: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(onboarding): instrument the cloud wizard AB test (#68758)
Fernando Gomes670641446b2e
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 8ef1cadba311..08c5e6c7cb92 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7285,9 +7285,9 @@ snapshots:scenes-other-login--sso-error--light:hash: v1.k794b7964.dcb9dbd028e9325ec079706aaf108c905d2d6116d8fcbef7482d48f370cda6a1.IpTMqWIuRh6xGrQ4TzU6wCvTIYdToc9T6wkqkOenjSYscenes-other-onboarding--ai-observability-sdk-install--dark:- hash: v1.k794b7964.67dc493d2f16bae3551bd006efdc905d5aeadd311bc2b8e704d71c8cbba8af28.NFNRzaeuWWfGgN97lPPG6aM7UtUb0nCwVm9IhASNDNM+ hash: v1.k794b7964.bda729452fe657398c480b5294c7e56e7d3635b19abb4002709522f13f369305.rrDpmUmU4m7CapzCP3sWTjEmrgTZOSFyBM-I7n29TUgscenes-other-onboarding--ai-observability-sdk-install--light:- hash: v1.k794b7964.810a6aba411094283414c4e8214829083fbc2fb8b5f7695d3256ac36e0cf00e4.KzC1SeqeiatayhdhuRnUYfJG6MPTmx8QIbp2pnLPAkM+ hash: v1.k794b7964.64e2dadc01e847ba81ba43ae802bbfd18631e50257d614530d96ce653be5a79b.IlIEo0DfEWgbB_wnutNzeFZcD50RJeITnhM9QaYE-W8scenes-other-onboarding--alerts--dark:hash: v1.k794b7964.c22b202da34ceea01a9dc7162520e35f2366b891dc31dfef3f4cc1c02a732925.Zsv8Bo4o_X08cJdxFTd6O68BqhLEViaM9XxAGNO_T1kscenes-other-onboarding--alerts--light:@@ -7313,9 +7313,9 @@ snapshots:scenes-other-onboarding--product-analytics-configuration--light:hash: v1.k794b7964.d02bcfb00b3c281c7310a239267f4df3eddd8ac9535c73da67f6f308ecc802db.mDI4QEeK68vppMWjGJHD6ZKuEO7QsQ1xTMZfiN2Wzo4scenes-other-onboarding--sdk-install--dark:- hash: v1.k794b7964.4c85f58954f3075da69dae89a1ccb032e4ba2c0fddf2247136a2e9edca30bf18.kBQGiG08hiiKZOuOQxDkRS71aoUv6GCTnX5PI8esNIc+ hash: v1.k794b7964.f13a0b1bc0a7c913b5a646ad6f4b5b7a7ce710f2e47cda5a690223b520081e04.bNHvfIPBNeq6nd8a7TM3_Ai4fC8ZxI9W0FUMUoCRPuQscenes-other-onboarding--sdk-install--light:- hash: v1.k794b7964.d75cd1b29a9a67012cd75a96172332a810c5727e4c92468363b954fc8eb7ba56.acfBD2LnZAIXsqOWQbBXvUN90WVynSjI8c73R2c_mTU+ hash: v1.k794b7964.18d05e299c4a40b287c82a60336a90fb0274a4b80f0d508ac133bc8d45eb0b85.TKBPTekWV2GkQ6kryFoHl0wGg2SyGU4k4h6GHkRFc1cscenes-other-onboarding--session-replay-configuration--dark:hash: v1.k794b7964.482b435a0c7fb6c0dca145e39284ac5aa006030ab1035b723e003d35848e5e2d.bxNfbPaPp_uaTpzKBdvrkiORbiuHnOotSAQGLHQ1Np4scenes-other-onboarding--session-replay-configuration--light:@@ -7329,9 +7329,9 @@ snapshots:scenes-other-onboarding--source-maps--light:hash: v1.k794b7964.5b16201cc8c0adaae60f4771c0b1dffdd2b355c6a9a45edbbceda84ea4a89d7b.oJHT8hlXUpR6-O_Cv4Rrtx_UmrN-AkPUWXTeAUXHpBoscenes-other-onboarding--workflows-custom-installation-instructions--dark:- hash: v1.k794b7964.fcd111a73d7c5de28fbb278426a024bec8b81154550549004c0303ff4d3b0e9e.n7nYyu0mx2MYkSi6X8n5waQCGJyoIy2b_eRrYRHX8Mo+ hash: v1.k794b7964.dd81a223dd76d082e354b4635025f2164f33d40c98ac905328517316e5b35d98.pd5woKnIzU5rN72oQC0_XSkgSwVZzxXp3M3MvpYL9aYscenes-other-onboarding--workflows-custom-installation-instructions--light:- hash: v1.k794b7964.82e3ad385bb537f6fdf26ec2aef29cf56401f5ca01215f10e53d4edad4d526a6.PoI2zRIus8AN7QRaTxKsDmK1QVYtl6-J-0uJwBIHDRM+ hash: v1.k794b7964.2e4c7a2a3622c774e52dca6381164f33c47e31e315e4a2809e08721b32bba1c5.rTv8V7rrbsvgftsUgo5ubSGb7tIwPifxDuVssbvUKl8scenes-other-onboarding-connect-data--connecting--dark:hash: v1.k794b7964.59f96f7b6102b81524fe52d51ca88ca8dadb1702a307fd7976737864a9088a53.eO9mz6WENzTopgbZIyuZ6fZ6K73TWyK0zpSmsllgamwscenes-other-onboarding-connect-data--connecting--light:@@ -7404,6 +7404,18 @@ snapshots:hash: v1.k794b7964.ffd7be72bc0ce9f36ca0a796b6442f5ce0998097ea97b430771d495a484696aa.RA5dclhzxUp4XuBbYRa8Ktlvad8SDQyOsgz-fvExZqEscenes-other-onboarding-installation-progress--running-wizard--light:hash: v1.k794b7964.bed8dbddcefaceb919731b1f6f03f2da690748891ca9793d8098e88fd0bc16f5.fmMcElO_fj3DC8dQpk-EEt1o_yEwyFESioVLyAD6oTk+ scenes-other-onboarding-legacy-install-step--cloud-run-in-progress--dark:+ hash: v1.k794b7964.b5ee945088ebf73e06ff4e3a3f0b7f506e20b902df8f50aef779ac3b0e433ecd.xNlLf3OVO2wRHIaGxXcEivkhq2Wbyl1eIag4VtxIru8+ scenes-other-onboarding-legacy-install-step--cloud-run-in-progress--light:+ hash: v1.k794b7964.0cc354df2c985ce3ef5811e8a21e66d57adf1f68cebf07a0e27388f1b9e66007.Fibyy8_nkxhbXEBfOSmHwSlo3QIfkrC-oC7cE2EwJgw+ scenes-other-onboarding-legacy-install-step--control-arm--dark:+ hash: v1.k794b7964.f13a0b1bc0a7c913b5a646ad6f4b5b7a7ce710f2e47cda5a690223b520081e04.e-amahshVCgQCqBHq3BIQanQqoUyk5XiuHSw8w8spfE+ scenes-other-onboarding-legacy-install-step--control-arm--light:+ hash: v1.k794b7964.18d05e299c4a40b287c82a60336a90fb0274a4b80f0d508ac133bc8d45eb0b85.gC_x7uIHFCn2MnPytLcK7oqq4kF6CkNvjPLSCZ7v7tw+ scenes-other-onboarding-legacy-install-step--test-arm--dark:+ hash: v1.k794b7964.5963b383d7d2a3f876f2047c116e50bc3a092fd34fe42c659b76a57767de8268.aZlFPXrA9RCYIpXFCV50iqgffZ-26-8qKML2-PffSuQ+ scenes-other-onboarding-legacy-install-step--test-arm--light:+ hash: v1.k794b7964.421b5cebe6bb09aa509224da47b266ece6cd81b1e8a8c4346865724be53d493f.oJXUzGGMy03cEx_8ZvnJMPVdfAF_SksSZgShSA_WsX4scenes-other-onboarding-product-selection--base--dark:hash: v1.k794b7964.6b35abf90f865d866bfe83ead0b3d2b6d1686a4efbb6f513d2d3470a36a3928b.51PN1rmvasAVWZFwSu5wHcNhcntw6epUCisAuCTGClYscenes-other-onboarding-product-selection--base--light:diff --git a/frontend/src/scenes/onboarding/legacy/sdks/OnboardingInstallStep/WizardCommandBlock.scss b/frontend/src/scenes/onboarding/legacy/sdks/OnboardingInstallStep/WizardCommandBlock.scssdeleted file mode 100644index dd098e09ad3e..000000000000--- a/frontend/src/scenes/onboarding/legacy/sdks/OnboardingInstallStep/WizardCommandBlock.scss+++ /dev/null@@ -1,29 +0,0 @@-// Hedgehog "casting a spell" wobble — played by remounting the <img> element-// with a fresh key, so the animation runs from the start on every copy click.--.WizardCommandBlock__hogCast {- animation: WizardCommandBlock-hogCast 500ms ease-out;-}--/* stylelint-disable-next-line keyframes-name-pattern */-@keyframes WizardCommandBlock-hogCast {- 0% {- transform: rotate(0deg);- }-- 20% {- transform: rotate(-8deg);- }-- 50% {- transform: rotate(5deg);- }-- 80% {- transform: rotate(-2deg);- }-- 100% {- transform: rotate(0deg);- }-}diff --git a/frontend/src/scenes/onboarding/legacy/sdks/OnboardingInstallStep/WizardCommandBlock.tsx b/frontend/src/scenes/onboarding/legacy/sdks/OnboardingInstallStep/WizardCommandBlock.tsxdeleted file mode 100644index 6653b5ba3eab..000000000000--- a/frontend/src/scenes/onboarding/legacy/sdks/OnboardingInstallStep/WizardCommandBlock.tsx+++ /dev/null@@ -1,106 +0,0 @@-import './WizardCommandBlock.scss'--import { type ComponentType, useState } from 'react'--import { CommandBlock } from 'lib/components/CommandBlock/CommandBlock'-import { cn } from 'lib/utils/css-classes'-import { useWizardCommand } from 'scenes/onboarding/shared/SetupWizardBanner'-import { WIZARD_HOG_URL } from 'scenes/onboarding/shared/wizardHog'--import androidImage from '../logos/android.svg'-import angularImage from '../logos/angular.svg'-import { AstroLogo } from '../logos/AstroLogo'-import djangoImage from '../logos/django.svg'-import flaskImage from '../logos/flask.svg'-import { IOSLogo } from '../logos/IOSLogo'-import laravelImage from '../logos/laravel.svg'-import nextjsImage from '../logos/nextjs.svg'-import nuxtImage from '../logos/nuxt.svg'-import pythonImage from '../logos/python.svg'-import railsImage from '../logos/rails.svg'-import reactImage from '../logos/react.svg'-import { ReactRouterLogo } from '../logos/ReactRouterLogo'-import svelteImage from '../logos/svelte.svg'-import vueImage from '../logos/vue.svg'--// Supported wizard frameworks for display-const WIZARD_FRAMEWORKS: { name: string; icon: string | ComponentType }[] = [- { name: 'Next.js', icon: nextjsImage },- { name: 'React', icon: reactImage },- { name: 'Angular', icon: angularImage },- { name: 'Vue', icon: vueImage },- { name: 'Nuxt', icon: nuxtImage },- { name: 'Astro', icon: AstroLogo },- { name: 'SvelteKit', icon: svelteImage },- { name: 'Django', icon: djangoImage },- { name: 'Flask', icon: flaskImage },- { name: 'Laravel', icon: laravelImage },- { name: 'React Native', icon: reactImage },- { name: 'iOS', icon: IOSLogo },- { name: 'Android', icon: androidImage },- { name: 'Ruby on Rails', icon: railsImage },- { name: 'React Router', icon: ReactRouterLogo },- { name: 'Python', icon: pythonImage },-]--export function WizardCommandBlock(): JSX.Element {- const { wizardCommand, isCloudOrDev } = useWizardCommand()- const [castKey, setCastKey] = useState(0)-- // The `npx @posthog/wizard` CLI only targets cloud (US/EU) and dev instances —- // self-hosted deployments have no preconfigured endpoint, so we hide the block- // entirely rather than show a command that can't work. Matches SetupWizardBanner.- if (!isCloudOrDev) {- return <></>- }-- return (- <div className="flex flex-col gap-3">- <div className="flex gap-6">- <img- key={`hog-${castKey}`}- src={WIZARD_HOG_URL}- alt="PostHog wizard hedgehog"- className={cn(- 'w-28 h-28 hidden sm:block shrink-0 self-center',- castKey > 0 && 'WizardCommandBlock__hogCast'- )}- />- <div className="flex-1 flex flex-col gap-3">- <CommandBlock- command={wizardCommand}- copyLabel="Wizard command"- ariaLabel="Copy wizard command"- size="md"- decoration="rainbow"- className="bg-bg-light border border-border hover:border-primary"- onCopy={(key) => setCastKey(key)}- />-- <p className="text-xs text-muted mb-0">- Auto-detects your framework, installs the SDK, and sets up event capture.- </p>-- <div className="flex flex-wrap gap-1.5 items-center">- <span className="text-xs text-muted">Supports:</span>- {WIZARD_FRAMEWORKS.map((fw) => (- <span- key={fw.name}- className="inline-flex items-center gap-1 text-xs text-muted bg-bg-light border border-border rounded px-1.5 py-0.5"- >- {typeof fw.icon === 'string' ? (- <img src={fw.icon} alt="" className="w-3 h-3 shrink-0" />- ) : (- <span className="inline-flex w-3 h-3 shrink-0 [&_svg]:!w-3 [&_svg]:!h-3">- <fw.icon />- </span>- )}- {fw.name}- </span>- ))}- </div>- </div>- </div>- </div>- )-}diff --git a/frontend/src/scenes/onboarding/legacy/sdks/OnboardingInstallStep/WizardInstallStep/WizardInstallStep.stories.tsx b/frontend/src/scenes/onboarding/legacy/sdks/OnboardingInstallStep/WizardInstallStep/WizardInstallStep.stories.tsxnew file mode 100644index 000000000000..6154c7459680--- /dev/null+++ b/frontend/src/scenes/onboarding/legacy/sdks/OnboardingInstallStep/WizardInstallStep/WizardInstallStep.stories.tsx@@ -0,0 +1,196 @@+import { MOCK_TEAM_ID } from 'lib/api.mock'++import { Meta, StoryObj } from '@storybook/react'+import { waitFor } from '@testing-library/dom'+import { useActions, useMountedLogic } from 'kea'+import { router } from 'kea-router'++import { FEATURE_FLAGS } from 'lib/constants'+import { useDelayedOnMountEffect } from 'lib/hooks/useOnMountEffect'+import { App } from 'scenes/App'+import { availableOnboardingProducts } from 'scenes/onboarding/shared/utils'+import { urls } from 'scenes/urls'++import { mswDecorator } from '~/mocks/browser'+import { billingJson } from '~/mocks/fixtures/_billing'+import preflightJson from '~/mocks/fixtures/_preflight.json'+import { ProductKey } from '~/queries/schema/schema-general'+import { IntegrationType, OnboardingStepKey } from '~/types'++import { activeCloudRunLogic } from '../../../../shared/wizard-sync/activeCloudRunLogic'+import { onboardingLogic } from '../../../onboardingLogic'++/**+ * The legacy onboarding install step under each arm of the cloud-wizard AB test (GROW-117), plus the+ * pinned progress state once a cloud run is underway. The context-first variant's equivalents live in+ * the Wizard Cloud Run stories; these render the legacy flow (ONBOARDING_FLOW_VARIANT unset).+ */++const githubIntegration: IntegrationType = {+ id: 1,+ kind: 'github',+ display_name: 'acme-co',+ icon_url: '/static/services/github.png',+ config: { account: { name: 'acme-co', type: 'Organization' }, repository_selection: 'all' },+ created_at: '2024-01-01T00:00:00Z',+}++const githubReposResponse = {+ repositories: [+ {+ id: 1,+ name: 'web',+ full_name: 'acme-co/web',+ private: false,+ default_branch: 'main',+ language: 'TypeScript',+ pushed_at: '2023-05-24T10:00:00Z',+ archived: false,+ can_push: true,+ },+ ],+ has_more: false,+}++// One SSE frame. The task-run stream speaks `data:`-only messages (default event type), so the+// EventSource `onmessage` handler picks them up.+const sseEvent = (data: object): string => `data: ${JSON.stringify(data)}\n\n`+const sseStep = (group: string, step: string, status: string, label: string, detail: string | null = null): string =>+ sseEvent({+ type: 'notification',+ notification: { method: '_posthog/progress', params: { group, step, status, label, detail } },+ })++// A mid-run pipeline snapshot, replayed to the InstallationProgressView the moment it connects. The+// trailing `stream-end` sentinel makes the logic close the EventSource, so the rendered state is+// stable for the snapshot (no reconnect churn).+const TASK_RUN_STREAM_BODY = [+ sseEvent({+ type: 'task_run_state',+ status: 'in_progress',+ stage: 'work',+ output: null,+ branch: null,+ error_message: null,+ updated_at: '2023-05-25T00:00:00Z',+ completed_at: null,+ }),+ sseStep('setup', 'sandbox', 'completed', 'Set up sandbox'),+ sseStep('setup', 'clone', 'completed', 'Cloned repository'),+ sseStep('setup', 'wizard', 'in_progress', 'Running setup wizard', 'Detecting Next.js'),+ sseStep('deliver', 'pr', 'pending', 'Opening pull request'),+ 'event: stream-end\ndata: {}\n\n',+].join('')++const meta: Meta = {+ title: 'Scenes-Other/Onboarding/Legacy Install Step',+ parameters: {+ layout: 'fullscreen',+ viewMode: 'story',+ mockDate: '2023-05-25',+ // The cloud tab and the pinned run render spinners by design (repo loading, in-progress+ // steps) — skip the test runner's default "wait for loaders to hide" check.+ testOptions: { waitForLoadersToDisappear: false },+ },+ decorators: [+ mswDecorator({+ get: {+ '/_preflight': { ...preflightJson, cloud: true, realm: 'cloud' },+ '/stats': {},+ '/events': {},+ '/api/billing/': { ...billingJson },+ '/api/environments/:team_id/integrations': { results: [githubIntegration] },+ '/api/environments/:team_id/integrations/:id/github_repos': githubReposResponse,+ '/api/projects/:project_id/tasks/:task_id/runs/:run_id/stream': () =>+ new Response(TASK_RUN_STREAM_BODY, {+ status: 200,+ headers: { 'Content-Type': 'text/event-stream' },+ }),+ // No wizard session enriching the run in these stories; a 404 closes the EventSource+ // without retries (the pipeline above is the only progress source).+ '/api/projects/:project_id/wizard/sessions/stream': () => [404],+ },+ patch: {+ '/api/environments/:team_id/add_product_intent/': {},+ },+ }),+ ],+}+export default meta++type Story = StoryObj++/** Lands on the legacy install step for product analytics, optionally staging extra state first. */+function legacyInstallStory({+ featureFlags = {},+ drive,+ waitForSelector,+ play,+}: {+ featureFlags?: Record<string, string | boolean>+ drive?: () => void+ waitForSelector: string+ play?: () => Promise<void>+}): Story {+ return {+ render: () => {+ useMountedLogic(onboardingLogic)+ useMountedLogic(activeCloudRunLogic)+ const { setProduct } = useActions(onboardingLogic)++ useDelayedOnMountEffect(() => {+ // activeCloudRun is persisted (survives a refresh mid-run) — clear any handle left+ // over from an earlier story in the same browser session before driving this one.+ activeCloudRunLogic.actions.clearActiveCloudRun()+ drive?.()+ setProduct(availableOnboardingProducts[ProductKey.PRODUCT_ANALYTICS])+ router.actions.push(+ urls.onboarding({ productKey: ProductKey.PRODUCT_ANALYTICS, stepKey: OnboardingStepKey.INSTALL })+ )+ })++ return <App />+ },+ parameters: { featureFlags, testOptions: { waitForSelector } },+ play,+ }+}++/**+ * Control arm: no cloud option — the intro, the CLI command block, and the framework badges. The flag+ * is deliberately UNSET rather than 'control': storybook's useFeatureFlag treats any truthy value as+ * flag-on (the variant match is ignored there), and the control arm renders the flag-off branch anyway.+ */+export const ControlArm: Story = legacyInstallStory({+ waitForSelector: '[data-attr="wizard-command-block"]',+})++/** Test arm: the cloud/local toggle with the "open a PR" block up front (GitHub connected). */+export const TestArm: Story = legacyInstallStory({+ featureFlags: { [FEATURE_FLAGS.ONBOARDING_WIZARD_CLOUD_RUN]: 'test' },+ waitForSelector: '[data-attr="wizard-cloud-run-open-pr"]',+})++/**+ * A cloud run underway: the step pins to the run's live pipeline (fed by the mocked task-run+ * stream), the local tab is blocked, and Continue is unblocked.+ */+export const CloudRunInProgress: Story = legacyInstallStory({+ featureFlags: { [FEATURE_FLAGS.ONBOARDING_WIZARD_CLOUD_RUN]: 'test' },+ drive: () =>+ activeCloudRunLogic.actions.setActiveCloudRun('task-1', 'run-1', new Date().toISOString(), MOCK_TEAM_ID),+ waitForSelector: '[data-attr="installation-progress"]',+ play: async () => {+ // The panel mounts in the 'connecting' phase; hold the snapshot until the mocked stream's+ // pipeline steps have rendered so it captures the mid-run timeline, not the placeholder.+ await waitFor(+ () => {+ const timeline = document.querySelector('[data-attr="installation-progress"]')+ if (!timeline?.textContent?.includes('Running setup wizard')) {+ throw new Error('pipeline timeline not ready')+ }+ },+ { timeout: 8000, interval: 200 }+ )+ },+})diff --git a/frontend/src/scenes/onboarding/legacy/sdks/OnboardingInstallStep/WizardInstallStep/index.tsx b/frontend/src/scenes/onboarding/legacy/sdks/OnboardingInstallStep/WizardInstallStep/index.tsxindex 380094b6b09e..c13a124f2234 100644--- a/frontend/src/scenes/onboarding/legacy/sdks/OnboardingInstallStep/WizardInstallStep/index.tsx+++ b/frontend/src/scenes/onboarding/legacy/sdks/OnboardingInstallStep/WizardInstallStep/index.tsx@@ -8,13 +8,13 @@ import { OnboardingStepKey, type SDK } from '~/types'import { onboardingEventUsageLogic } from '../../../../onboardingEventUsageLogic'import { activeCloudRunLogic } from '../../../../shared/wizard-sync/activeCloudRunLogic'+import { WizardCommandBlock } from '../../../../shared/wizard-sync/WizardCommandBlock'import { WizardInstallOptions } from '../../../../shared/wizard-sync/WizardInstallOptions'import { OnboardingStep } from '../../../OnboardingStep'import { AdblockWarning, RealtimeCheckIndicator } from '../../RealtimeCheckIndicator'import { SDKGrid } from '../SDKGrid'import { SDKInstructionsModal } from '../SDKInstructionsModal'import { VariantProps } from '../types'-import { WizardCommandBlock } from '../WizardCommandBlock'import { wizardInstallStepLogic } from '../wizardInstallStepLogic'import { WizardProgressTracker, useWizardTakeoverActive } from '../WizardProgressTracker'import { WizardInstallIntro } from './WizardInstallIntro'diff --git a/frontend/src/scenes/onboarding/onboardingEventUsageLogic.ts b/frontend/src/scenes/onboarding/onboardingEventUsageLogic.tsindex 308e95cfc2be..509932b52802 100644--- a/frontend/src/scenes/onboarding/onboardingEventUsageLogic.ts+++ b/frontend/src/scenes/onboarding/onboardingEventUsageLogic.ts@@ -1,7 +1,9 @@import { actions, connect, kea, listeners, path } from 'kea'import posthog from 'posthog-js'+import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic, type FeatureFlagsSet } from 'lib/logic/featureFlagLogic'+import { projectLogic } from 'scenes/projectLogic'import type { onboardingEventUsageLogicType } from './onboardingEventUsageLogicType'import { resolveOnboardingFlowVariant } from './onboardingVariants'@@ -15,15 +17,43 @@ export type ContextOnboardingStepId = 'welcome' | 'install' | 'sources' | 'wareh// `eventUsageLogic`, stamped `{version: 1, flow_variant: 'legacy'}`.const CONTEXT_ONBOARDING_EVENT_PROPS = { version: 2, flow_variant: 'context_first' } as const+/** Arm of the cloud-wizard AB test (GROW-117): `test` offers the cloud run, `control` is local-only. */+export type CloudRunExperimentArm = 'control' | 'test'++/**+ * The user's experiment arm, or null when they are not enrolled: an unset/boolean flag value (not+ * rolled out, targeting excludes them, flags not loaded yet) must NOT be collapsed into `control`,+ * or never-enrolled users pollute the control cohort and bias the readout toward "no effect".+ */+export function resolveCloudRunExperimentArm(featureFlags: FeatureFlagsSet): CloudRunExperimentArm | null {+ const value = featureFlags[FEATURE_FLAGS.ONBOARDING_WIZARD_CLOUD_RUN]+ return value === 'test' || value === 'control' ? value : null+}+// Wizard-sync events fire from BOTH onboarding variants (GROW-121): same v2 event shape, but-// flow_variant reflects whichever flow the user is actually in so the AB test can split on it.-function wizardSyncEventProps(featureFlags: FeatureFlagsSet): { version: 2; flow_variant: string } {+// flow_variant reflects whichever flow the user is actually in, and the cloud-run experiment arm+// rides along (GROW-117) so downstream metrics can split on either without a flag-persons join.+function wizardSyncEventProps(featureFlags: FeatureFlagsSet): {+ version: 2+ flow_variant: string+ cloud_run_experiment_arm: CloudRunExperimentArm | null+} {return {version: 2,flow_variant: resolveOnboardingFlowVariant(featureFlags) === 'self-driving' ? 'context_first' : 'legacy',+ cloud_run_experiment_arm: resolveCloudRunExperimentArm(featureFlags),}}+// One exposure per project per pageload: the install step remounts on navigation, and a re-fired+// exposure would inflate the denominator, but a project switch mid-session is a fresh exposure.+// Module-scoped, mirroring the wizard tracker's once-per-session report guards.+const reportedCloudRunExperimentExposures = new Set<string>()++export function resetCloudRunExperimentExposureForTests(): void {+ reportedCloudRunExperimentExposures.clear()+}+/*** Funnel events for the context-first onboarding flow (v2) — a dedicated logic rather than more* surface on the giant `eventUsageLogic`, following `sessionRecordingEventUsageLogic`'s split.@@ -34,7 +64,7 @@ function wizardSyncEventProps(featureFlags: FeatureFlagsSet): { version: 2; flowexport const onboardingEventUsageLogic = kea<onboardingEventUsageLogicType>([path(['scenes', 'onboarding', 'onboardingEventUsageLogic']),connect(() => ({- values: [featureFlagLogic, ['featureFlags']],+ values: [featureFlagLogic, ['featureFlags'], projectLogic, ['currentProjectId']],})),actions({reportContextOnboardingStarted: true,@@ -60,6 +90,9 @@ export const onboardingEventUsageLogic = kea<onboardingEventUsageLogicType>([prOpened: booleanprUrl: string | null}) => props,+ // Exposure marker for the cloud-wizard AB test (GROW-117): fired when a user reaches the+ // surface where the arms diverge (the install step on cloud/dev instances).+ reportWizardCloudRunExperimentExposed: true,// Engagement with the shared wizard sync surface (FAB card / launcher / dialog), fired for// both variants and both run modes (GROW-121).reportWizardSyncExpanded: (props: { runKey: string; mode: 'cloud' | 'local'; phase: string }) => props,@@ -125,22 +158,41 @@ export const onboardingEventUsageLogic = kea<onboardingEventUsageLogicType>([...CONTEXT_ONBOARDING_EVENT_PROPS,})},- reportContextOnboardingCloudRunQueued: ({ taskId, runId, repository }) => {+ // Deliberately NOT capturing the repository name or PR URL: they identify customers'+ // (often private) repos and this event lands in the shared app analytics project. The+ // backend task_run_* lifecycle events carry them server-side; task_id/run_id join to them.+ reportContextOnboardingCloudRunQueued: ({ taskId, runId }) => {posthog.capture('onboarding cloud run queued', {task_id: taskId,run_id: runId,- repository,...wizardSyncEventProps(values.featureFlags),})},- reportContextOnboardingCloudRunCompleted: ({ taskId, runId, status, durationSeconds, prOpened, prUrl }) => {+ reportContextOnboardingCloudRunCompleted: ({ taskId, runId, status, durationSeconds, prOpened }) => {posthog.capture('onboarding cloud run completed', {task_id: taskId,run_id: runId,status,duration_seconds: durationSeconds,pr_opened: prOpened,- pr_url: prUrl,+ ...wizardSyncEventProps(values.featureFlags),+ })+ },+ reportWizardCloudRunExperimentExposed: () => {+ // Enrollment-gated: callers fire on readiness (preflight + receivedFeatureFlags), and a+ // null arm means the user is not in the experiment — no exposure, no guard, so a later+ // dispatch after enrollment resolves can still count them. Never stamp a guessed arm:+ // a mis-bucketed exposure cannot be repaired retroactively.+ const arm = resolveCloudRunExperimentArm(values.featureFlags)+ if (arm === null) {+ return+ }+ const projectKey = String(values.currentProjectId ?? 'unknown')+ if (reportedCloudRunExperimentExposures.has(projectKey)) {+ return+ }+ reportedCloudRunExperimentExposures.add(projectKey)+ posthog.capture('wizard cloud run experiment exposed', {...wizardSyncEventProps(values.featureFlags),})},diff --git a/frontend/src/scenes/onboarding/self-driving/ContextOnboarding.tsx b/frontend/src/scenes/onboarding/self-driving/ContextOnboarding.tsxindex 8f1f20d47d34..3e811c1aad2c 100644--- a/frontend/src/scenes/onboarding/self-driving/ContextOnboarding.tsx+++ b/frontend/src/scenes/onboarding/self-driving/ContextOnboarding.tsx@@ -32,7 +32,6 @@ import { installationProgressLogic } from '../shared/wizard-sync/installationProimport { wizardCloudRunLogic } from '../shared/wizard-sync/wizardCloudRunLogic'import { WizardCommandBlock } from '../shared/wizard-sync/WizardCommandBlock'import { WizardInstallOptions } from '../shared/wizard-sync/WizardInstallOptions'-import { WizardFrameworkBadges } from '../shared/wizard-sync/WizardModeShell'import { ContextBillingStep } from './ContextBillingStep'import { ContextInviteStep } from './ContextInviteStep'import { ContextWarehouseStep } from './ContextWarehouseStep'@@ -61,8 +60,8 @@ function WelcomeStep(): JSX.Element {)}-// One wizard, two ways to run it — the shared WizardInstallOptions owns the cloud/local switching;-// this wraps it in the self-driving copy, framework badges, and manual-docs fallback.+// One wizard, two ways to run it — the shared WizardInstallOptions owns the cloud/local switching+// and framework badges; this wraps it in the self-driving copy and manual-docs fallback.function InstallOptions({ onContinue }: { onContinue: () => void }): JSX.Element {const cloudRunEnabled = useFeatureFlag('ONBOARDING_WIZARD_CLOUD_RUN', 'test')const { isCloudOrDev } = useWizardCommand()@@ -99,10 +98,6 @@ function InstallOptions({ onContinue }: { onContinue: () => void }): JSX.ElementRun the wizard to get your product's context flowing so agents can start finding and fixing things.</p>)}- {/* Frameworks are the same whichever way the wizard runs, so the badges sit above the selector. */}- <div className="pb-2">- <WizardFrameworkBadges />- </div>{/* GROW-96: kicking off the cloud run is the step's "next" action, so onQueued advances the flow. */}<WizardInstallOptionshideHogdiff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardInstallOptions.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardInstallOptions.tsxindex 618cc2c8d0fc..a397a7838170 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardInstallOptions.tsx+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardInstallOptions.tsx@@ -1,14 +1,18 @@import { useActions, useValues } from 'kea'import { useState } from 'react'+import { useEffect } from 'react'import { IconCloud, IconTerminal } from '@posthog/icons'import { LemonSegmentedButton } from '@posthog/lemon-ui'import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { onboardingEventUsageLogic } from '../../onboardingEventUsageLogic'import { useWizardCommand } from '../SetupWizardBanner'import { activeCloudRunLogic } from './activeCloudRunLogic'import { WizardCloudRunBlock } from './WizardCloudRunBlock'+import { WizardFrameworkBadges } from './WizardModeShell'export type WizardInstallMode = 'cloud' | 'local'@@ -39,9 +43,24 @@ export function WizardInstallOptions({const { isCloudOrDev } = useWizardCommand()const { activeCloudRun } = useValues(activeCloudRunLogic)const { clearActiveCloudRun } = useActions(activeCloudRunLogic)+ const { reportWizardCloudRunExperimentExposed } = useActions(onboardingEventUsageLogic)const [mode, setMode] = useState<WizardInstallMode>('cloud')const offerCloud = cloudRunEnabled && isCloudOrDev++ // GROW-117: this component is where the cloud-run AB arms diverge — control collapses to the+ // local block, test shows the picker — so showing it on a cloud/dev instance IS the exposure.+ // Both gates resolve asynchronously (preflight for isCloudOrDev, posthog-js for the flags), so+ // fire on readiness rather than once at mount: a mount-time snapshot would drop or mis-bucket+ // exposures for exactly the fresh-signup population the experiment measures. The listener+ // dedupes and skips unenrolled users, so re-fires are safe. Self-hosted never offers cloud+ // runs on either arm, so it stays out of the experiment.+ const { receivedFeatureFlags } = useValues(featureFlagLogic)+ useEffect(() => {+ if (isCloudOrDev && receivedFeatureFlags) {+ reportWizardCloudRunExperimentExposed()+ }+ }, [isCloudOrDev, receivedFeatureFlags, reportWizardCloudRunExperimentExposed])// GROW-95: once a cloud run is spawned you cannot also run it locally, so the local tab is blocked// and the view pins to the cloud run's progress until it is cleared (e.g. via the failure fallback).const localBlocked = !!activeCloudRun@@ -54,18 +73,32 @@ export function WizardInstallOptions({setMode('local')}+ // The frameworks are the same whichever way (and in whichever variant) the wizard runs, so the+ // badge list rides with the options everywhere. Self-hosted gets no wizard, so no badges either.+ const badges = isCloudOrDev && (+ <div className="pb-2">+ <WizardFrameworkBadges />+ </div>+ )+if (!offerCloud) {// A persisted run outlives the experiment arm: keep rendering its progress (with the local// fallback) even when the flag no longer offers new cloud runs, so nothing is stranded.- return activeCloudRun ? (- <WizardCloudRunBlock hideHog={hideHog} onRetryLocally={runItYourself} onQueued={onQueued} />- ) : (- <>{localBlock}</>+ return (+ <div className="flex flex-col gap-4">+ {badges}+ {activeCloudRun ? (+ <WizardCloudRunBlock hideHog={hideHog} onRetryLocally={runItYourself} onQueued={onQueued} />+ ) : (+ localBlock+ )}+ </div>)}return (<div className="flex flex-col gap-4">+ {badges}<LemonSegmentedButtonfullWidthvalue={effectiveMode}