Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

refactor(growth): remove useTelemetryCookie and sb-telemetry-data cookie (#43840)

Sean Oliver571533482fa7
diff --git a/packages/common/constants/local-storage.ts b/packages/common/constants/local-storage.ts
index 695933ded31..9f98d577c10 100644
--- a/packages/common/constants/local-storage.ts
+++ b/packages/common/constants/local-storage.ts
@@ -123,7 +123,6 @@ export const LOCAL_STORAGE_KEYS = {
*/
/** @deprecated – we're using usercentrics instead to handle telemetry consent */
TELEMETRY_CONSENT: 'supabase-consent-ph',
- TELEMETRY_DATA: 'supabase-telemetry-data',
/**
* DOCS
diff --git a/packages/common/hooks/useTelemetryCookie.tsx b/packages/common/hooks/useTelemetryCookie.tsx
deleted file mode 100644
index 0e06ed2d2ed..00000000000
--- a/packages/common/hooks/useTelemetryCookie.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import { useEffect } from 'react'
-
-import { LOCAL_STORAGE_KEYS } from '../constants'
-import { getSharedTelemetryData, getTelemetryCookieOptions } from '../telemetry-utils'
-
-interface UseTelemetryCookieProps {
- enabled: boolean
-}
-
-/**
- * @deprecated Superseded by `useFirstTouchStore` which uses an in-memory store
- * instead of a cookie. Removal tracked under GROWTH-646.
- */
-export function useTelemetryCookie({ enabled }: UseTelemetryCookieProps) {
- const telemetryStorageKey = LOCAL_STORAGE_KEYS.TELEMETRY_DATA
-
- useEffect(() => {
- if (typeof window === 'undefined') return
- if (!enabled) return
-
- const cookies = document.cookie.split(';')
- const cookieOptions = getTelemetryCookieOptions()
-
- const telemetryCookie = cookies.find((cookie) =>
- cookie.trim().startsWith(`${telemetryStorageKey}=`)
- )
- if (telemetryCookie) return
-
- const telemetryData = getSharedTelemetryData(window.location.pathname)
-
- const encodedData = encodeURIComponent(JSON.stringify(telemetryData))
- document.cookie = `${telemetryStorageKey}=${encodedData}; ${cookieOptions}`
- }, [enabled, telemetryStorageKey])
-}
-
-export default useTelemetryCookie
diff --git a/packages/common/telemetry-utils.ts b/packages/common/telemetry-utils.ts
index 814154a69e4..edec73a00a7 100644
--- a/packages/common/telemetry-utils.ts
+++ b/packages/common/telemetry-utils.ts
@@ -1,4 +1,4 @@
-import { IS_PROD, LOCAL_STORAGE_KEYS } from './constants'
+import { IS_PROD } from './constants'
import { isBrowser } from './helpers'
export function getTelemetryCookieOptions() {
@@ -10,11 +10,6 @@ export function getTelemetryCookieOptions() {
return isSupabaseCom ? 'path=/; domain=supabase.com; SameSite=Lax' : 'path=/; SameSite=Lax'
}
-export function clearTelemetryDataCookie() {
- if (!isBrowser) return
- document.cookie = `${LOCAL_STORAGE_KEYS.TELEMETRY_DATA}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; max-age=0; ${getTelemetryCookieOptions()}`
-}
-
// Parse session_id from PostHog cookie since SDK doesn't expose session ID
// (needed to correlate client and server events)
function getPostHogSessionId(): string | null {
diff --git a/packages/ui-patterns/src/consent.tsx b/packages/ui-patterns/src/consent.tsx
index 877960d439e..a6bbbb556a5 100644
--- a/packages/ui-patterns/src/consent.tsx
+++ b/packages/ui-patterns/src/consent.tsx
@@ -1,6 +1,6 @@
'use client'
-import { clearTelemetryDataCookie, consentState, isBrowser } from 'common'
+import { consentState, isBrowser } from 'common'
import { useCallback, useEffect, useRef } from 'react'
import { toast } from 'sonner'
import { cn } from 'ui'
@@ -26,7 +26,6 @@ export const useConsentToast = () => {
if (!isBrowser) return
snap.denyAll()
- clearTelemetryDataCookie()
// Clear GA4 and sGTM tracking cookies
const trackingCookies = ['_ga', '_ga_XW18KGKGNR', 'FPID', 'FPAU', 'FPLC']