The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(telemetry): track home page and getting started exposure (#42247)
Pamela Chiaef84dddc2266
diff --git a/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStartedSection.tsx b/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStartedSection.tsxindex cd220809d3f..62128342303 100644--- a/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStartedSection.tsx+++ b/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStartedSection.tsx@@ -1,14 +1,12 @@import { Code, Table2 } from 'lucide-react'import { useRouter } from 'next/router'-import { useCallback, useMemo, useState } from 'react'+import { useCallback, useEffect, useMemo, useRef, useState } from 'react'-import { useParams } from 'common'+import { IS_PLATFORM, useParams } from 'common'import { FRAMEWORKS } from 'components/interfaces/Connect/Connect.constants'import { SIDEBAR_KEYS } from 'components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'-import { useSendEventMutation } from 'data/telemetry/send-event-mutation'-import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'-import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'import { BASE_PATH } from 'lib/constants'+import { useTrack } from 'lib/telemetry/track'import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state'import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state'import { Button, Card, CardContent, ToggleGroup, ToggleGroupItem } from 'ui'@@ -34,9 +32,7 @@ interface GettingStartedSectionProps {export function GettingStartedSection({ value, onChange }: GettingStartedSectionProps) {const router = useRouter()const { ref } = useParams()- const { data: project } = useSelectedProjectQuery()- const { data: organization } = useSelectedOrganizationQuery()- const { mutate: sendEvent } = useSendEventMutation()+ const track = useTrack()const aiSnap = useAiAssistantStateSnapshot()const { openSidebar } = useSidebarManagerSnapshot()@@ -141,6 +137,19 @@ export function GettingStartedSection({ value, onChange }: GettingStartedSectionconst steps = workflow === 'code' ? codeSteps : workflow === 'no-code' ? noCodeSteps : []+ const hasTrackedExposure = useRef(false)++ useEffect(() => {+ if (!IS_PLATFORM) return+ if (hasTrackedExposure.current) return++ hasTrackedExposure.current = true++ track('home_getting_started_section_exposed', {+ workflow: workflow === 'no-code' ? 'no_code' : workflow === 'code' ? 'code' : null,+ })+ }, [workflow, track])+return (<section className="w-full"><div className="flex justify-between items-center mb-6">@@ -154,16 +163,9 @@ export function GettingStartedSection({ value, onChange }: GettingStartedSectionconst newWorkflow = v as 'no-code' | 'code'setPreviousWorkflow(workflow)onChange(newWorkflow)- sendEvent({- action: 'home_getting_started_workflow_clicked',- properties: {- workflow: newWorkflow === 'no-code' ? 'no_code' : 'code',- is_switch: previousWorkflow !== null,- },- groups: {- project: project?.ref || '',- organization: organization?.slug || '',- },+ track('home_getting_started_workflow_clicked', {+ workflow: newWorkflow === 'no-code' ? 'no_code' : 'code',+ is_switch: previousWorkflow !== null,})}}}@@ -197,17 +199,10 @@ export function GettingStartedSection({ value, onChange }: GettingStartedSection(step) => step.status === 'complete').lengthconst totalSteps = (workflow === 'code' ? codeSteps : noCodeSteps).length- sendEvent({- action: 'home_getting_started_closed',- properties: {- workflow: workflow === 'no-code' ? 'no_code' : 'code',- steps_completed: completedSteps,- total_steps: totalSteps,- },- groups: {- project: project?.ref || '',- organization: organization?.slug || '',- },+ track('home_getting_started_closed', {+ workflow: workflow === 'no-code' ? 'no_code' : 'code',+ steps_completed: completedSteps,+ total_steps: totalSteps,})}}}@@ -250,16 +245,9 @@ export function GettingStartedSection({ value, onChange }: GettingStartedSectiononClick={() => {setPreviousWorkflow(workflow)onChange('no-code')- sendEvent({- action: 'home_getting_started_workflow_clicked',- properties: {- workflow: 'no_code',- is_switch: previousWorkflow !== null,- },- groups: {- project: project?.ref || '',- organization: organization?.slug || '',- },+ track('home_getting_started_workflow_clicked', {+ workflow: 'no_code',+ is_switch: previousWorkflow !== null,})}}className="block gap-2 h-auto p-4 md:p-8 max-w-80 text-left justify-start bg-background "@@ -278,16 +266,9 @@ export function GettingStartedSection({ value, onChange }: GettingStartedSectiononClick={() => {setPreviousWorkflow(workflow)onChange('code')- sendEvent({- action: 'home_getting_started_workflow_clicked',- properties: {- workflow: 'code',- is_switch: previousWorkflow !== null,- },- groups: {- project: project?.ref || '',- organization: organization?.slug || '',- },+ track('home_getting_started_workflow_clicked', {+ workflow: 'code',+ is_switch: previousWorkflow !== null,})}}className="bg-background block gap-2 h-auto p-4 md:p-8 max-w-80 text-left justify-start"@@ -308,19 +289,12 @@ export function GettingStartedSection({ value, onChange }: GettingStartedSectionsteps={steps}onStepClick={({ stepIndex, stepTitle, actionType, wasCompleted }) => {if (workflow) {- sendEvent({- action: 'home_getting_started_step_clicked',- properties: {- workflow: workflow === 'no-code' ? 'no_code' : 'code',- step_number: stepIndex + 1,- step_title: stepTitle,- action_type: actionType,- was_completed: wasCompleted,- },- groups: {- project: project?.ref || '',- organization: organization?.slug || '',- },+ track('home_getting_started_step_clicked', {+ workflow: workflow === 'no-code' ? 'no_code' : 'code',+ step_number: stepIndex + 1,+ step_title: stepTitle,+ action_type: actionType,+ was_completed: wasCompleted,})}}}diff --git a/apps/studio/pages/project/[ref]/index.tsx b/apps/studio/pages/project/[ref]/index.tsxindex fe1e6e8903b..a28d4c452dd 100644--- a/apps/studio/pages/project/[ref]/index.tsx+++ b/apps/studio/pages/project/[ref]/index.tsx@@ -1,12 +1,17 @@+import { IS_PLATFORM } from 'common'import { Home } from 'components/interfaces/Home/Home'import { HomeV2 } from 'components/interfaces/HomeNew/Home'import DefaultLayout from 'components/layouts/DefaultLayout'import { ProjectLayoutWithAuth } from 'components/layouts/ProjectLayout'+import { useTrackExperimentExposure } from 'hooks/misc/useTrackExperimentExposure'import { usePHFlag } from 'hooks/ui/useFlag'import type { NextPageWithLayout } from 'types'const HomePage: NextPageWithLayout = () => {- const isHomeNew = usePHFlag('homeNew') === 'new-home'+ const homeNewVariant = usePHFlag<string>('homeNew')+ const isHomeNew = homeNewVariant === 'new-home'++ useTrackExperimentExposure('home_new', IS_PLATFORM ? homeNewVariant : undefined)if (isHomeNew) {return <HomeV2 />diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.tsindex 8b0349c682c..46c8f39fdff 100644--- a/packages/common/telemetry-constants.ts+++ b/packages/common/telemetry-constants.ts@@ -1864,6 +1864,42 @@ export interface HomeGettingStartedClosedEvent {groups: TelemetryGroups}+/**+ * Getting Started section was shown to the user in HomeV2.+ *+ * @group Events+ * @source studio+ * @page /project/{ref}+ */+export interface HomeGettingStartedSectionExposedEvent {+ action: 'home_getting_started_section_exposed'+ properties: {+ /**+ * The current workflow shown (null if choosing workflow)+ */+ workflow: 'code' | 'no_code' | null+ }+ groups: TelemetryGroups+}++/**+ * User was exposed to the HomeV2 experiment (shown the new home page).+ *+ * @group Events+ * @source studio+ * @page /project/{ref}+ */+export interface HomeNewExperimentExposedEvent {+ action: 'home_new_experiment_exposed'+ properties: {+ /**+ * The experiment variant shown to the user+ */+ variant: string+ }+ groups: TelemetryGroups+}+/*** User reordered sections in HomeV2 using drag and drop.*@@ -2718,6 +2754,8 @@ export type TelemetryEvent =| HomeGettingStartedWorkflowClickedEvent| HomeGettingStartedStepClickedEvent| HomeGettingStartedClosedEvent+ | HomeGettingStartedSectionExposedEvent+ | HomeNewExperimentExposedEvent| HomeSectionRowsMovedEvent| HomeActivityStatClickedEvent| HomeProjectUsageServiceClickedEvent