: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
feat(workflows): track which wizard steps people see and where they came from (#120066)
Meikel Ratzc6c4a0d09ede
diff --git a/products/workflows/frontend/Broadcasts/BroadcastsEmptyState.tsx b/products/workflows/frontend/Broadcasts/BroadcastsEmptyState.tsxindex 652ed48023fc..e2ad5442a586 100644--- a/products/workflows/frontend/Broadcasts/BroadcastsEmptyState.tsx+++ b/products/workflows/frontend/Broadcasts/BroadcastsEmptyState.tsx@@ -50,7 +50,7 @@ export function BroadcastsEmptyState(): JSX.Element {{!senderReady && (<LemonButtontype="primary"- to={onboardingWizardUrl('broadcast')}+ to={onboardingWizardUrl('broadcast', { entry: 'broadcasts_empty_state' })}disabledReason={editorDisabledReason}onClick={() => capture('set-up-email')}data-attr="broadcasts-empty-state-set-up-email"diff --git a/products/workflows/frontend/setupGuide/AutomationEmptyState.tsx b/products/workflows/frontend/setupGuide/AutomationEmptyState.tsxindex 3098d79c6e86..58a1e1fbcfac 100644--- a/products/workflows/frontend/setupGuide/AutomationEmptyState.tsx+++ b/products/workflows/frontend/setupGuide/AutomationEmptyState.tsx@@ -30,7 +30,7 @@ export function AutomationEmptyState(): JSX.Element {<div className="flex flex-wrap justify-center gap-2"><LemonButtontype="primary"- to={onboardingWizardUrl('automation')}+ to={onboardingWizardUrl('automation', { entry: 'automation_empty_state' })}onClick={() => capture('guided-setup')}data-attr="workflows-automation-empty-state-guided-setup">diff --git a/products/workflows/frontend/setupGuide/AutomationSuggestionBanner.tsx b/products/workflows/frontend/setupGuide/AutomationSuggestionBanner.tsxindex 70767db1cd6a..2b6dbf7d926a 100644--- a/products/workflows/frontend/setupGuide/AutomationSuggestionBanner.tsx+++ b/products/workflows/frontend/setupGuide/AutomationSuggestionBanner.tsx@@ -21,7 +21,7 @@ export function AutomationSuggestionBanner(): JSX.Element | null {onClose={dismissAutomationSuggestion}action={{children: 'Set up an automation',- to: onboardingWizardUrl('automation'),+ to: onboardingWizardUrl('automation', { entry: 'automation_banner' }),'data-attr': 'workflows-automation-suggestion',}}>diff --git a/products/workflows/frontend/setupGuide/MessagingSetupGuide.tsx b/products/workflows/frontend/setupGuide/MessagingSetupGuide.tsxindex 34067562f50d..95c1c25f2074 100644--- a/products/workflows/frontend/setupGuide/MessagingSetupGuide.tsx+++ b/products/workflows/frontend/setupGuide/MessagingSetupGuide.tsx@@ -27,7 +27,7 @@ export function MessagingSetupGuide({ linkFor }: { linkFor: (tab: MessagingNavTa<LemonButtonsize="small"type="primary"- to={onboardingWizardUrl('messaging')}+ to={onboardingWizardUrl('messaging', { entry: 'messaging_setup_guide' })}data-attr="messaging-setup-guide-open-wizard">Guided setupdiff --git a/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.ts b/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.tsindex a500de65b7aa..3cba14e91c9c 100644--- a/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.ts+++ b/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.ts@@ -30,9 +30,19 @@ export const BLANK_START_ID = 'blank'/** The `template_id` the finished event reports when a data suggestion created the workflow. */export const DATA_SUGGESTION_START_ID = 'data_suggestion'+// pinned: URL value and analytics property value of the wizard events - renaming breaks dashboards+export const WIZARD_ENTRIES = [+ 'path_choice',+ 'messaging_setup_guide',+ 'automation_empty_state',+ 'automation_banner',+ 'broadcasts_empty_state',+] as const+export type WizardEntry = (typeof WIZARD_ENTRIES)[number]+export function onboardingWizardUrl(path: WorkflowsOnboardingPath,- params: { step?: WizardStepKey; template?: string } = {}+ params: { step?: WizardStepKey; template?: string; entry?: WizardEntry } = {}): string {return combineUrl(urls.workflows(ONBOARDING_WIZARD_TAB), { path, ...params }).url}diff --git a/products/workflows/frontend/setupGuide/wizard/workflowsOnboardingWizardLogic.ts b/products/workflows/frontend/setupGuide/wizard/workflowsOnboardingWizardLogic.tsindex 6e5aa03af262..6b20dbca53df 100644--- a/products/workflows/frontend/setupGuide/wizard/workflowsOnboardingWizardLogic.ts+++ b/products/workflows/frontend/setupGuide/wizard/workflowsOnboardingWizardLogic.ts@@ -25,8 +25,10 @@ import {FrequencyCapChoice,RECOMMENDED_FREQUENCY_CAP,ONBOARDING_WIZARD_TAB,+ WIZARD_ENTRIES,WIZARD_STEP_COPY,WizardConnection,+ WizardEntry,WizardStepKey,chosenFrequencyCap,customFrequencyCapError,@@ -37,6 +39,10 @@ import {wizardSteps,} from './onboardingWizardSteps'+function isWizardEntry(value: unknown): value is WizardEntry {+ return WIZARD_ENTRIES.includes(value as WizardEntry)+}+function isOnboardingPath(value: unknown): value is WorkflowsOnboardingPath {return value === 'messaging' || value === 'automation' || value === 'broadcast'}@@ -57,6 +63,7 @@ export interface workflowsOnboardingWizardLogicValues {currentStep: WizardStepKeycustomFrequencyCap: FrequencyCap | nullengagementEventsChoice: boolean | null+ entry: WizardEntry | nullfrequencyCapChoice: FrequencyCapChoice | nullfrequencyCapError: string | nullhasPositioned: boolean@@ -126,8 +133,16 @@ export interface workflowsOnboardingWizardLogicActions {path: WorkflowsOnboardingPath,step: WizardStepKey | null,stepIndex: number,- templateId: string | null+ templateId: string | null,+ entry: WizardEntry | null) => {+ entry:+ | 'automation_banner'+ | 'automation_empty_state'+ | 'broadcasts_empty_state'+ | 'messaging_setup_guide'+ | 'path_choice'+ | nullpath: WorkflowsOnboardingPathstep: WizardStepKey | nullstepIndex: number@@ -266,12 +281,14 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogicpath: WorkflowsOnboardingPath,step: WizardStepKey | null,stepIndex: number,- templateId: string | null+ templateId: string | null,+ entry: WizardEntry | null) => ({path,step,stepIndex,templateId,+ entry,}),setStepIndex: (index: number) => ({ index }),next: true,@@ -295,6 +312,12 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogicinitWizard: (_, { path }) => path,},],+ entry: [+ null as WizardEntry | null,+ {+ initWizard: (_, { entry }) => entry,+ },+ ],stepIndex: [0,{@@ -571,109 +594,132 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogic},],}),- listeners(({ actions, values }) => ({- next: () => {- const step = values.currentStep+ listeners(({ actions, values }) => {+ // Sent once the wizard settles on a step, so a person who opens it fresh does not count a view of+ // the first step before it moves to their first open one.+ const captureStepViewed = (): void => {// pinned: analytics event name - renaming breaks dashboards- posthog.capture('workflows onboarding wizard step completed', {+ posthog.capture('workflows onboarding wizard step viewed', {path: values.wizardPath,- step,- skipped: WIZARD_STEP_COPY[step].optional && !values.stepDone?.[step],- ...(step === 'sending-rules'- ? { frequency_cap: values.shownFrequencyCapChoice, engagement_events: values.shownEngagementEvents }- : {}),+ step: values.currentStep,+ step_index: values.stepIndex,+ entry: values.entry,})- const rulesToSave =- step === 'sending-rules'- ? sendingRulesToSave(- {- ...values.savedFrequencyCap,- engagementEvents:- !!values.currentTeam?.workflows_config?.capture_workflows_engagement_events,- },- values.chosenFrequencyCap,- values.shownEngagementEvents,- values.canEditSendingRules- )- : null- if (rulesToSave) {- actions.updateCurrentTeam({ workflows_config: rulesToSave })- }- if (values.isLastStep) {- actions.finish()- } else {- actions.setStepIndex(values.stepIndex + 1)- }- },- back: () => {- actions.setStepIndex(Math.max(0, values.stepIndex - 1))- },- initWizard: () => {- actions.positionIfReady()- },- positionIfReady: () => {- const { stepDone, initialized, hasPositioned, wizardPath, stepKeys } = values- if (stepDone && initialized && !hasPositioned && wizardPath !== 'automation') {- actions.positionAtFirstOpenStep(firstOpenStepIndex(stepKeys, stepDone))- }- },- finish: () => {- if (values.wizardPath === 'broadcast') {+ }+ return {+ setStepIndex: captureStepViewed,+ positionAtFirstOpenStep: captureStepViewed,+ next: () => {+ const step = values.currentStep// pinned: analytics event name - renaming breaks dashboards- posthog.capture('workflows onboarding wizard finished', { path: values.wizardPath })- actions.startNewBroadcast()- return- }- if (values.startsBlank) {+ posthog.capture('workflows onboarding wizard step completed', {+ path: values.wizardPath,+ step,+ skipped: WIZARD_STEP_COPY[step].optional && !values.stepDone?.[step],+ ...(step === 'sending-rules'+ ? {+ frequency_cap: values.shownFrequencyCapChoice,+ engagement_events: values.shownEngagementEvents,+ }+ : {}),+ })+ const rulesToSave =+ step === 'sending-rules'+ ? sendingRulesToSave(+ {+ ...values.savedFrequencyCap,+ engagementEvents:+ !!values.currentTeam?.workflows_config?.capture_workflows_engagement_events,+ },+ values.chosenFrequencyCap,+ values.shownEngagementEvents,+ values.canEditSendingRules+ )+ : null+ if (rulesToSave) {+ actions.updateCurrentTeam({ workflows_config: rulesToSave })+ }+ if (values.isLastStep) {+ actions.finish()+ } else {+ actions.setStepIndex(values.stepIndex + 1)+ }+ },+ back: () => {+ actions.setStepIndex(Math.max(0, values.stepIndex - 1))+ },+ initWizard: ({ path, step }) => {+ // The automation path and a link to a named step never move, so their first step is already settled.+ // Reads the payload, because positioning can run before this listener and set `hasPositioned`.+ if (step !== null || path === 'automation') {+ captureStepViewed()+ }+ actions.positionIfReady()+ },+ positionIfReady: () => {+ const { stepDone, initialized, hasPositioned, wizardPath, stepKeys } = values+ if (stepDone && initialized && !hasPositioned && wizardPath !== 'automation') {+ actions.positionAtFirstOpenStep(firstOpenStepIndex(stepKeys, stepDone))+ }+ },+ finish: () => {+ if (values.wizardPath === 'broadcast') {+ // pinned: analytics event name - renaming breaks dashboards+ posthog.capture('workflows onboarding wizard finished', { path: values.wizardPath })+ actions.startNewBroadcast()+ return+ }+ if (values.startsBlank) {+ // pinned: analytics event name - renaming breaks dashboards+ posthog.capture('workflows onboarding wizard finished', {+ path: values.wizardPath,+ template_id: BLANK_START_ID,+ })+ actions.createEmptyWorkflow()+ return+ }+ const template = values.selectedTemplate+ if (!template) {+ return+ }// pinned: analytics event name - renaming breaks dashboardsposthog.capture('workflows onboarding wizard finished', {path: values.wizardPath,- template_id: BLANK_START_ID,+ template_id: template.id,+ template_scope: template.scope,})- actions.createEmptyWorkflow()- return- }- const template = values.selectedTemplate- if (!template) {- return- }- // pinned: analytics event name - renaming breaks dashboards- posthog.capture('workflows onboarding wizard finished', {- path: values.wizardPath,- template_id: template.id,- template_scope: template.scope,- })- actions.createWorkflowFromTemplate(template)- },- // A suggestion card creates and opens the workflow itself, so it skips `next` and `finish`.- finishWithSuggestion: () => {- // pinned: analytics event name - renaming breaks dashboards- posthog.capture('workflows onboarding wizard step completed', {- path: values.wizardPath,- step: values.currentStep,- skipped: false,- })- // pinned: analytics event name - renaming breaks dashboards- posthog.capture('workflows onboarding wizard finished', {- path: values.wizardPath,- template_id: DATA_SUGGESTION_START_ID,- })- },- exit: () => {- // pinned: analytics event name - renaming breaks dashboards- posthog.capture('workflows onboarding wizard exited', {- path: values.wizardPath,- step: values.currentStep,- })- router.actions.push(- values.wizardPath === 'messaging'- ? urls.workflows('channels')- : values.wizardPath === 'broadcast'- ? urls.broadcasts()- : urls.workflows()- )- },- })),+ actions.createWorkflowFromTemplate(template)+ },+ // A suggestion card creates and opens the workflow itself, so it skips `next` and `finish`.+ finishWithSuggestion: () => {+ // pinned: analytics event name - renaming breaks dashboards+ posthog.capture('workflows onboarding wizard step completed', {+ path: values.wizardPath,+ step: values.currentStep,+ skipped: false,+ })+ // pinned: analytics event name - renaming breaks dashboards+ posthog.capture('workflows onboarding wizard finished', {+ path: values.wizardPath,+ template_id: DATA_SUGGESTION_START_ID,+ })+ },+ exit: () => {+ // pinned: analytics event name - renaming breaks dashboards+ posthog.capture('workflows onboarding wizard exited', {+ path: values.wizardPath,+ step: values.currentStep,+ })+ router.actions.push(+ values.wizardPath === 'messaging'+ ? urls.workflows('channels')+ : values.wizardPath === 'broadcast'+ ? urls.broadcasts()+ : urls.workflows()+ )+ },+ }+ }),subscriptions(({ actions }) => ({stepDone: () => {actions.positionIfReady()@@ -688,8 +734,14 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogicconst steps = wizardSteps(path, values.pushEnabled)const step = steps.includes(searchParams.step) ? (searchParams.step as WizardStepKey) : nullconst templateId = searchParams.template ? String(searchParams.template) : null- if (path !== values.wizardPath || step !== values.currentStep || templateId !== values.selectedTemplateId) {- actions.initWizard(path, step, step ? steps.indexOf(step) : 0, templateId)+ const entry = isWizardEntry(searchParams.entry) ? searchParams.entry : null+ if (+ !values.initialized ||+ path !== values.wizardPath ||+ step !== values.currentStep ||+ templateId !== values.selectedTemplateId+ ) {+ actions.initWizard(path, step, step ? steps.indexOf(step) : 0, templateId, entry)}},})),diff --git a/products/workflows/frontend/setupGuide/workflowsSetupGuideLogic.ts b/products/workflows/frontend/setupGuide/workflowsSetupGuideLogic.tsindex 31677d32bb37..ce490206e701 100644--- a/products/workflows/frontend/setupGuide/workflowsSetupGuideLogic.ts+++ b/products/workflows/frontend/setupGuide/workflowsSetupGuideLogic.ts@@ -267,13 +267,13 @@ export const workflowsSetupGuideLogic = kea<workflowsSetupGuideLogicType>([if (canSendBroadcast) {actions.startNewBroadcast()} else {- router.actions.push(onboardingWizardUrl(path))+ router.actions.push(onboardingWizardUrl(path, { entry: 'path_choice' }))}} else if (path === 'messaging' && values.isComplete) {// A finished messaging setup has nothing left to guide, so it goes straight to the journeys.actions.browseTemplates('messaging')} else {- router.actions.push(onboardingWizardUrl(path))+ router.actions.push(onboardingWizardUrl(path, { entry: 'path_choice' }))}},hideGuide: () => {