: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(onboarding): carry entry_point onto every funnel event (#94768)
posthog[bot]e91e87275101
diff --git a/frontend/src/lib/utils/eventUsageLogic.test.ts b/frontend/src/lib/utils/eventUsageLogic.test.tsindex 6c8fc6170f07..164d81036f73 100644--- a/frontend/src/lib/utils/eventUsageLogic.test.ts+++ b/frontend/src/lib/utils/eventUsageLogic.test.ts@@ -1,3 +1,7 @@+import posthog from 'posthog-js'++import { SELF_DRIVING_ONBOARDING_EVENT_PROPS } from 'scenes/onboarding/onboardingEventUsageLogic'+import { NodeKind } from '~/queries/schema/schema-general'import type {ExperimentFunnelMetric,@@ -8,11 +12,53 @@ import type {ExperimentTrendsQuery,Node,} from '~/queries/schema/schema-general'+import { initKeaTests } from '~/test/init'import { BaseMathType, BehavioralEventType, FilterLogicalOperator, PropertyFilterType } from '~/types'-import { getEventPropertiesForMetric, sanitizeQuery } from './eventUsageLogic'+import {+ type OnboardingEventProperties,+ eventUsageLogic,+ getEventPropertiesForMetric,+ sanitizeQuery,+} from './eventUsageLogic'describe('eventUsageLogic', () => {+ describe('onboarding funnel events', () => {+ let capture: jest.SpyInstance++ beforeEach(() => {+ initKeaTests()+ eventUsageLogic.mount()+ capture = jest.spyOn(posthog, 'capture').mockImplementation()+ })++ afterEach(() => {+ capture.mockRestore()+ })++ const cases: [string, OnboardingEventProperties | undefined, string][] = [+ ['legacy', undefined, 'product_selection'],+ ['self-driving', SELF_DRIVING_ONBOARDING_EVENT_PROPS, 'welcome'],+ ]++ it.each(cases)('stamps the %s entry point on every funnel event', (_, properties, entryPoint) => {+ eventUsageLogic.actions.reportOnboardingStarted(properties)+ eventUsageLogic.actions.reportOnboardingStepCompleted('install', undefined, properties)+ eventUsageLogic.actions.reportOnboardingStepSkipped('install', undefined, properties)+ eventUsageLogic.actions.reportOnboardingCompleted('product_analytics', properties)++ for (const event of [+ 'onboarding started',+ 'onboarding step completed',+ 'onboarding step skipped',+ 'onboarding completed',+ ]) {+ const call = capture.mock.calls.find(([name]) => name === event)+ expect(call?.[1]).toMatchObject({ entry_point: entryPoint })+ }+ })+ })+describe('ExperimentMetric (new format)', () => {it('extracts funnel metric properties', () => {const metric: ExperimentFunnelMetric = {diff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.tsindex 986bbdbd3671..875bffe186f8 100644--- a/frontend/src/lib/utils/eventUsageLogic.ts+++ b/frontend/src/lib/utils/eventUsageLogic.ts@@ -304,12 +304,21 @@ export interface ExperimentRecordingsBucketFailedContext {// by `version` (1 = legacy, 2 = context-first redesign) and `flow_variant`. Stamping properties// instead of renaming keeps every existing dashboard and alert on the v1 events working. The// redesign's v2 events live in `scenes/onboarding/onboardingEventUsageLogic`.+// `entry_point` names the surface the flow starts on. It rides along with every funnel event, not+// only `started`, so a breakdown by entry point stays populated for the whole funnel.+export type OnboardingEntryPoint = 'product_selection' | 'welcome'+export type OnboardingEventProperties = {+ entry_point: OnboardingEntryPointflow_variant: 'context_first' | 'legacy'version: 1 | 2}-const LEGACY_ONBOARDING_EVENT_PROPS: OnboardingEventProperties = { version: 1, flow_variant: 'legacy' }+const LEGACY_ONBOARDING_EVENT_PROPS: OnboardingEventProperties = {+ version: 1,+ flow_variant: 'legacy',+ entry_point: 'product_selection',+}function retentionWindowDays(metric: ExperimentRetentionMetric): number | undefined {const unitToDays: Record<string, number> = { day: 1, week: 7, month: 30 }@@ -1900,11 +1909,7 @@ export interface eventUsageLogicActions {recommendationSource: stringselected: boolean}- reportOnboardingStarted: (- entrypoint: string,- properties?: OnboardingEventProperties- ) => {- entrypoint: string+ reportOnboardingStarted: (properties?: OnboardingEventProperties) => {properties: OnboardingEventProperties | undefined}reportOnboardingStepCompleted: (@@ -3080,8 +3085,7 @@ export const eventUsageLogic = kea<eventUsageLogicType>([reportProductTourListViewed: true,reportProductUnsubscribed: (product: string) => ({ product }),reportSubscribedDuringOnboarding: (productKey: string) => ({ productKey }),- reportOnboardingStarted: (entrypoint: string, properties?: OnboardingEventProperties) => ({- entrypoint,+ reportOnboardingStarted: (properties?: OnboardingEventProperties) => ({properties,}),reportOnboardingStepCompleted: (@@ -4610,9 +4614,8 @@ export const eventUsageLogic = kea<eventUsageLogicType>([product_key: productKey,})},- reportOnboardingStarted: ({ entrypoint, properties }) => {+ reportOnboardingStarted: ({ properties }) => {posthog.capture('onboarding started', {- entry_point: entrypoint,...LEGACY_ONBOARDING_EVENT_PROPS,...properties,})diff --git a/frontend/src/scenes/onboarding/legacy/productSelection/productSelectionLogic.ts b/frontend/src/scenes/onboarding/legacy/productSelection/productSelectionLogic.tsindex 2ca00674fde7..a78dfff43ee4 100644--- a/frontend/src/scenes/onboarding/legacy/productSelection/productSelectionLogic.ts+++ b/frontend/src/scenes/onboarding/legacy/productSelection/productSelectionLogic.ts@@ -80,10 +80,8 @@ export interface productSelectionLogicActions {selected: boolean} // eventUsageLogicreportOnboardingStarted: (- entrypoint: string,properties?: import('lib/utils/eventUsageLogic').OnboardingEventProperties | undefined) => {- entrypoint: stringproperties: import('lib/utils/eventUsageLogic').OnboardingEventProperties | undefined} // eventUsageLogicsetOnCompleteOnboardingRedirectUrl: (url: string | null) => {@@ -455,6 +453,6 @@ export const productSelectionLogic = kea<productSelectionLogicType>([}}- actions.reportOnboardingStarted('product_selection')+ actions.reportOnboardingStarted()}),])diff --git a/frontend/src/scenes/onboarding/onboardingEventUsageLogic.ts b/frontend/src/scenes/onboarding/onboardingEventUsageLogic.tsindex d806cb8f8189..24b64740774d 100644--- a/frontend/src/scenes/onboarding/onboardingEventUsageLogic.ts+++ b/frontend/src/scenes/onboarding/onboardingEventUsageLogic.ts@@ -19,6 +19,7 @@ export type SelfDrivingOnboardingStepId =export const SELF_DRIVING_ONBOARDING_EVENT_PROPS: OnboardingEventProperties = {version: 2,flow_variant: 'context_first',+ entry_point: 'welcome',}export type CloudRunExperimentArm = 'control' | 'test'diff --git a/frontend/src/scenes/onboarding/self-driving/SelfDrivingOnboardingFlow.tsx b/frontend/src/scenes/onboarding/self-driving/SelfDrivingOnboardingFlow.tsxindex 55e0b79b9d90..257ac71dae10 100644--- a/frontend/src/scenes/onboarding/self-driving/SelfDrivingOnboardingFlow.tsx+++ b/frontend/src/scenes/onboarding/self-driving/SelfDrivingOnboardingFlow.tsx@@ -142,7 +142,7 @@ export function SelfDrivingOnboardingFlow(): JSX.Element {// including the one this mounts on.useOnMountEffect(() => {if (stepIndex === 0) {- reportOnboardingStarted('welcome', SELF_DRIVING_ONBOARDING_EVENT_PROPS)+ reportOnboardingStarted(SELF_DRIVING_ONBOARDING_EVENT_PROPS)}})useEffect(() => {diff --git a/frontend/src/scenes/onboarding/self-driving/onboardingLogic.test.ts b/frontend/src/scenes/onboarding/self-driving/onboardingLogic.test.tsindex efc98e3e6b68..d1af1b163a5a 100644--- a/frontend/src/scenes/onboarding/self-driving/onboardingLogic.test.ts+++ b/frontend/src/scenes/onboarding/self-driving/onboardingLogic.test.ts@@ -178,6 +178,7 @@ describe('onboardingLogic', () => {product_key: ProductKey.ERROR_TRACKING,version: 2,flow_variant: 'context_first',+ entry_point: 'welcome',},],])