aboutsummaryrefslogtreecommitdiff
path: root/apps/browser-extension/utils/constants.ts
blob: 5d61ffdffb37e486b5516acad3581491770970af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/**
 * API Endpoints
 */
export const API_ENDPOINTS = {
	SUPERMEMORY_API: import.meta.env.PROD
		? "https://api.supermemory.ai"
		: "http://localhost:8787",
	SUPERMEMORY_WEB: import.meta.env.PROD
		? "https://app.supermemory.ai"
		: "http://localhost:3000",
} as const

/**
 * DOM Element IDs
 */
export const ELEMENT_IDS = {
	TWITTER_IMPORT_BUTTON: "sm-twitter-import-button",
	TWITTER_ONBOARDING_TOAST: "sm-twitter-onboarding-toast",
	TWITTER_IMPORT_PROGRESS_TOAST: "sm-twitter-import-progress-toast",
	SUPERMEMORY_TOAST: "sm-toast",
	SUPERMEMORY_SAVE_BUTTON: "sm-save-button",
	SAVE_TWEET_ELEMENT: "sm-save-tweet-element",
	CHATGPT_INPUT_BAR_ELEMENT: "sm-chatgpt-input-bar-element",
	CLAUDE_INPUT_BAR_ELEMENT: "sm-claude-input-bar-element",
	T3_INPUT_BAR_ELEMENT: "sm-t3-input-bar-element",
	PROJECT_SELECTION_MODAL: "sm-project-selection-modal",
	SELECTION_SEARCH_FAB: "sm-selection-search-fab",
	SELECTION_SEARCH_PANEL: "sm-selection-search-panel",
} as const

/**
 * Storage Keys for local
 */
export const STORAGE_KEYS = {
	TWITTER_BOOKMARKS_ONBOARDING_SEEN: "sm_twitter_bookmarks_onboarding_seen",
	TWITTER_BOOKMARKS_IMPORT_INTENT_UNTIL: "sm_twitter_bookmarks_import_intent_until",
} as const

/**
 * UI Configuration
 */
export const UI_CONFIG = {
	BUTTON_SHOW_DELAY: 2000, // milliseconds
	TOAST_DURATION: 3000, // milliseconds
	ONBOARDING_TOAST_DURATION: 6000, // milliseconds (6 seconds for progress bar)
	IMPORT_INTENT_TTL: 2 * 60 * 1000, // 2 minutes TTL for import intent
	RATE_LIMIT_BASE_WAIT: 60000, // 1 minute
	PAGINATION_DELAY: 1000, // 1 second between requests
	AUTO_SEARCH_DEBOUNCE_DELAY: 1500, // milliseconds to wait after user stops typing
	OBSERVER_THROTTLE_DELAY: 300, // milliseconds between observer callback executions
	ROUTE_CHECK_INTERVAL: 2000, // milliseconds between route change checks
	API_REQUEST_TIMEOUT: 10000, // milliseconds for API request timeout
	SELECTION_MIN_LENGTH: 3, // minimum characters to show FAB
	SELECTION_MAX_LENGTH: 500, // maximum characters to show FAB
} as const

/**
 * Supported Domains
 */
export const DOMAINS = {
	TWITTER: ["x.com", "twitter.com"],
	CHATGPT: ["chatgpt.com", "chat.openai.com"],
	CLAUDE: ["claude.ai"],
	T3: ["t3.chat"],
	SUPERMEMORY: ["localhost", "supermemory.ai", "app.supermemory.ai"],
} as const

/**
 * Container Tags
 */
export const CONTAINER_TAGS = {
	TWITTER_BOOKMARKS: "sm_project_twitter_bookmarks",
	DEFAULT_PROJECT: "sm_project_default",
} as const

/**
 * Message Types for extension communication
 */
export const MESSAGE_TYPES = {
	SAVE_MEMORY: "sm-save-memory",
	SHOW_TOAST: "sm-show-toast",
	BATCH_IMPORT_ALL: "sm-batch-import-all",
	IMPORT_UPDATE: "sm-import-update",
	IMPORT_DONE: "sm-import-done",
	GET_RELATED_MEMORIES: "sm-get-related-memories",
	CAPTURE_PROMPT: "sm-capture-prompt",
	FETCH_PROJECTS: "sm-fetch-projects",
	SEARCH_SELECTION: "sm-search-selection",
	OPEN_SEARCH_PANEL: "sm-open-search-panel",
	TWITTER_IMPORT_OPEN_MODAL: "sm-twitter-import-open-modal",
} as const

export const CONTEXT_MENU_IDS = {
	SAVE_TO_SUPERMEMORY: "sm-save-to-supermemory",
	SEARCH_SUPERMEMORY: "sm-search-supermemory",
} as const

export const POSTHOG_EVENT_KEY = {
	TWITTER_IMPORT_STARTED: "twitter_import_started",
	SAVE_MEMORY_ATTEMPTED: "save_memory_attempted",
	SAVE_MEMORY_ATTEMPT_FAILED: "save_memory_attempt_failed",
	SOURCE: "extension",
	T3_CHAT_MEMORIES_SEARCHED: "t3_chat_memories_searched",
	T3_CHAT_MEMORIES_AUTO_SEARCHED: "t3_chat_memories_auto_searched",
	CLAUDE_CHAT_MEMORIES_SEARCHED: "claude_chat_memories_searched",
	CLAUDE_CHAT_MEMORIES_AUTO_SEARCHED: "claude_chat_memories_auto_searched",
	CHATGPT_CHAT_MEMORIES_SEARCHED: "chatgpt_chat_memories_searched",
	CHATGPT_CHAT_MEMORIES_AUTO_SEARCHED: "chatgpt_chat_memories_auto_searched",
	SELECTION_SEARCH_TRIGGERED: "selection_search_triggered",
	SELECTION_SEARCH_COPIED: "selection_search_copied",
} as const