:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(metrics): stop onboarding marking metrics complete; make gated scene a waitlist (#95225)
Daniel Viscace47f03c7260
diff --git a/frontend/src/layout/scenes/components/FeaturePreviewSceneGate.test.tsx b/frontend/src/layout/scenes/components/FeaturePreviewSceneGate.test.tsxindex 79ede2e01a9b..f6ac390e11ae 100644--- a/frontend/src/layout/scenes/components/FeaturePreviewSceneGate.test.tsx+++ b/frontend/src/layout/scenes/components/FeaturePreviewSceneGate.test.tsx@@ -9,6 +9,7 @@ import { supportLogic } from 'lib/components/Support/supportLogic'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { preflightLogic } from 'lib/logic/preflightLogic'+import { ProductKey } from '~/queries/schema/schema-general'import { FeaturePreviewGateConfig } from '~/types'import { FeaturePreviewSceneGate } from './FeaturePreviewSceneGate'@@ -66,6 +67,8 @@ const mockedUseMountedLogic = useMountedLogic as jest.Mockconst mockLoadEarlyAccessFeatures = jest.fn()const mockUpdateEarlyAccessFeatureEnrollment = jest.fn()+const mockSubmitConceptSurvey = jest.fn()+const mockAddProductIntentForCrossSell = jest.fn()const mockOpenSupportForm = jest.fn()const BASE_CONFIG: FeaturePreviewGateConfig = {@@ -99,12 +102,21 @@ function isSupportLogicRef(logic: unknown): boolean {function setupMocks({earlyAccessFeatures = [],+ waitlistSurveysEnabled = false,+ conceptSurveySubmissions = {},activeSceneId = null,featureFlags = {},cloud = true,isDebug = false,}: {- earlyAccessFeatures?: Array<{ flagKey: string; enabled: boolean; stage?: string }>+ earlyAccessFeatures?: Array<{+ flagKey: string+ enabled: boolean+ stage?: string+ payload?: Record<string, unknown>+ }>+ waitlistSurveysEnabled?: boolean+ conceptSurveySubmissions?: Record<string, boolean>activeSceneId?: string | nullfeatureFlags?: Record<string, boolean | string>cloud?: boolean@@ -114,7 +126,7 @@ function setupMocks({mockedUseValues.mockImplementation((logic: unknown) => {if (isFeaturePreviewsLogicRef(logic)) {- return { earlyAccessFeatures }+ return { earlyAccessFeatures, waitlistSurveysEnabled, conceptSurveySubmissions }}if (isSceneLogicRef(logic)) {return { activeSceneId }@@ -133,6 +145,8 @@ function setupMocks({return {loadEarlyAccessFeatures: mockLoadEarlyAccessFeatures,updateEarlyAccessFeatureEnrollment: mockUpdateEarlyAccessFeatureEnrollment,+ submitConceptSurvey: mockSubmitConceptSurvey,+ addProductIntentForCrossSell: mockAddProductIntentForCrossSell,}}if (isSupportLogicRef(logic)) {@@ -320,6 +334,90 @@ describe('FeaturePreviewSceneGate', () => {)})+ describe('concept stage (waitlist)', () => {+ const CONCEPT_FEATURE = {+ flagKey: BASE_CONFIG.flag,+ enabled: false,+ stage: 'concept',+ payload: { survey_id: 'survey-1' },+ }++ test('shows an email waitlist form instead of the dead toggle for a concept feature', () => {+ setupMocks({ earlyAccessFeatures: [CONCEPT_FEATURE], waitlistSurveysEnabled: true })++ render(<FeaturePreviewSceneGate config={BASE_CONFIG}>{CHILDREN}</FeaturePreviewSceneGate>)++ expect(screen.getByPlaceholderText('[email protected]')).toBeInTheDocument()+ expect(screen.getByText('Get notified')).toBeInTheDocument()+ expect(screen.queryByRole('switch')).not.toBeInTheDocument()+ })++ test('shows the confirmation once the user is on the waitlist', () => {+ setupMocks({+ earlyAccessFeatures: [CONCEPT_FEATURE],+ waitlistSurveysEnabled: true,+ conceptSurveySubmissions: { [BASE_CONFIG.flag]: true },+ })++ render(<FeaturePreviewSceneGate config={BASE_CONFIG}>{CHILDREN}</FeaturePreviewSceneGate>)++ expect(screen.getByText(/Thanks — we'll email you when it's ready/)).toBeInTheDocument()+ expect(screen.queryByRole('switch')).not.toBeInTheDocument()+ })++ test('submits the waitlist survey and registers product intent', async () => {+ setupMocks({ earlyAccessFeatures: [CONCEPT_FEATURE], waitlistSurveysEnabled: true })++ render(+ <FeaturePreviewSceneGate config={{ ...BASE_CONFIG, productIntent: 'metrics' as ProductKey }}>+ {CHILDREN}+ </FeaturePreviewSceneGate>+ )+ await userEvent.type(screen.getByPlaceholderText('[email protected]'), '[email protected]')+ await userEvent.click(screen.getByText('Get notified'))++ expect(mockSubmitConceptSurvey).toHaveBeenCalledWith(BASE_CONFIG.flag, '[email protected]')+ expect(mockAddProductIntentForCrossSell).toHaveBeenCalledWith(+ expect.objectContaining({+ to: 'metrics',+ intent_context: 'feature_preview_enabled',+ })+ )+ })++ test('does not register product intent for an impersonated session', async () => {+ setupMocks({ earlyAccessFeatures: [CONCEPT_FEATURE], waitlistSurveysEnabled: true })+ window.IMPERSONATED_SESSION = true++ try {+ render(+ <FeaturePreviewSceneGate config={{ ...BASE_CONFIG, productIntent: 'metrics' as ProductKey }}>+ {CHILDREN}+ </FeaturePreviewSceneGate>+ )+ await userEvent.type(screen.getByPlaceholderText('[email protected]'), '[email protected]')+ await userEvent.click(screen.getByText('Get notified'))++ // The survey submit is attempted (the logic shows the rejection toast), but the+ // adoption signal must not fire for a signup the backend will refuse.+ expect(mockAddProductIntentForCrossSell).not.toHaveBeenCalled()+ } finally {+ delete window.IMPERSONATED_SESSION+ }+ })++ test('falls back to the toggle for a concept feature without a waitlist survey', () => {+ setupMocks({+ earlyAccessFeatures: [{ flagKey: BASE_CONFIG.flag, enabled: false, stage: 'concept' }],+ waitlistSurveysEnabled: false,+ })++ render(<FeaturePreviewSceneGate config={BASE_CONFIG}>{CHILDREN}</FeaturePreviewSceneGate>)++ expect(screen.getByRole('switch')).toBeInTheDocument()+ })+ })+describe('request access', () => {const CONFIG_WITH_SUPPORT: FeaturePreviewGateConfig = {...BASE_CONFIG,diff --git a/frontend/src/layout/scenes/components/FeaturePreviewSceneGate.tsx b/frontend/src/layout/scenes/components/FeaturePreviewSceneGate.tsxindex 07b5e8013a36..44e3968cbdfb 100644--- a/frontend/src/layout/scenes/components/FeaturePreviewSceneGate.tsx+++ b/frontend/src/layout/scenes/components/FeaturePreviewSceneGate.tsx@@ -1,9 +1,10 @@import { useActions, useValues } from 'kea'-import { useEffect } from 'react'+import { useEffect, useState } from 'react'-import { LemonButton, LemonSwitch } from '@posthog/lemon-ui'+import { IconCheck } from '@posthog/icons'+import { LemonButton, LemonInput, LemonSwitch } from '@posthog/lemon-ui'-import { featurePreviewsLogic } from 'lib/components/FeaturePreviews/featurePreviewsLogic'+import { EnrichedEarlyAccessFeature, featurePreviewsLogic } from 'lib/components/FeaturePreviews/featurePreviewsLogic'import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'import { supportLogic } from 'lib/components/Support/supportLogic'import {@@ -16,6 +17,7 @@ import { sceneLogic } from 'scenes/sceneLogic'import { sceneConfigurations } from 'scenes/scenes'import { urls } from 'scenes/urls'+import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'import { FeaturePreviewGateConfig } from '~/types'import { SceneContent } from './SceneContent'@@ -52,6 +54,31 @@ function FeaturePreviewGateContent({ config }: { config: FeaturePreviewGateConficonst sceneConfig = sceneIdForHeader ? sceneConfigurations[sceneIdForHeader] : undefinedconst flagsHonored = areClientFeatureFlagsHonored(preflight)+ // Concept ("Coming Soon") features never enable their flag, so the enrollment toggle is a+ // dead end there. When the feature carries a waitlist survey, collect an email instead.+ if (feature?.stage === 'concept' && feature.payload?.survey_id) {+ return (+ <SceneContent>+ {sceneConfig?.name && (+ <SceneTitleSection+ name={sceneConfig.name}+ description={sceneConfig.description}+ resourceType={{ type: sceneConfig.iconType || 'default' }}+ />+ )}+ <ProductIntroduction+ productName={config.title}+ thingName="feature"+ titleOverride={config.title}+ description={config.description}+ isEmpty+ actionElementOverride={<ConceptWaitlistForm feature={feature} config={config} />}+ docsURL={config.docsURL}+ />+ </SceneContent>+ )+ }+return (<SceneContent>{sceneConfig?.name && (@@ -117,3 +144,81 @@ function FeaturePreviewGateContent({ config }: { config: FeaturePreviewGateConfi</SceneContent>)}++function ConceptWaitlistForm({+ feature,+ config,+}: {+ feature: EnrichedEarlyAccessFeature+ config: FeaturePreviewGateConfig+}): JSX.Element {+ const { waitlistSurveysEnabled, conceptSurveySubmissions } = useValues(featurePreviewsLogic)+ const { submitConceptSurvey, updateEarlyAccessFeatureEnrollment, addProductIntentForCrossSell } =+ useActions(featurePreviewsLogic)+ const [email, setEmail] = useState('')++ const surveySubmitted = !!conceptSurveySubmissions[feature.flagKey] || feature.enabled++ // Mirrors the previews page's ConceptPreview: email collection only when the waitlist+ // surveys gate is on, otherwise the plain one-click registration.+ const hasWaitlistSurvey = waitlistSurveysEnabled++ const recordIntent = (): void => {+ // submitConceptSurvey refuses impersonated sessions; skip the intent too so a+ // rejected signup never records a false adoption signal.+ if (config.productIntent && !window.IMPERSONATED_SESSION) {+ void addProductIntentForCrossSell({+ from: ProductKey.EARLY_ACCESS_FEATURES,+ to: config.productIntent,+ intent_context: ProductIntentContext.FEATURE_PREVIEW_ENABLED,+ })+ }+ }++ if (surveySubmitted) {+ return (+ <span role="status" className="flex items-center gap-1 text-success font-medium">+ <IconCheck /> Thanks — we'll email you when it's ready.+ </span>+ )+ }++ if (hasWaitlistSurvey) {+ return (+ <form+ className="flex items-center gap-2"+ onSubmit={(e) => {+ e.preventDefault()+ if (email) {+ submitConceptSurvey(feature.flagKey, email)+ recordIntent()+ }+ }}+ >+ <LemonInput+ type="email"+ value={email}+ onChange={setEmail}+ placeholder="[email protected]"+ aria-label="Email address"+ autoComplete="email"+ />+ <LemonButton type="primary" htmlType="submit" disabledReason={!email ? 'Enter your email' : undefined}>+ Get notified+ </LemonButton>+ </form>+ )+ }++ return (+ <LemonButton+ type="primary"+ onClick={() => {+ updateEarlyAccessFeatureEnrollment(feature.flagKey, true, feature.stage)+ recordIntent()+ }}+ >+ Get notified+ </LemonButton>+ )+}diff --git a/frontend/src/scenes/onboarding/self-driving/onboardingLogic.test.ts b/frontend/src/scenes/onboarding/self-driving/onboardingLogic.test.tsindex b9cb94954313..efc98e3e6b68 100644--- a/frontend/src/scenes/onboarding/self-driving/onboardingLogic.test.ts+++ b/frontend/src/scenes/onboarding/self-driving/onboardingLogic.test.ts@@ -141,9 +141,10 @@ describe('onboardingLogic', () => {await logic.asyncActions.completeOnboarding('find_problems')expect(addIntentRequests).toBe(0)- expect(intents).toHaveLength(6)- expect(new Set(intents.map(({ product_type }) => product_type)).size).toBe(6)+ expect(intents).toHaveLength(5)+ expect(new Set(intents.map(({ product_type }) => product_type)).size).toBe(5)expect(intents).not.toContainEqual(expect.objectContaining({ product_type: ProductKey.SURVEYS }))+ expect(intents).not.toContainEqual(expect.objectContaining({ product_type: ProductKey.METRICS }))expect(intents).toEqual(expect.arrayContaining([{diff --git a/frontend/src/scenes/onboarding/shared/useCases.test.ts b/frontend/src/scenes/onboarding/shared/useCases.test.tsindex a2f1604068d5..f50425937d3e 100644--- a/frontend/src/scenes/onboarding/shared/useCases.test.ts+++ b/frontend/src/scenes/onboarding/shared/useCases.test.ts@@ -22,4 +22,15 @@ describe('onboarding use cases', () => {expect(DOCS_URL_BY_PRODUCT_PATH[tool.productPath]).toEqual(expect.any(String))}})++ it('keeps preview-gated products out of onboarding completion', () => {+ // Marking a product "onboarding completed" as a side effect of an unrelated use case+ // must not happen for a product the user cannot open afterwards. Metrics is behind an+ // early access feature with no self-serve enrollment (the gate renders as a dead toggle),+ // so completing onboarding for it tells the user onboarding is complete for a product+ // they cannot open, and `has_completed_onboarding_for` records a false adoption signal.+ const intentOnlyProducts = ONBOARDING_USE_CASES.flatMap((useCase) => useCase.additionalTools ?? [])++ expect(intentOnlyProducts).not.toContain('metrics')+ })})diff --git a/frontend/src/scenes/onboarding/shared/useCases.tsx b/frontend/src/scenes/onboarding/shared/useCases.tsxindex 232ffada1015..1775121057b1 100644--- a/frontend/src/scenes/onboarding/shared/useCases.tsx+++ b/frontend/src/scenes/onboarding/shared/useCases.tsx@@ -83,7 +83,6 @@ export const SUPPORTED_TOOL_PRODUCTS = [ProductKey.EXPERIMENTS,ProductKey.SURVEYS,ProductKey.LOGS,- ProductKey.METRICS,ProductKey.DATA_WAREHOUSE,ProductKey.WORKFLOWS,ProductKey.MCP_ANALYTICS,@@ -219,7 +218,7 @@ export const ONBOARDING_USE_CASES: OnboardingUseCase[] = [done: 'first product problem finding or proposed fix',primaryProduct: ProductKey.ERROR_TRACKING,tools: ['error_tracking', 'session_replay'],- additionalTools: [ProductKey.LOGS, ProductKey.METRICS, ProductKey.CONVERSATIONS],+ additionalTools: [ProductKey.LOGS, ProductKey.CONVERSATIONS],sidebarExtras: SHARED_SIDEBAR,},{@@ -266,7 +265,6 @@ const DEFAULT_SETUP: OnboardingSetup = {ProductKey.EXPERIMENTS,ProductKey.SURVEYS,ProductKey.LOGS,- ProductKey.METRICS,ProductKey.DATA_WAREHOUSE,ProductKey.WORKFLOWS,ProductKey.MCP_ANALYTICS,diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 7f9d8e006fa8..91d26de5051d 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -7853,6 +7853,11 @@ export interface FeaturePreviewGateConfig {* feature previews page.*/offerRequestAccess?: boolean+ /**+ * Product intent recorded when a user joins the waitlist from the gate, so waitlist sign-ups+ * count as product intent the same way opting in from the feature previews page does.+ */+ productIntent?: ProductKey}export interface ProductManifest {diff --git a/products/metrics/frontend/featurePreviewGate.ts b/products/metrics/frontend/featurePreviewGate.tsindex f3380e6ba7e1..d76a5647da0b 100644--- a/products/metrics/frontend/featurePreviewGate.ts+++ b/products/metrics/frontend/featurePreviewGate.ts@@ -1,5 +1,6 @@import { FEATURE_FLAGS } from 'lib/constants'+import { ProductKey } from '~/queries/schema/schema-general'import { FeaturePreviewGateConfig } from '~/types'export const metricsFeaturePreviewGate: FeaturePreviewGateConfig = {@@ -9,4 +10,5 @@ export const metricsFeaturePreviewGate: FeaturePreviewGateConfig = {'Metrics is in open alpha: things may change while we polish it. Send metrics with any OpenTelemetry client, then turn on the feature preview to open the viewer.',docsURL: 'https://posthog.com/docs/metrics',sceneId: 'Metrics',+ productIntent: ProductKey.METRICS,}