Skip to content

: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.

fix(signals): guard scout fleet dispatch on first inbox visit (#89318)

posthog[bot]8818c302d5d3
diff --git a/frontend/src/scenes/onboarding/legacy/onboardingLogic.test.ts b/frontend/src/scenes/onboarding/legacy/onboardingLogic.test.ts
index c19c6316644d..fb20cfa4c7e9 100644
--- a/frontend/src/scenes/onboarding/legacy/onboardingLogic.test.ts
+++ b/frontend/src/scenes/onboarding/legacy/onboardingLogic.test.ts
@@ -7,6 +7,7 @@ import { SetupTaskId } from 'lib/components/ProductSetup'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { organizationLogic } from 'scenes/organizationLogic'
+import { urls } from 'scenes/urls'
import { ProductKey } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
@@ -716,6 +717,46 @@ describe('onboardingLogic — flow composition', () => {
})
})
+ describe('completion redirect gate', () => {
+ const setVariant = (value: string | undefined): void => {
+ featureFlagLogic
+ .findMounted()
+ ?.actions.setFeatureFlags(
+ value === undefined ? [] : [FEATURE_FLAGS.ONBOARDING_FLOW_VARIANT],
+ value === undefined ? {} : { [FEATURE_FLAGS.ONBOARDING_FLOW_VARIANT]: value }
+ )
+ }
+
+ // The completion PATCH that the self-driving flow sends also reaches this scene logic, which
+ // stays mounted under both variants. Only the legacy variant may redirect on it, so the two
+ // flows never push competing destinations for the same completion.
+ const completeProduct = (): void => {
+ const completed = { has_completed_onboarding_for: { product_analytics: true } }
+ logic.actions.updateCurrentTeamSuccess(completed as any, completed as any)
+ }
+
+ it('redirects on completion under the legacy variant', async () => {
+ router.actions.push(urls.default())
+ logic.actions.setProductKey(ProductKey.PRODUCT_ANALYTICS)
+ await expectLogic(logic, () => {
+ completeProduct()
+ }).toFinishAllListeners()
+ expect(router.values.location.pathname).toMatch(/quickstart|insight/i)
+ })
+
+ it('does not redirect on completion under the self-driving variant', async () => {
+ setVariant('self-driving')
+ router.actions.push(urls.default())
+ const before = router.values.location.pathname
+ logic.actions.setProductKey(ProductKey.PRODUCT_ANALYTICS)
+ await expectLogic(logic, () => {
+ completeProduct()
+ }).toFinishAllListeners()
+ expect(router.values.location.pathname).not.toMatch(/quickstart|insight/i)
+ expect(router.values.location.pathname).toBe(before)
+ })
+ })
+
describe('flow stays consistent across product changes', () => {
it('switching primary resets the secondary list and rebuilds the flow', () => {
logic.actions.setProductKey(ProductKey.PRODUCT_ANALYTICS)
diff --git a/frontend/src/scenes/onboarding/legacy/onboardingLogic.tsx b/frontend/src/scenes/onboarding/legacy/onboardingLogic.tsx
index f6cb32f97170..0cbe02a440a2 100644
--- a/frontend/src/scenes/onboarding/legacy/onboardingLogic.tsx
+++ b/frontend/src/scenes/onboarding/legacy/onboardingLogic.tsx
@@ -985,6 +985,12 @@ export const onboardingLogic = kea<onboardingLogicType>([
return [url, searchParams, undefined, { replace: true }]
},
updateCurrentTeamSuccess(val) {
+ // This scene logic stays mounted under the self-driving variant, which owns its own
+ // completion redirect. Only redirect when the legacy flow is the active variant, so the
+ // two flows do not push competing destinations for the same completion PATCH.
+ if (values.onboardingFlowVariant !== 'legacy') {
+ return
+ }
if (values.productKey && val.payload?.has_completed_onboarding_for?.[values.productKey]) {
const redirectUrl = values.onCompleteOnboardingRedirectUrl
// Reset the override after consuming it so a subsequent onboarding session
diff --git a/products/signals/frontend/inbox/logics/findingsLogic.ts b/products/signals/frontend/inbox/logics/findingsLogic.ts
index 6e876088fc76..4add8c96d5b5 100644
--- a/products/signals/frontend/inbox/logics/findingsLogic.ts
+++ b/products/signals/frontend/inbox/logics/findingsLogic.ts
@@ -871,9 +871,12 @@ export const findingsLogic = kea<findingsLogicType>([
// the report-link retry listener a poll to ride. It lives on this logic's own disposables
// under its own key, so it never disposes the section's `runsPoll` — when both are mounted
// the overlap just costs one extra capped request, since `loadRunsWindow` is idempotent.
- scoutFleetLogic.actions.loadRunsWindow()
+ scoutFleetLogic.findMounted()?.actions.loadRunsWindow()
cache.disposables.add(() => {
- const interval = setInterval(() => scoutFleetLogic.actions.loadRunsWindow(), RUNS_REFETCH_INTERVAL_MS)
+ const interval = setInterval(
+ () => scoutFleetLogic.findMounted()?.actions.loadRunsWindow(),
+ RUNS_REFETCH_INTERVAL_MS
+ )
return () => clearInterval(interval)
}, 'findingsRunsPoll')
},