local-storage.ts176 lines · main
| 1 | export const LOCAL_STORAGE_KEYS = { |
| 2 | /** |
| 3 | * STUDIO |
| 4 | */ |
| 5 | AI_ASSISTANT_STATE: (projectRef: string | undefined) => |
| 6 | `briven-ai-assistant-state-${projectRef}`, |
| 7 | SIDEBAR_BEHAVIOR: 'briven-sidebar-behavior', |
| 8 | EDITOR_PANEL_STATE: 'briven-editor-panel-state', |
| 9 | PROJECTS_VIEW: 'projects-view', |
| 10 | PROJECTS_FILTER: 'projects-filter', |
| 11 | PROJECTS_SORT: 'projects-sort', |
| 12 | FEEDBACK_WIDGET_CONTENT: 'feedback-widget-content', |
| 13 | FEEDBACK_WIDGET_SCREENSHOT: 'feedback-widget-screenshot', |
| 14 | INCIDENT_BANNER_DISMISSED_IDS: 'incident-banner-dismissed-ids', |
| 15 | MAINTENANCE_BANNER_DISMISSED: (id: string) => `maintenance-banner-dismissed-${id}`, |
| 16 | DASHBOARD_PREFERENCES: (ref: string) => `dashboard-preferences-${ref}`, |
| 17 | UNIFIED_LOGS_DOCK: 'unified-logs-dock', |
| 18 | |
| 19 | UI_TIMEZONE: 'briven-ui-timezone', |
| 20 | UI_PREVIEW_CLS: 'briven-ui-cls', |
| 21 | UI_PREVIEW_INLINE_EDITOR: 'briven-ui-preview-inline-editor', |
| 22 | UI_PREVIEW_UNIFIED_LOGS: 'briven-ui-preview-unified-logs', |
| 23 | UI_ONBOARDING_NEW_PAGE_SHOWN: 'briven-ui-onboarding-new-page-shown', |
| 24 | UI_PREVIEW_ADVISOR_RULES: 'briven-ui-advisor-rules', |
| 25 | UI_PREVIEW_QUEUE_OPERATIONS: 'briven-ui-queue-operations', |
| 26 | UI_PREVIEW_PG_DELTA_DIFF: 'briven-ui-pg-delta-diff', |
| 27 | UI_PREVIEW_PLATFORM_WEBHOOKS: 'briven-ui-platform-webhooks', |
| 28 | UI_PREVIEW_JIT_DB_ACCESS: 'briven-ui-jit-db-access', |
| 29 | UI_PREVIEW_RLS_TESTER: 'briven-ui-rls-tester', |
| 30 | UI_PREVIEW_MARKETPLACE: 'briven-ui-marketplace', |
| 31 | |
| 32 | NEW_LAYOUT_NOTICE_ACKNOWLEDGED: 'new-layout-notice-acknowledge', |
| 33 | TABS_INTERFACE_ACKNOWLEDGED: 'tabs-interface-acknowledge', |
| 34 | AI_ASSISTANT_MCP_OPT_IN: 'ai-assistant-mcp-opt-in', |
| 35 | |
| 36 | DASHBOARD_HISTORY: (ref: string) => `dashboard-history-${ref}`, |
| 37 | STORAGE_PREFERENCE: (ref: string) => `storage-explorer-${ref}`, |
| 38 | |
| 39 | AUTH_USERS_FILTER: (ref: string) => `auth-users-filter-${ref}`, |
| 40 | AUTH_USERS_SORT_BY_VALUE: (ref: string) => `auth-users-sort-by-value-${ref}`, |
| 41 | AUTH_USERS_COLUMNS_CONFIGURATION: (ref: string) => `briven-auth-users-columns-${ref}`, |
| 42 | AUTH_USERS_IMPROVED_SEARCH_DISMISSED: (ref: string) => |
| 43 | `auth-users-improved-search-dismissed-${ref}`, |
| 44 | |
| 45 | SQL_EDITOR_INTELLISENSE: 'briven_sql-editor-intellisense-enabled', |
| 46 | SQL_EDITOR_SPLIT_SIZE: 'briven_sql-editor-split-size', |
| 47 | // Key to track which schemas are ok to be sent to AI. The project ref is intentionally put at the end for easier search in the browser console. |
| 48 | SQL_EDITOR_AI_SCHEMA: (ref: string) => `briven_sql-editor-ai-schema-enabled-${ref}`, |
| 49 | SQL_EDITOR_AI_OPEN: 'briven_sql-editor-ai-open', |
| 50 | SQL_EDITOR_LAST_SELECTED_DB: (ref: string) => `sql-editor-last-selected-db-${ref}`, |
| 51 | SQL_EDITOR_SQL_BLOCK_ACKNOWLEDGED: (ref: string) => `sql-editor-sql-block-acknowledged-${ref}`, |
| 52 | SQL_EDITOR_SECTION_STATE: (ref: string) => `sql-editor-section-state-${ref}`, |
| 53 | SQL_EDITOR_SORT: (ref: string) => `sql-editor-sort-${ref}`, |
| 54 | |
| 55 | LOG_EXPLORER_SPLIT_SIZE: 'briven_log-explorer-split-size', |
| 56 | GRAPHIQL_RLS_BYPASS_WARNING: 'graphiql-rls-bypass-warning-dismissed', |
| 57 | GRAPHQL_INTROSPECTION_NOTICE_COLLAPSED: (ref: string) => |
| 58 | `graphql-introspection-notice-collapsed-${ref}`, |
| 59 | CLS_DIFF_WARNING: 'cls-diff-warning-dismissed', |
| 60 | CLS_SELECT_STAR_WARNING: 'cls-select-star-warning-dismissed', |
| 61 | QUERY_PERF_SHOW_BOTTOM_SECTION: 'briven-query-perf-show-bottom-section', |
| 62 | LINTER_SHOW_FOOTER: 'briven-linter-show-footer', |
| 63 | // Key to track account deletion requests |
| 64 | ACCOUNT_DELETION_REQUEST: 'briven-account-deletion-request', |
| 65 | // Used for storing a user id when sending reports to Sentry. The id is hashed for anonymity. |
| 66 | SENTRY_USER_ID: 'briven-sentry-user-id', |
| 67 | // Used for storing the last sign in method used by the user |
| 68 | LAST_SIGN_IN_METHOD: 'briven-last-sign-in-method', |
| 69 | // Key to track the last selected schema. The project ref is intentionally put at the end for easier search in the browser console. |
| 70 | LAST_SELECTED_SCHEMA: (ref: string) => `last-selected-schema-${ref}`, |
| 71 | // Track position of nodes for schema visualizer |
| 72 | SCHEMA_VISUALIZER_POSITIONS: (ref: string, schemaId: number) => |
| 73 | `schema-visualizer-positions-${ref}-${schemaId}`, |
| 74 | // Used for allowing the main nav panel to expand on hover |
| 75 | EXPAND_NAVIGATION_PANEL: 'briven-expand-navigation-panel', |
| 76 | GITHUB_AUTHORIZATION_STATE: 'briven-github-authorization-state', |
| 77 | // Notice banner keys |
| 78 | FLY_DEPRECATION_2026_05_31: 'fly-deprecation-2026-05-31-dismissed', |
| 79 | API_KEYS_FEEDBACK_DISMISSED: (ref: string) => `briven-api-keys-feedback-dismissed-${ref}`, |
| 80 | TERMS_OF_SERVICE_UPDATE: 'terms-of-service-update-2026-06-06', |
| 81 | REPORT_DATERANGE: 'briven-report-daterange', |
| 82 | PROJECT_PAUSING_STARTED_AT: (ref: string) => `briven-project-pausing-started-at-${ref}`, |
| 83 | PROJECT_RESTORING_STARTED_AT: (ref: string) => `briven-project-restoring-started-at-${ref}`, |
| 84 | |
| 85 | // api keys view switcher for new and legacy api keys |
| 86 | API_KEYS_VIEW: (ref: string) => `briven-api-keys-view-${ref}`, |
| 87 | |
| 88 | // Shortcut preferences |
| 89 | SHORTCUT_STORAGE_KEY: 'briven-shortcut-preferences', |
| 90 | |
| 91 | LAST_VISITED_ORGANIZATION: 'last-visited-organization', |
| 92 | |
| 93 | // user impersonation selector previous searches |
| 94 | USER_IMPERSONATION_SELECTOR_PREVIOUS_SEARCHES: (ref: string) => |
| 95 | `user-impersonation-selector-previous-searches-${ref}`, |
| 96 | |
| 97 | LAST_OPENED_SIDE_BAR: (ref: string) => `last-opened-sidebar-${ref}`, |
| 98 | |
| 99 | // Index Advisor notice dismissed |
| 100 | INDEX_ADVISOR_NOTICE_DISMISSED: (ref: string) => `index-advisor-notice-dismissed-${ref}`, |
| 101 | |
| 102 | // RLS event trigger banner dismissed |
| 103 | RLS_EVENT_TRIGGER_BANNER_DISMISSED: (ref: string) => `rls-event-trigger-banner-dismissed-${ref}`, |
| 104 | |
| 105 | PROJECT_SECURITY_DISMISSED_AT: (ref: string) => `project-security-dismissed-at-${ref}`, |
| 106 | |
| 107 | RLS_TESTER_BANNER_DISMISSED: (ref: string) => `rls-tester-banner-dismissed-${ref}`, |
| 108 | |
| 109 | // Observability banner dismissed |
| 110 | OBSERVABILITY_BANNER_DISMISSED: (ref: string) => `observability-banner-dismissed-${ref}`, |
| 111 | ORGANIZATION_MARKETPLACE_BANNER_DISMISSED: (orgSlug: string, managedBy: string) => |
| 112 | `organization-marketplace-banner-dismissed-${orgSlug}-${managedBy}`, |
| 113 | PROJECT_INTEGRATION_BANNER_DISMISSED: (ref: string, integrationSource: string) => |
| 114 | `project-integration-banner-dismissed-${ref}-${integrationSource}`, |
| 115 | |
| 116 | TABLE_EDITOR_QUEUE_OPERATIONS_BANNER_DISMISSED: (ref: string) => |
| 117 | `table-editor-queue-operations-banner-dismissed-${ref}`, |
| 118 | FREE_MICRO_UPGRADE_BANNER_DISMISSED: (ref: string) => |
| 119 | `free-micro-upgrade-banner-dismissed-${ref}`, |
| 120 | STORAGE_PUBLIC_BUCKET_SELECT_POLICY_WARNING_DISMISSED: (ref: string, bucketId: string) => |
| 121 | `storage-public-bucket-select-policy-warning-dismissed-${ref}-${bucketId}`, |
| 122 | PRIVACY_NOTICE_ACKNOWLEDGED: 'privacy-notice-acknowledged-2026-03', |
| 123 | |
| 124 | /** |
| 125 | * COMMON |
| 126 | */ |
| 127 | /** @deprecated – we're using usercentrics instead to handle telemetry consent */ |
| 128 | TELEMETRY_CONSENT: 'briven-consent-ph', |
| 129 | |
| 130 | /** |
| 131 | * DOCS |
| 132 | */ |
| 133 | SAVED_ORG: 'docs.ui.user.selected.org', |
| 134 | SAVED_PROJECT: 'docs.ui.user.selected.project', |
| 135 | SAVED_BRANCH: 'docs.ui.user.selected.branch', |
| 136 | |
| 137 | HIDE_PROMO_TOAST: 'briven-hide-promo-toast-lw15-ticket', |
| 138 | |
| 139 | /** |
| 140 | * WWW |
| 141 | */ |
| 142 | BLOG_VIEW: 'briven-blog-view', |
| 143 | } as const |
| 144 | |
| 145 | export type LocalStorageKey = (typeof LOCAL_STORAGE_KEYS)[keyof typeof LOCAL_STORAGE_KEYS] |
| 146 | |
| 147 | const LOCAL_STORAGE_KEYS_ALLOWLIST = [ |
| 148 | 'graphiql:theme', |
| 149 | 'theme', |
| 150 | 'brivenDarkMode', |
| 151 | 'briven.dashboard.auth.debug', |
| 152 | 'briven.dashboard.auth.navigatorLock.disabled', |
| 153 | LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT, |
| 154 | LOCAL_STORAGE_KEYS.UI_PREVIEW_INLINE_EDITOR, |
| 155 | LOCAL_STORAGE_KEYS.UI_PREVIEW_QUEUE_OPERATIONS, |
| 156 | LOCAL_STORAGE_KEYS.UI_PREVIEW_CLS, |
| 157 | LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS, |
| 158 | LOCAL_STORAGE_KEYS.UI_PREVIEW_PLATFORM_WEBHOOKS, |
| 159 | LOCAL_STORAGE_KEYS.UI_PREVIEW_JIT_DB_ACCESS, |
| 160 | LOCAL_STORAGE_KEYS.UI_PREVIEW_MARKETPLACE, |
| 161 | LOCAL_STORAGE_KEYS.LAST_SIGN_IN_METHOD, |
| 162 | LOCAL_STORAGE_KEYS.HIDE_PROMO_TOAST, |
| 163 | LOCAL_STORAGE_KEYS.BLOG_VIEW, |
| 164 | LOCAL_STORAGE_KEYS.AI_ASSISTANT_MCP_OPT_IN, |
| 165 | LOCAL_STORAGE_KEYS.LINTER_SHOW_FOOTER, |
| 166 | LOCAL_STORAGE_KEYS.SIDEBAR_BEHAVIOR, |
| 167 | LOCAL_STORAGE_KEYS.UI_TIMEZONE, |
| 168 | ] |
| 169 | |
| 170 | export function clearLocalStorage() { |
| 171 | for (const key in localStorage) { |
| 172 | if (!LOCAL_STORAGE_KEYS_ALLOWLIST.includes(key)) { |
| 173 | localStorage.removeItem(key) |
| 174 | } |
| 175 | } |
| 176 | } |