Skip to content

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

feat(studio): add creation funnel telemetry (#47291)

Pamela Chia0a797ef4ea89
diff --git a/apps/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx b/apps/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx
index c21083f1d1f..36dfbf16b50 100644
--- a/apps/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx
+++ b/apps/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx
@@ -63,6 +63,7 @@ import {
classifyStripeError,
classifyValidationError,
} from '@/lib/telemetry/funnel-errors'
+import { useTrack } from '@/lib/telemetry/track'
import { useTrackFunnelError } from '@/lib/telemetry/use-track-funnel-error'
interface NewOrgFormProps {
@@ -98,6 +99,7 @@ export const NewOrgForm = ({
}: NewOrgFormProps) => {
const router = useRouter()
const user = useProfile()
+ const track = useTrack()
const { resolvedTheme } = useTheme()
const { lastVisitedOrganization } = useLastVisitedOrganization()
@@ -170,6 +172,14 @@ export const NewOrgForm = ({
}
}, [isSuccess, form, organizations?.length, user.profile?.username, user.isSuccess])
+ const hasTrackedFormExposed = useRef(false)
+ useEffect(() => {
+ if (hasTrackedFormExposed.current) return
+ if (!user.isSuccess) return
+ hasTrackedFormExposed.current = true
+ track('organization_creation_form_exposed')
+ }, [user.isSuccess, track])
+
const [latestAddress, setLatestAddress] = useState<CustomerAddress>()
const [latestTaxId, setLatestTaxId] = useState<CustomerTaxId | null>()
@@ -288,6 +298,8 @@ export const NewOrgForm = ({
}
const onOrganizationCreated = (org: { slug: string }) => {
+ track('organization_creation_completed', undefined, { organization: org.slug })
+
const prefilledProjectName = user.profile?.username
? user.profile.username + `'s Project`
: 'My Project'
diff --git a/apps/studio/pages/new/[slug].tsx b/apps/studio/pages/new/[slug].tsx
index a1738298df2..e37ca9b8d19 100644
--- a/apps/studio/pages/new/[slug].tsx
+++ b/apps/studio/pages/new/[slug].tsx
@@ -4,7 +4,7 @@ import { useFeatureFlags, useFlag, useParams } from 'common'
import Head from 'next/head'
import Link from 'next/link'
import { useRouter } from 'next/router'
-import { PropsWithChildren, useEffect, useMemo, useState } from 'react'
+import { PropsWithChildren, useEffect, useMemo, useRef, useState } from 'react'
import { useForm, useFormState } from 'react-hook-form'
import { type CloudProvider } from 'shared-data'
import { toast } from 'sonner'
@@ -428,6 +428,14 @@ const Wizard: NextPageWithLayout = () => {
createProject(data)
}
+ const hasTrackedFormExposed = useRef(false)
+ useEffect(() => {
+ if (hasTrackedFormExposed.current) return
+ if (!isOrganizationsSuccess || !canCreateProject || !currentOrg) return
+ hasTrackedFormExposed.current = true
+ track('project_creation_form_exposed', { surface: 'main' })
+ }, [isOrganizationsSuccess, canCreateProject, currentOrg, track])
+
useEffect(() => {
// Only set once to ensure compute credits dont change while project is being created
if (allOrgProjects && allOrgProjects.length > 0 && !allProjects) {
diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.ts
index b72164ac2cb..fee4d647002 100644
--- a/packages/common/telemetry-constants.ts
+++ b/packages/common/telemetry-constants.ts
@@ -429,6 +429,60 @@ export interface ProjectCreationSimpleVersionConfirmModalOpenedEvent {
groups: Omit<TelemetryGroups, 'project'>
}
+/**
+ * Project creation form was rendered and shown to the user. Passive impression that
+ * anchors the project-creation funnel (exposed -> completed). Fires once per form view,
+ * after the org and create-project permission have resolved, so it tracks the form
+ * actually being visible rather than the route loading. Disambiguate by `surface`.
+ * Completion is measured by `project_creation_simple_version_submitted` (which fires
+ * client-side on the create success callback).
+ *
+ * @group Events
+ * @source studio
+ * @page new/{slug}
+ */
+export interface ProjectCreationFormExposedEvent {
+ action: 'project_creation_form_exposed'
+ properties: {
+ /**
+ * Which surface rendered the form. 'main' is the standard project creation wizard.
+ */
+ surface?: 'main' | 'vercel'
+ }
+ groups: Omit<TelemetryGroups, 'project'>
+}
+
+/**
+ * New-organization form was rendered and shown to the user. Passive impression that
+ * anchors the organization-creation funnel (exposed -> completed). Fires once per form
+ * view, after the user's profile has resolved (i.e. an authenticated session), so it
+ * does not count pre-auth redirects. No organization group: the org does not exist yet
+ * at this point in the flow.
+ *
+ * @group Events
+ * @source studio
+ * @page new
+ */
+export interface OrganizationCreationFormExposedEvent {
+ action: 'organization_creation_form_exposed'
+}
+
+/**
+ * Organization was created and the new org slug is available client-side. Fires from the
+ * create success callback (both the free path and the paid path that confirms a pending
+ * payment intent), so org-creation completion is measurable from frontend events without
+ * relying on the backend `organization_created` event (which fires across all surfaces).
+ * Closes the organization-creation funnel (exposed -> completed).
+ *
+ * @group Events
+ * @source studio
+ * @page new
+ */
+export interface OrganizationCreationCompletedEvent {
+ action: 'organization_creation_completed'
+ groups: Omit<TelemetryGroups, 'project'>
+}
+
/**
* User toggled Data API access on a table via the switch in the table editor side panel.
* Only fires for new tables — editing existing tables links out to the settings page instead.
@@ -3471,6 +3525,9 @@ export type TelemetryEvent =
| ProjectCreationGithubConnectClickedEvent
| ProjectCreationSimpleVersionSubmittedEvent
| ProjectCreationSimpleVersionConfirmModalOpenedEvent
+ | ProjectCreationFormExposedEvent
+ | OrganizationCreationFormExposedEvent
+ | OrganizationCreationCompletedEvent
| TableApiAccessToggleClickedEvent
| RealtimeInspectorListenChannelClickedEvent
| RealtimeInspectorBroadcastSentEvent