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): show onboarding activation failures (#126182)

Georgiy Tarasov9fe3bd544a49
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 766320513054..bdbf0f740e57 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -12334,6 +12334,10 @@ snapshots:
hash: v1.k794b7964.653864650883238be09ff223e227c4aef6d637308cd9cb5337bbd122ba0e16c6.KmAERZYNS8d-FYi019q153Z49JfnWLSi5oewFlizVZs
scenes-app-inbox-focused-setup--quick-activated--light:
hash: v1.k794b7964.fd316d377c5a14dc45c7359ea18419d3da11c4c8a9e3c33edb29f7c20c42d82c.8bPWIes64TfbjuoTB-n963_IoRvpIj4q1ZATzDvvUj0
+ scenes-app-inbox-focused-setup--quick-activation-failed--dark:
+ hash: v1.k794b7964.5be3ea2ca1b0fc3f73bebe7cb6fd6594f8b2464747267e6063c6f40ce3191d49.wbnLZzbhUG9p-lw0leQKJi6gIlb8GXolublF2gAlXx8
+ scenes-app-inbox-focused-setup--quick-activation-failed--light:
+ hash: v1.k794b7964.cc295c7a25de2f851622406855bf0e57761da1fc92aa067c52f19d80ddf3e08e.cnKNnf-5Pqy9HRCqfJzcuf7X3lIpB5mT50-PFCtgS9g
scenes-app-inbox-focused-setup--quick-connected--dark:
hash: v1.k794b7964.e0f8ccaf099a26d2c9e5a01759d4335c4f3874920c0cc87629cc18c08f2a186d.IVEw-2rU5zq3HvMxGsIMmvZBD1OXc9mMb_fvRGqWbH4
scenes-app-inbox-focused-setup--quick-connected--light:
diff --git a/products/signals/frontend/inbox/components/onboarding/InboxQuickSetupAction.tsx b/products/signals/frontend/inbox/components/onboarding/InboxQuickSetupAction.tsx
index 02b9cb3b1005..09e41410bdba 100644
--- a/products/signals/frontend/inbox/components/onboarding/InboxQuickSetupAction.tsx
+++ b/products/signals/frontend/inbox/components/onboarding/InboxQuickSetupAction.tsx
@@ -15,7 +15,7 @@ import { inboxSetupLogic } from '../../logics/inboxSetupLogic'
import { useScoutCreateDisabledReason } from '../config/scouts/ScoutCreateModalHost'
export function InboxQuickSetupAction(): JSX.Element {
- const { startSetup, connectGithub, activateQuickSetup, resumeQuickSetup, retry } = useActions(inboxSetupLogic)
+ const { connectGithub, activateQuickSetup, resumeQuickSetup, retry } = useActions(inboxSetupLogic)
const {
hasGithubIntegration,
isGithubOptionalSetup,
@@ -23,7 +23,6 @@ export function InboxQuickSetupAction(): JSX.Element {
saving,
error,
shouldResumeQuickSetup,
- failedOperation,
} = useValues(inboxSetupLogic)
const { integrations, integrationsLoading } = useValues(integrationsLogic)
const scoutDisabledReason = useScoutCreateDisabledReason()
@@ -70,17 +69,11 @@ export function InboxQuickSetupAction(): JSX.Element {
/>
)}
{error && (
- <LemonBanner type="error">
- {error}
+ <LemonBanner type="error" className="w-full">
+ <span>{error}</span>
<LemonButton
size="small"
- onClick={
- failedOperation === 'scouts' || failedOperation === 'sources'
- ? retry
- : hasGithubIntegration
- ? () => activateQuickSetup('retry')
- : startSetup
- }
+ onClick={retry}
loading={busy}
disabledReason={restrictionReason || scoutDisabledReason}
>
diff --git a/products/signals/frontend/inbox/components/onboarding/InboxSetupFlow.stories.tsx b/products/signals/frontend/inbox/components/onboarding/InboxSetupFlow.stories.tsx
index 272ecf9c4f41..af9b7cd808e7 100644
--- a/products/signals/frontend/inbox/components/onboarding/InboxSetupFlow.stories.tsx
+++ b/products/signals/frontend/inbox/components/onboarding/InboxSetupFlow.stories.tsx
@@ -6,7 +6,7 @@ import { useValues } from 'kea'
import { FEATURE_FLAGS, TeamMembershipLevel } from 'lib/constants'
-import { mswDecorator } from '~/mocks/browser'
+import { mswDecorator, useStorybookMocks } from '~/mocks/browser'
import { expect } from 'storybook/test'
@@ -464,6 +464,36 @@ export const QuickConnected: Story = {
],
}
+export const QuickActivationFailed: Story = {
+ ...QuickConnected,
+ name: 'Quick activation error',
+ render: () => {
+ useStorybookMocks({
+ post: {
+ '/api/projects/:id/signals/onboarding/complete/': [
+ 503,
+ { detail: 'Activation interrupted', code: 'activation_interrupted' },
+ ],
+ },
+ })
+ return <QuickActivationPreview />
+ },
+ beforeEach: () => {
+ quickActivationCompleted = false
+ },
+ play: async ({ canvas, userEvent }) => {
+ const activate = (await canvas.findByText('Activate Self-Driving')).closest('button')!
+ await waitFor(() => expect(activate).toHaveAttribute('aria-disabled', 'false'))
+ await userEvent.click(activate)
+ const message = await canvas.findByText('Activation interrupted')
+ await waitFor(() => {
+ expect(inboxSetupLogic.values.saving).toBe(false)
+ expect(message.parentElement!.clientWidth).toBeGreaterThan(0)
+ })
+ await expect(canvas.getByText('Retry')).toBeVisible()
+ },
+}
+
export const QuickActivated: Story = {
render: () => (
<div className="mx-auto max-w-4xl p-6">
diff --git a/products/signals/frontend/inbox/logics/inboxSetupLogic.test.ts b/products/signals/frontend/inbox/logics/inboxSetupLogic.test.ts
index 7fe86f463d44..99782917c064 100644
--- a/products/signals/frontend/inbox/logics/inboxSetupLogic.test.ts
+++ b/products/signals/frontend/inbox/logics/inboxSetupLogic.test.ts
@@ -576,53 +576,80 @@ describe('Inbox setup', () => {
}
})
- it.each([true, false])('retries partial activation with usage-based pricing %s', async (usageBasedPricing) => {
- featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.SELF_DRIVING_UBP]: usageBasedPricing })
- const capture = jest.spyOn(posthog, 'capture')
- await expectLogic(logic, () => logic.actions.startSetup()).toFinishAllListeners()
- expect(logic.values.activationDisabledReason).toBeUndefined()
- expect(capture.mock.calls.filter(([event]) => event === 'self-driving onboarding started')).toHaveLength(0)
- await expectLogic(logic, () => logic.actions.activate()).toFinishAllListeners()
- expect(logic.values.completed).toBe(false)
- expect(logic.values.inProgress).toBe(true)
- expect(logic.values.draft).toEqual({ ...draft, automatic_implementation: !usageBasedPricing })
- expect(logic.values.error).toBeTruthy()
- expect(createdSources).toBe(1)
+ it.each([
+ { usageBasedPricing: true, detail: 'Activation interrupted', status: 400 },
+ { usageBasedPricing: false, detail: 'Activation interrupted', status: 503 },
+ { usageBasedPricing: true, detail: null, status: 503 },
+ { usageBasedPricing: true, detail: ' ', status: 500 },
+ ])(
+ 'retries partial activation with pricing $usageBasedPricing and detail $detail',
+ async ({ usageBasedPricing, detail, status }) => {
+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.SELF_DRIVING_UBP]: usageBasedPricing })
+ const capture = jest.spyOn(posthog, 'capture')
+ const captureException = jest.spyOn(posthog, 'captureException').mockImplementation(() => undefined)
+ useMocks({
+ post: {
+ '/api/projects/:id/signals/onboarding/complete/': () =>
+ failCompletion
+ ? [status, { detail, code: 'activation_interrupted' }]
+ : [200, { draft: savedDraft, completed_at: '2026-10-14T12:00:00Z' }],
+ },
+ })
+ await expectLogic(logic, () => logic.actions.startSetup()).toFinishAllListeners()
+ expect(logic.values.activationDisabledReason).toBeUndefined()
+ expect(capture.mock.calls.filter(([event]) => event === 'self-driving onboarding started')).toHaveLength(0)
+ await expectLogic(logic, () => logic.actions.activate()).toFinishAllListeners()
+ expect(logic.values.completed).toBe(false)
+ expect(logic.values.inProgress).toBe(true)
+ expect(logic.values.draft).toEqual({ ...draft, automatic_implementation: !usageBasedPricing })
+ const message = detail?.trim() || 'Could not finish setup. Your choices are saved. Retry activation.'
+ expect(logic.values.error).toBe(message)
+ expect(logic.values.failedOperation).toBe('activation')
+ expect(logic.values.saving).toBe(false)
+ expect(captureException).toHaveBeenCalledWith(
+ expect.objectContaining({ status, code: 'activation_interrupted' }),
+ { operation: 'inbox_activation', http_status: status, error_code: 'activation_interrupted' }
+ )
+ expect(createdSources).toBe(1)
- failCompletion = false
- await expectLogic(logic, () => logic.actions.retry()).toFinishAllListeners()
- expect(savedDraft?.automatic_implementation).toBe(!usageBasedPricing)
- expect(logic.values.completed).toBe(true)
- expect(logic.values.inProgress).toBe(false)
- expect(createdSources).toBe(1)
- expect(capture.mock.calls.filter(([event]) => event === 'self-driving onboarding started')).toHaveLength(1)
- expect(capture.mock.calls.filter(([event]) => event === 'Signal source connected')).toEqual([
- [
- 'Signal source connected',
- expect.objectContaining({
- source_product: 'error_tracking',
- is_first_connection: true,
- setup_mode: 'guided',
- }),
- undefined,
- ],
- ])
- expect(capture.mock.calls.filter(([event]) => event === 'self-driving onboarding failed')).toEqual([
- [
- 'self-driving onboarding failed',
- expect.objectContaining({
- failed_operation: 'activation',
- step: 'github',
- flow_version: 'ui-first-v1',
- }),
- ],
- ])
- expect(capture).toHaveBeenCalledWith(
- 'self-driving onboarding activation requested',
- expect.objectContaining({ activation_source: 'retry' })
- )
- capture.mockRestore()
- })
+ failCompletion = false
+ await expectLogic(logic, () => logic.actions.retry()).toFinishAllListeners()
+ expect(savedDraft?.automatic_implementation).toBe(!usageBasedPricing)
+ expect(logic.values.completed).toBe(true)
+ expect(logic.values.inProgress).toBe(false)
+ expect(createdSources).toBe(1)
+ expect(capture.mock.calls.filter(([event]) => event === 'self-driving onboarding started')).toHaveLength(1)
+ expect(capture.mock.calls.filter(([event]) => event === 'Signal source connected')).toEqual([
+ [
+ 'Signal source connected',
+ expect.objectContaining({
+ source_product: 'error_tracking',
+ is_first_connection: true,
+ setup_mode: 'guided',
+ }),
+ undefined,
+ ],
+ ])
+ expect(capture.mock.calls.filter(([event]) => event === 'self-driving onboarding failed')).toEqual([
+ [
+ 'self-driving onboarding failed',
+ expect.objectContaining({
+ failed_operation: 'activation',
+ step: 'github',
+ flow_version: 'ui-first-v1',
+ http_status: status,
+ error_code: 'activation_interrupted',
+ error_message: message,
+ }),
+ ],
+ ])
+ expect(capture).toHaveBeenCalledWith(
+ 'self-driving onboarding activation requested',
+ expect.objectContaining({ activation_source: 'retry' })
+ )
+ capture.mockRestore()
+ }
+ )
it('preserves a committed activation when its completion response was lost', async () => {
await expectLogic(logic, () => logic.actions.startSetup()).toFinishAllListeners()
diff --git a/products/signals/frontend/inbox/logics/inboxSetupLogic.ts b/products/signals/frontend/inbox/logics/inboxSetupLogic.ts
index a3a027ff468a..1d4f0825007a 100644
--- a/products/signals/frontend/inbox/logics/inboxSetupLogic.ts
+++ b/products/signals/frontend/inbox/logics/inboxSetupLogic.ts
@@ -100,6 +100,11 @@ export interface FirstReportProgressState extends FirstReportStateApi {
status: Exclude<FirstReportStateApi['status'], 'report_created'>
}
+interface InboxSetupErrorDetails {
+ http_status?: number
+ error_code?: string | null
+}
+
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface inboxSetupLogicValues {
featureFlags: FeatureFlagsSet // featureFlagLogic
@@ -226,9 +231,11 @@ export interface inboxSetupLogicActions {
setError: (
error: string | null,
failedOperation?: 'activation' | 'other' | 'scouts' | 'sources',
- failureReason?: 'draft_save_failed' | 'github_redirect_failed' | null
+ failureReason?: 'draft_save_failed' | 'github_redirect_failed' | null,
+ errorDetails?: InboxSetupErrorDetails
) => {
error: string | null
+ errorDetails: InboxSetupErrorDetails | undefined
failedOperation: 'activation' | 'other' | 'scouts' | 'sources'
failureReason: 'draft_save_failed' | 'github_redirect_failed' | null
}
@@ -433,11 +440,13 @@ export const inboxSetupLogic = kea<inboxSetupLogicType>([
setError: (
error: string | null,
failedOperation: 'activation' | 'sources' | 'scouts' | 'other' = 'other',
- failureReason: 'draft_save_failed' | 'github_redirect_failed' | null = null
+ failureReason: 'draft_save_failed' | 'github_redirect_failed' | null = null,
+ errorDetails?: InboxSetupErrorDetails
) => ({
error,
failedOperation,
failureReason,
+ errorDetails,
}),
setSavedState: (state: InboxOnboardingStateApi) => ({ state }),
}),
@@ -839,12 +848,13 @@ export const inboxSetupLogic = kea<inboxSetupLogicType>([
cache.viewedStep = key
}
},
- setError: ({ error, failedOperation, failureReason }) => {
+ setError: ({ error, failedOperation, failureReason, errorDetails }) => {
if (error) {
capture('self-driving onboarding failed', {
step: values.draft.step,
failed_operation: failedOperation,
failure_reason: failureReason ?? failedOperation,
+ ...(failedOperation === 'activation' ? { error_message: error, ...errorDetails } : {}),
})
}
},
@@ -1193,12 +1203,13 @@ export const inboxSetupLogic = kea<inboxSetupLogicType>([
actions.loadScoutConfigs()
router.actions.replace(urls.inbox())
} catch (error) {
- actions.setError(
- error instanceof ApiError
- ? error.detail
- : 'Could not finish setup. Your choices are saved. Retry activation.',
- 'activation'
- )
+ const message =
+ (error instanceof ApiError && error.detail?.trim()) ||
+ 'Could not finish setup. Your choices are saved. Retry activation.'
+ const errorDetails =
+ error instanceof ApiError ? { http_status: error.status, error_code: error.code } : undefined
+ actions.setError(message, 'activation', null, errorDetails)
+ posthog.captureException(error, { operation: 'inbox_activation', ...errorDetails })
} finally {
actions.setSaving(false)
cache.activating = false