: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): order multi-product install steps by the chosen primary (#65338)
posthog[bot]3e83ea34546b
diff --git a/frontend/src/scenes/onboarding/legacy/onboardingLogic.test.ts b/frontend/src/scenes/onboarding/legacy/onboardingLogic.test.tsindex ec434f069326..a15faa69afa5 100644--- a/frontend/src/scenes/onboarding/legacy/onboardingLogic.test.ts+++ b/frontend/src/scenes/onboarding/legacy/onboardingLogic.test.ts@@ -20,7 +20,7 @@ import { INSTALL_DEDUP_KEYS } from './types'* Test focus:* 1. Flow shape per single product and representative multi-product combos* 2. Install-step dedup behaviour (POSTHOG_JS, OPENTELEMETRY, no-dedup)- * 3. Bucket sort: all installs first, posthog-js install first among them+ * 3. Bucket sort: all installs first, the primary product's install first among them* 4. URL parsing defenses (cap, dedupe, filter)* 5. Navigation correctness (next/prev, bad stepId reconciliation)* 6. Completion: visited-product credit, idempotency, additionalProductKeys merge@@ -265,6 +265,19 @@ describe('onboardingLogic — flow composition', () => {expect(logsInstallIdx).toBe(1)expect(firstNonInstall).toBeGreaterThan(logsInstallIdx)})++ it('puts the primary product install first, even when a posthog-js install is secondary', () => {+ // "Monitor AI applications" use case → AI observability + product analytics.+ // When the user picks AI observability as the "Start with" product, its install+ // (which has no posthog-js dedup key) must render before the product analytics+ // install — the primary choice decides ordering, not the SDK.+ logic.actions.setProductKey(ProductKey.AI_OBSERVABILITY)+ logic.actions.setSecondaryProductKeys([ProductKey.PRODUCT_ANALYTICS])++ const ids = flowIds()+ expect(ids.indexOf('install:llm_analytics')).toBe(0)+ expect(ids.indexOf('install:llm_analytics')).toBeLessThan(ids.indexOf('install:product_analytics'))+ })})describe('shared trailing steps', () => {diff --git a/frontend/src/scenes/onboarding/legacy/onboardingLogic.tsx b/frontend/src/scenes/onboarding/legacy/onboardingLogic.tsxindex e42252dbd1a4..2f82833bb5ea 100644--- a/frontend/src/scenes/onboarding/legacy/onboardingLogic.tsx+++ b/frontend/src/scenes/onboarding/legacy/onboardingLogic.tsx@@ -26,7 +26,7 @@ import { arraysEqual, parseProductsParam, stepKeyToTitle } from './onboardingFloimport type { onboardingLogicType } from './onboardingLogicType'import { appendSharedTrailingSteps } from './sharedSteps'import { onboardingProviderRegistry } from './stepProviderRegistry'-import { INSTALL_DEDUP_KEYS, type OnboardingFlowContext, type OnboardingStepDescriptor } from './types'+import { type OnboardingFlowContext, type OnboardingStepDescriptor } from './types'/** Interface kept for callers that import it (legacy step components). */export interface OnboardingStepComponentType<P = object> extends React.FC<P> {@@ -305,19 +305,20 @@ export const onboardingLogic = kea<onboardingLogicType>([}))}- // Reorder: all install steps to the front, with the SDK install (the- // posthog-js-deduped survivor) first among them. Stable sort preserves- // each provider's intra-group order — non-install steps (configure,+ // Reorder: all install steps to the front, with the primary product's+ // install first among them — so the "Start with" choice (which product is+ // primary) decides which SDK instructions the user sees first. Stable sort+ // preserves each provider's intra-group order — non-install steps (configure,// link_data, plans, invite) keep their relative positions, just appear// after the installs. Buckets:- // 0 — Install + posthog-js dedup survivor (the canonical "SDK install")- // 1 — Install (any other dedupKey or none — Logs/OTel, Workflows, etc.)+ // 0 — Install for the primary product (the SDK the user chose to start with)+ // 1 — Install for any secondary product (Logs/OTel, Workflows, etc.)// 2 — everything else (configure, plans, invite, link_data, …)const sortBucket = (step: OnboardingStepDescriptor): number => {if (step.stepKey !== OnboardingStepKey.INSTALL) {return 2}- return step.dedupKey === INSTALL_DEDUP_KEYS.POSTHOG_JS ? 0 : 1+ return step.role === 'primary' ? 0 : 1}return result.slice().sort((a, b) => sortBucket(a) - sortBucket(b))},