The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add consent conditions in telemetry requests
Joshen Lim272c62440ee9
diff --git a/studio/components/ui/PageTelemetry.tsx b/studio/components/ui/PageTelemetry.tsxindex 0cf97ebfb44..07a09c27677 100644--- a/studio/components/ui/PageTelemetry.tsx+++ b/studio/components/ui/PageTelemetry.tsx@@ -1,7 +1,7 @@import { useParams, useTelemetryProps } from 'common'import { useSelectedOrganization } from 'hooks'import { post } from 'lib/common/fetch'-import { API_URL, IS_PLATFORM } from 'lib/constants'+import { API_URL, IS_PLATFORM, LOCAL_STORAGE_KEYS } from 'lib/constants'import { observer } from 'mobx-react-lite'import { useRouter } from 'next/router'import { PropsWithChildren, useEffect } from 'react'@@ -12,6 +12,11 @@ const PageTelemetry = ({ children }: PropsWithChildren<{}>) => {const telemetryProps = useTelemetryProps()const selectedOrganization = useSelectedOrganization()+ const consent =+ typeof window !== 'undefined'+ ? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)+ : null+useEffect(() => {function handleRouteChange(url: string) {handlePageTelemetry(url)@@ -39,7 +44,7 @@ const PageTelemetry = ({ children }: PropsWithChildren<{}>) => {* @param route: the browser url* */const handlePageTelemetry = async (route: string) => {- if (IS_PLATFORM) {+ if (IS_PLATFORM && consent === 'true') {/*** Get referrer from browser*/diff --git a/studio/lib/telemetry.ts b/studio/lib/telemetry.tsindex d4dc380411f..88f5c4c954d 100644--- a/studio/lib/telemetry.ts+++ b/studio/lib/telemetry.ts@@ -1,5 +1,5 @@import { post } from 'lib/common/fetch'-import { API_URL, IS_PLATFORM } from 'lib/constants'+import { API_URL, IS_PLATFORM, LOCAL_STORAGE_KEYS } from 'lib/constants'import { User } from 'types'import { NextRouter } from 'next/router'@@ -20,6 +20,12 @@ const sendEvent = () => {if (!IS_PLATFORM) return+ const consent =+ typeof window !== 'undefined'+ ? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)+ : null+ if (consent !== 'true') return+const { category, action, label, value } = eventreturn post(`${API_URL}/telemetry/event`, {@@ -44,6 +50,12 @@ const sendEvent = (const sendIdentify = (user: User, gaProps?: TelemetryProps) => {if (!IS_PLATFORM) return+ const consent =+ typeof window !== 'undefined'+ ? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)+ : null+ if (consent !== 'true') return+return post(`${API_URL}/telemetry/identify`, {user,ga: {@@ -65,6 +77,12 @@ const sendActivity = () => {if (!IS_PLATFORM) return+ const consent =+ typeof window !== 'undefined'+ ? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)+ : null+ if (consent !== 'true') return+const { activity, source, projectRef, orgSlug, data } = eventconst properties = {