The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: send page params on telemetry event
phamhieu00e76cd00da2
diff --git a/apps/www/components/Features/index.tsx b/apps/www/components/Features/index.tsxindex 2b14cc6fbfe..4b291e78767 100644--- a/apps/www/components/Features/index.tsx+++ b/apps/www/components/Features/index.tsx@@ -6,8 +6,10 @@ import SectionContainer from '../Layouts/SectionContainer'import ProductIcon from '../ProductIcon'import TextLink from '../TextLink'import { useGoogleAnalyticsProps } from 'common/hooks/useGoogleAnalyticsProps'+import { useRouter } from 'next/router'const Features = () => {+ const router = useRouter()const googleAnalyticsProps = useGoogleAnalyticsProps()const sendTelemetryEvent = async (product: any) => {@@ -15,27 +17,32 @@ const Features = () => {case 'Database':return await Telemetry.sendEvent(gaEvents['www_hp_subhero_products_database'],- googleAnalyticsProps+ googleAnalyticsProps,+ router)case 'Authentication':return await Telemetry.sendEvent(gaEvents['www_hp_subhero_products_auth'],- googleAnalyticsProps+ googleAnalyticsProps,+ router)case 'Storage':return await Telemetry.sendEvent(gaEvents['www_hp_subhero_products_storage'],- googleAnalyticsProps+ googleAnalyticsProps,+ router)case 'Edge Functions':return await Telemetry.sendEvent(gaEvents['www_hp_subhero_products_edgeFunctions'],- googleAnalyticsProps+ googleAnalyticsProps,+ router)case 'Realtime':return await Telemetry.sendEvent(gaEvents['www_hp_subhero_products_realtime'],- googleAnalyticsProps+ googleAnalyticsProps,+ router)}}diff --git a/apps/www/components/Hero.tsx b/apps/www/components/Hero.tsxindex e8d336787af..33a1e3deec6 100644--- a/apps/www/components/Hero.tsx+++ b/apps/www/components/Hero.tsx@@ -7,11 +7,12 @@ import gaEvents from '~/lib/gaEvents'import { useGoogleAnalyticsProps } from 'common/hooks/useGoogleAnalyticsProps'const Hero = () => {- const { basePath } = useRouter()+ const router = useRouter()+ const { basePath } = routerconst googleAnalyticsProps = useGoogleAnalyticsProps()const sendTelemetryEvent = async (event: GoogleAnalyticsEvent) => {- await Telemetry.sendEvent(event, googleAnalyticsProps)+ await Telemetry.sendEvent(event, googleAnalyticsProps, router)}return (diff --git a/apps/www/lib/telemetry.ts b/apps/www/lib/telemetry.tsindex aa0097d1f17..e64f0992b68 100644--- a/apps/www/lib/telemetry.ts+++ b/apps/www/lib/telemetry.ts@@ -1,6 +1,7 @@import { post } from '~/lib/fetchWrapper'import { API_URL, IS_PROD, IS_PREVIEW } from 'lib/constants'import { BrowserTabTracker } from 'browser-session-tabs'+import { NextRouter } from 'next/router'export interface GoogleAnalyticsEvent {category: string@@ -17,7 +18,11 @@ export interface GoogleAnalyticsProps {// This event is the same as in studio/lib/telemetry.tx// but uses different ENV variables for www-const sendEvent = (event: GoogleAnalyticsEvent, gaProps: GoogleAnalyticsProps) => {+const sendEvent = (+ event: GoogleAnalyticsEvent,+ gaProps: GoogleAnalyticsProps,+ router: NextRouter+) => {if (!IS_PROD && !IS_PREVIEW) returnconst { category, action, label, value } = event@@ -27,6 +32,9 @@ const sendEvent = (event: GoogleAnalyticsEvent, gaProps: GoogleAnalyticsProps) =category: category,label: label,value: value,+ page_referrer: document?.referrer,+ page_title: document?.title,+ page_location: router.asPath,ga: {screen_resolution: gaProps?.screenResolution,language: gaProps?.language,diff --git a/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx b/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsxindex d1ea1631330..f400dbd6a13 100644--- a/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx+++ b/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx@@ -78,7 +78,8 @@ const SQLTemplates = observer(() => {action: 'script_clicked',label: x.title,},- googleAnalyticsProps+ googleAnalyticsProps,+ router)}}/>@@ -112,7 +113,8 @@ const SQLTemplates = observer(() => {action: 'quickstart_clicked',label: x.title,},- googleAnalyticsProps+ googleAnalyticsProps,+ router)}}/>diff --git a/studio/components/interfaces/SQLEditor/UtilityPanel/ResultsDropdown.tsx b/studio/components/interfaces/SQLEditor/UtilityPanel/ResultsDropdown.tsxindex 0f9ac2fe627..4d47dcedb13 100644--- a/studio/components/interfaces/SQLEditor/UtilityPanel/ResultsDropdown.tsx+++ b/studio/components/interfaces/SQLEditor/UtilityPanel/ResultsDropdown.tsx@@ -10,6 +10,7 @@ import { useSqlEditorStateSnapshot } from 'state/sql-editor'// @ts-ignoreimport MarkdownTable from 'markdown-table'import { useGoogleAnalyticsProps } from 'common'+import { useRouter } from 'next/router'export type ResultsDropdownProps = {id: string@@ -22,6 +23,7 @@ const ResultsDropdown = ({ id }: ResultsDropdownProps) => {const result = snap.results?.[id]?.[0] ?? undefinedconst { ui } = useStore()const csvRef = useRef<CSVLink & HTMLAnchorElement & { link: HTMLAnchorElement }>(null)+ const router = useRouter()const csvData = useMemo(() => (result?.rows ? compact(Array.from(result.rows || [])) : ''),@@ -32,7 +34,8 @@ const ResultsDropdown = ({ id }: ResultsDropdownProps) => {csvRef.current?.link.click()Telemetry.sendEvent({ category: 'sql_editor', action: 'sql_download_csv', label: '' },- googleAnalyticsProps+ googleAnalyticsProps,+ router)}@@ -55,7 +58,8 @@ const ResultsDropdown = ({ id }: ResultsDropdownProps) => {ui.setNotification({ category: 'success', message: 'Copied results to clipboard' })Telemetry.sendEvent({ category: 'sql_editor', action: 'sql_copy_as_markdown', label: '' },- googleAnalyticsProps+ googleAnalyticsProps,+ router)})}diff --git a/studio/lib/telemetry.ts b/studio/lib/telemetry.tsindex 1fc185b1699..f3a75970c6a 100644--- a/studio/lib/telemetry.ts+++ b/studio/lib/telemetry.ts@@ -2,6 +2,7 @@ import { post } from 'lib/common/fetch'import { API_URL, IS_PLATFORM } from 'lib/constants'import { User } from 'types'import { BrowserTabTracker } from 'browser-session-tabs'+import { NextRouter } from 'next/router'export interface GoogleAnalyticsProps {screenResolution?: string@@ -15,7 +16,8 @@ const sendEvent = (label: stringvalue?: string},- gaProps?: GoogleAnalyticsProps+ gaProps: GoogleAnalyticsProps,+ router: NextRouter) => {if (!IS_PLATFORM) return@@ -26,6 +28,9 @@ const sendEvent = (category: category,label: label,value: value,+ page_referrer: document?.referrer,+ page_title: document?.title,+ page_location: router.asPath,ga: {screen_resolution: gaProps?.screenResolution,language: gaProps?.language,