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.

feat(mcp-analytics): guide setup and track activation attempts (#98668)

Lucas Fariae48a1d5b9271
diff --git a/docs/internal/mcp-analytics-activation.md b/docs/internal/mcp-analytics-activation.md
new file mode 100644
index 000000000000..652db8ad6dcd
--- /dev/null
+++ b/docs/internal/mcp-analytics-activation.md
@@ -0,0 +1,80 @@
+# MCP analytics setup measurement
+
+The product empty state offers Wizard, an installation prompt for a coding agent, and manual documentation.
+Wizard targets the selected project with `--project-id`.
+The agent prompt includes the selected project ID and backend URL, but no credentials.
+It links to the existing Markdown installation guide so the app does not depend on a new documentation URL being deployed first.
+
+## Events
+
+The shared `productSetupStatusLogic` emits these events.
+Existing click event names remain unchanged.
+
+| Event | Meaning |
+| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
+| `product empty state shown` | The setup surface rendered for the selected project. Filter `mode = needs-setup` for the initial setup denominator. |
+| `product empty state wizard command copied` | The command reached the clipboard. This does not prove the installer started. |
+| `product empty state agent instructions opened` | The agent prompt dialog opened. |
+| `product empty state agent prompt copied` | The installation prompt reached the clipboard. This does not prove the agent ran. |
+| `product empty state manual setup clicked` | The manual setup documentation opened. |
+| `product empty state wizard session observed` | A current, project-matching `mcp-analytics` Wizard session appeared or changed phase in the inline progress view. |
+| `product empty state data detected` | The product's detection logic reported `has-data` after a setup exposure or interaction in this browser. |
+
+Each setup event includes `product_key`, `project_id`, `project_uuid`, `setup_attempt_id`, `initial_setup_route`, and `setup_route`.
+Shown and interaction events also include `mode`.
+Route values are `wizard`, `agent`, or `manual`; they are null until a command/prompt is copied or the manual link is clicked.
+Opening the agent dialog does not select the agent route.
+The initial route remains fixed while the current route changes as someone tries another path.
+
+`setup_attempt_id` identifies the first setup journey in one browser for one product and project.
+It persists across navigation and reloads in local storage.
+It is not a project-wide or cross-device identifier.
+The data-detected event is emitted at most once per stored attempt.
+MCP signal queries discard successes and failures when the selected project UUID changes while the query is in flight.
+Clearing browser storage starts a new attempt, so deduplicate analysis by project, not by attempt count.
+Forced `?empty_state` previews, Storybook previews, and impersonated sessions do not emit the new setup funnel events.
+
+Wizard observations also include `wizard_session_id` and `wizard_phase`.
+The session ID is the session API's ID, not the CLI's process-level `run_id` or the cloud run's `wizard_run_id`.
+The authenticated session belongs to the selected project, which connects observed progress to the UI cohort without adding an unsupported CLI flag.
+Deduplicate Wizard observations by project, session ID, and phase.
+They can repeat on remount, and a completed session can be observed without its running phase being seen.
+
+## Funnel and outcomes
+
+Use the earliest eligible `product empty state shown` event per project as the cohort entry.
+Filter `product_key = mcp_analytics` and `mode = needs-setup`, exclude internal/test projects, and allow a full seven-day observation window.
+Use the existing instance and project UUID groups (`$group_1`, `$group_2`) as the project key; numeric IDs alone collide across regions.
+
+Measure these separately:
+
+1. Setup shown -> any setup route chosen.
+2. Setup shown -> `product empty state data detected` within seven days.
+3. Setup shown -> the existing stored product activation timestamp within seven days.
+
+Keep route choice as a diagnostic breakdown.
+It is not a randomized comparison: people who choose different installers can differ before installation.
+An experiment should assign variants at the project level and compare all eligible exposed projects in each assigned variant.
+This change does not create or start an experiment.
+
+The existing activation definition remains unchanged: MCP tool-call data plus an MCP analytics view.
+Use the stored product-intent activation timestamp for that metric; the activation event alone misses immediate activations.
+
+The data-detected event is a browser observation, not an ingestion timestamp or proof of SDK installation on a particular server.
+It can miss projects whose data arrives while no setup detection is mounted.
+MCP analytics detection currently accepts any `$mcp_tool_call` in the project, including hosted PostHog MCP traffic.
+To measure installation of an owned server, independently verify the server identity on the ingested call.
+Do not report this frontend proxy as that stronger metric.
+
+The app cannot observe an external agent starting or completing installation from a copied prompt alone.
+Keep those stages unknown until there is evidence.
+The prompt instructs the agent to verify a real tool-call event and to report pending verification when it cannot access PostHog.
+
+## Verification flow
+
+The existing setup detector keeps polling for MCP data.
+The inline Wizard view tracks the `mcp-analytics` workflow and shows its existing progress, failure, and report surfaces.
+A completed Wizard run is not evidence of a captured tool call.
+After setup, invoke an existing safe tool and inspect its event in the selected project's MCP analytics activity view.
+When data arrives, the existing empty-state gate reveals the product's activity/first-look surface.
+Stateless MCP clients may omit initialization, so `$mcp_initialize` is not required for completion.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index b8553fac337b..d64c2eff7987 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -1912,18 +1912,26 @@ snapshots:
hash: v1.k794b7964.c30a033cfdc557c02c2e1231e3a39f9c4ab5b7fc6f58861b2b6488a5771679bc.CGcyNSruX__p-Pb-BgL3aLhk-y4gvWPnVWQ4WRt3QZ4
components-product-empty-state--marketing-analytics-needs-setup--light:
hash: v1.k794b7964.81468d19337f95e32e9d53d71ec649509f0be961a0bfa1e3fbcf44f28258cfd7.YfD9ppWZGbZ8BfGaZpaUJLLrkXeKv_ra2G6Qn0en1uM
+ components-product-empty-state--mcp-analytics-agent-prompt--dark:
+ hash: v1.k794b7964.7efc1fb8a1aba52265862853a66fbd1c25d8dd267a9bb1df40ab5d6d41e30070.HtDX1LALD6SxZXxp_V2ff5tzFUUSBVKJztk3hpqJAZk
+ components-product-empty-state--mcp-analytics-agent-prompt--light:
+ hash: v1.k794b7964.f067adfcffd629b6a6d4cbac73aac29a4c65280a55886251accca60b7460a8f8.Lb3OYLj0J2qcGsCKi_t8WUb273EI696PRRDvpPr4jBM
components-product-empty-state--mcp-analytics-needs-setup--dark:
- hash: v1.k794b7964.955d7799e78bc9c0ace10dabd2bce52b354eb11b56475b6744e02b3288b7f01c.ZF3v1WTUmhePhYs8qcP_C2jQ8ak1RVqBrRx_2WN-0cA
+ hash: v1.k794b7964.6f826eacfb8a61a5020170a4e379ed49a1bd3de2695817ccb5f794e945f53e05.hD7aGePSUSpdMoTfoZZxCCAJSI1p02Ad4-lTSykt374
components-product-empty-state--mcp-analytics-needs-setup--light:
- hash: v1.k794b7964.2a07f9c4ad3cdc67496665fe087d96ef624b5416af4ea6f0a372f225bfbdf51a.nmYxmPP8M2WfgIfiO02FH1LRo3l2iHZNUAQeoIqxbyM
+ hash: v1.k794b7964.c17830e6ef956450ed87477a404453663cdd248b4d077741e9d03eb48f36de36.CftVpdVEYLLsrQc6NDgqSYZUOk3DcXSDdT5wCZXkKTI
+ components-product-empty-state--mcp-analytics-needs-setup-narrow--dark:
+ hash: v1.k794b7964.1733bf3f600d71fee852855b55a990f7816bbc4758cd4d33e31c2a59f205dc17.e-91phTQ08LUo0Q2tc7wITh9mZFvIXO-xVyLBrkvevs
+ components-product-empty-state--mcp-analytics-needs-setup-narrow--light:
+ hash: v1.k794b7964.48e11bd09202823aa8fc22034d8994fd6ce8314906229614d09691e2e868ee81.czBLo8Fm__j7hZ5ZEOPB993s72NlAf7b-4GsAi1NpFU
components-product-empty-state--mcp-analytics-waiting-for-data--dark:
- hash: v1.k794b7964.381cc4b0a52b7be8e197807df0d452faa90f841070c0b7903db848d457379360.SF2yhvD2RC5dv2ArNdphtjCRRw8Q9QWAK5hbS_7nZgQ
+ hash: v1.k794b7964.42a1f591ca016e82d20c44cfe6ef8ce302a464c50e11361d68d18e6d0112f112.H_P5v4qJAXEBesQ__dsXkifYnjpZ_UfW_dG67QXWIl8
components-product-empty-state--mcp-analytics-waiting-for-data--light:
- hash: v1.k794b7964.afc36da92cd8599bb37c555313e58ac2d9b8e0ad1d3507a3bcc2e0dd83bba0f8.4h24zMTfQcsLf2u0Y76RLDgWrzIILudjQofdU6wLJXI
+ hash: v1.k794b7964.844b448bdaf9628b3893792e2768d95080c1651ad21ceee88a5d4a75b62e26fe.xXWZsFqzfpTB6X4SHYQwsnKU2QKaczdNPRGRKiL-TTY
components-product-empty-state--mcp-analytics-without-wizard--dark:
- hash: v1.k794b7964.1a86992164badf9773af819ff363afd2da5c58e60f684b4c012b8d3fec92da0a.mJKIdXOe0PObMF3hc0adlk72-bWNdZgTRAwn-QtCqbM
+ hash: v1.k794b7964.a91b256beb713dfcc9a05b3c56ddfd3ce644b7a79e979b1c313a5b793d8ea815.drXcGdUDQym3PXhhsjE8ESVthB1XpN0SM6PsWOjLW0Q
components-product-empty-state--mcp-analytics-without-wizard--light:
- hash: v1.k794b7964.b90e900cd86f566f2ba8ca414dbadc30b47192fa3623c74d0877073e045fb10a.jzrhSBUDnD-A8Mb3pbz2kfVRItka5I2R3wBh-miWC1Q
+ hash: v1.k794b7964.168b2a4ea77e4ddd62f21e0feb71b17b94df0638d76e6f56313d5d2d9bd34f84.lng-srSwvzyTlCIfAd5RdX6k9z0uTngxwJPkKLYh_Fs
components-product-empty-state--metrics-needs-setup--dark:
hash: v1.k794b7964.75f2906aa996af4484df6752b48fbc306ceb5ab82beca50473c236506a0ba1ce.keyNXrAKRwr57hyLW_G-8QEAiiz_rhxkdxkCAMNpx9E
components-product-empty-state--metrics-needs-setup--light:
diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
index 3eb71d44b019..92104276cf7d 100644
--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
@@ -1,4 +1,6 @@
import { Meta } from '@storybook/react'
+import { screen, within } from '@testing-library/dom'
+import userEvent from '@testing-library/user-event'
import type { Mocks } from '~/mocks/utils'
@@ -81,6 +83,24 @@ export const MCPAnalyticsNeedsSetup: ProductEmptyStateStory = productEmptyStateS
{ mocks: mcpSignalMocks(false) }
)
+export const MCPAnalyticsNeedsSetupNarrow: ProductEmptyStateStory = productEmptyStateStory(
+ mcpAnalyticsEmptyState,
+ 'needs-setup',
+ { mocks: mcpSignalMocks(false), containerWidth: 520 }
+)
+
+export const MCPAnalyticsAgentPrompt: ProductEmptyStateStory = {
+ ...MCPAnalyticsNeedsSetup,
+ parameters: {
+ testOptions: { waitForLoadersToDisappear: false, snapshotTargetSelector: 'body' },
+ },
+ play: async ({ canvasElement }) => {
+ const trigger = await within(canvasElement).findByRole('button', { name: 'Install with your agent' })
+ await userEvent.click(trigger)
+ await screen.findByRole('dialog')
+ },
+}
+
export const MCPAnalyticsWaitingForData: ProductEmptyStateStory = productEmptyStateStory(
mcpAnalyticsEmptyState,
'waiting-for-data',
diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsx
index 0c7abcb27f32..070f3cf8bfee 100644
--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsx
+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsx
@@ -1,5 +1,5 @@
-import { useActions } from 'kea'
-import posthog from 'posthog-js'
+import { useActions, useValues } from 'kea'
+import { useEffect } from 'react'
import { IconBook, IconGear } from '@posthog/icons'
@@ -10,6 +10,7 @@ import { TeamMembershipLevel } from 'lib/constants'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { cn } from 'lib/utils/css-classes'
import { useWizardCommand } from 'scenes/onboarding/shared/useWizardCommand'
+import { teamLogic } from 'scenes/teamLogic'
import { productSetupStatusLogic } from './productSetupStatusLogic'
import type {
@@ -23,6 +24,7 @@ import type {
export interface ProductEmptyStateProps {
config: ProductEmptyStateConfig
mode: ProductEmptyStateMode
+ preview?: boolean
}
const ACCENT_TEXT = 'text-[var(--empty-state-accent)] dark:text-[var(--empty-state-accent-dark)]'
@@ -55,15 +57,25 @@ function resolveWizard(
* a product has been set up — gate it with `ProductEmptyStateGate` (or declare
* `emptyState` on the scene's `SceneExport` and the app shell gates for you).
*/
-export function ProductEmptyState({ config, mode }: ProductEmptyStateProps): JSX.Element {
+export function ProductEmptyState({ config, mode, preview = false }: ProductEmptyStateProps): JSX.Element {
const wizard = resolveWizard(config.wizard, mode)
const { wizardCommand, isCloudOrDev } = useWizardCommand(wizard?.slug, {
pinProjectId: wizard?.pinProjectId,
})
- const { skipEmptyState } = useActions(productSetupStatusLogic({ productKey: config.productKey }))
+ const { skipEmptyState, reportSetupShown, reportSetupInteraction } = useActions(
+ productSetupStatusLogic({ productKey: config.productKey })
+ )
+ const { currentTeam } = useValues(teamLogic)
+ const projectUuid = currentTeam?.uuid
+
+ useEffect(() => {
+ reportSetupShown(mode, preview)
+ }, [mode, preview, projectUuid, reportSetupShown])
const captureClick = (action: string): void => {
- posthog.capture(`product empty state ${action}`, { product_key: config.productKey, mode })
+ const route =
+ action === 'wizard command copied' ? 'wizard' : action === 'manual setup clicked' ? 'manual' : null
+ reportSetupInteraction(action, mode, route, preview)
}
// Mode-specific text overrides the base; missing fields fall back to it.
@@ -218,6 +230,8 @@ export function ProductEmptyState({ config, mode }: ProductEmptyStateProps): JSX
{callToAction}
+ {config.SetupActions ? <config.SetupActions mode={mode} preview={preview} /> : null}
+
{config.statusIndicator ? <div className="text-xs">{config.statusIndicator}</div> : null}
<div className="flex flex-wrap items-center gap-x-4 gap-y-2">
diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.tsx
index 93fe6dc9e883..25a38baa25d0 100644
--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.tsx
+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.tsx
@@ -108,7 +108,7 @@ function ProductEmptyStateGateInner({ emptyState, children }: ProductEmptyStateG
if (forcedMode) {
return (
<ProductSceneFrame config={config}>
- <ProductEmptyState config={config} mode={forcedMode} />
+ <ProductEmptyState config={config} mode={forcedMode} preview />
</ProductSceneFrame>
)
}
diff --git a/frontend/src/lib/components/ProductEmptyState/productSetupStatusLogic.test.ts b/frontend/src/lib/components/ProductEmptyState/productSetupStatusLogic.test.ts
index 7f03f2ad7174..d7e63175b04b 100644
--- a/frontend/src/lib/components/ProductEmptyState/productSetupStatusLogic.test.ts
+++ b/frontend/src/lib/components/ProductEmptyState/productSetupStatusLogic.test.ts
@@ -1,4 +1,5 @@
import { expectLogic } from 'kea-test-utils'
+import posthog from 'posthog-js'
import { teamLogic } from 'scenes/teamLogic'
@@ -11,6 +12,7 @@ describe('productSetupStatusLogic', () => {
beforeEach(() => {
localStorage.clear()
initKeaTests()
+ jest.spyOn(posthog, 'capture').mockClear()
})
function mountLogic(): ReturnType<typeof productSetupStatusLogic.build> {
@@ -19,6 +21,69 @@ describe('productSetupStatusLogic', () => {
return logic
}
+ it('keeps setup attribution across route changes and reports data only once', () => {
+ const logic = mountLogic()
+ logic.actions.setDetectedStatus('needs-setup')
+ logic.actions.reportSetupShown('needs-setup')
+ logic.actions.reportSetupInteraction('wizard command copied', 'needs-setup', 'wizard')
+ logic.actions.reportSetupInteraction('agent prompt copied', 'needs-setup', 'agent')
+
+ expect(posthog.capture).toHaveBeenLastCalledWith(
+ 'product empty state agent prompt copied',
+ expect.objectContaining({
+ setup_attempt_id: expect.any(String),
+ initial_setup_route: 'wizard',
+ setup_route: 'agent',
+ })
+ )
+ const attemptId = logic.values.setupAttempt?.id
+ logic.actions.setDetectedStatus('has-data')
+ logic.actions.setDetectedStatus('has-data')
+ const detected = jest
+ .mocked(posthog.capture)
+ .mock.calls.filter(([event]) => event === 'product empty state data detected')
+ expect(detected).toHaveLength(1)
+ expect(detected[0][1]).toMatchObject({
+ setup_attempt_id: attemptId,
+ initial_setup_route: 'wizard',
+ setup_route: 'agent',
+ })
+ })
+
+ it('does not count forced previews or existing data as setup', () => {
+ const logic = mountLogic()
+ logic.actions.reportSetupShown('needs-setup', true)
+ logic.actions.reportSetupInteraction('agent prompt copied', 'needs-setup', 'agent', true)
+ logic.actions.setDetectedStatus('has-data')
+ expect(logic.values.setupAttempt).toBeNull()
+ expect(posthog.capture).not.toHaveBeenCalled()
+ })
+
+ it('keeps the same attempt after remounting setup', () => {
+ const logic = productSetupStatusLogic({ productKey: ProductKey.MCP_ANALYTICS })
+ const unmount = logic.mount()
+ logic.actions.reportSetupShown('needs-setup')
+ logic.actions.reportSetupInteraction('manual setup clicked', 'needs-setup', 'manual')
+ const attemptId = logic.values.setupAttempt?.id
+ unmount()
+
+ const remounted = mountLogic()
+ remounted.actions.reportSetupShown('needs-setup')
+ expect(remounted.values.setupAttempt).toMatchObject({ id: attemptId, initialRoute: 'manual' })
+ })
+
+ it('does not attribute data from a project with the same numeric ID to the current setup attempt', () => {
+ const logic = mountLogic()
+ logic.actions.reportSetupShown('needs-setup')
+ const otherTeam = { ...teamLogic.values.currentTeam!, uuid: '00000000-0000-4000-8000-000000000123' }
+ teamLogic.actions.loadCurrentTeamSuccess(otherTeam)
+ logic.actions.setDetectedStatus('has-data')
+ expect(logic.values.setupAttempt).toBeNull()
+ expect(
+ jest.mocked(posthog.capture).mock.calls.filter(([event]) => event === 'product empty state data detected')
+ ).toHaveLength(0)
+ })
+
// Guards the skip path end to end: a broken skip either traps users on the
// empty state or (worse) permanently hides it for users who never skipped. The gate
// decides from `skipped` and `status` together, so both have to move independently.
diff --git a/frontend/src/lib/components/ProductEmptyState/productSetupStatusLogic.ts b/frontend/src/lib/components/ProductEmptyState/productSetupStatusLogic.ts
index d14212c4912c..d1d92b61309a 100644
--- a/frontend/src/lib/components/ProductEmptyState/productSetupStatusLogic.ts
+++ b/frontend/src/lib/components/ProductEmptyState/productSetupStatusLogic.ts
@@ -1,10 +1,14 @@
import { MakeLogicType, actions, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import posthog from 'posthog-js'
+import { v4 as uuid } from 'uuid'
import { teamLogic } from 'scenes/teamLogic'
+import { userLogic } from 'scenes/userLogic'
import type { ProductKey } from '~/queries/schema/schema-general'
+import type { TeamType } from '~/types'
+import type { TeamPublicType } from '../../../types'
import type { ProductEmptyStateMode, ProductSetupStatus } from './types'
export interface ProductSetupStatusLogicProps {
@@ -16,11 +20,24 @@ interface DetectedStatus {
teamId: number | null
}
+export type ProductSetupRoute = 'wizard' | 'agent' | 'manual'
+
+interface SetupAttempt {
+ id: string
+ initialRoute: ProductSetupRoute | null
+ route: ProductSetupRoute | null
+ completed: boolean
+}
+
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface productSetupStatusLogicValues {
+ currentTeam: TeamPublicType | TeamType | null // teamLogic
currentTeamId: number | null // teamLogic
detected: DetectedStatus
mode: ProductEmptyStateMode
+ setupAttempt: SetupAttempt | null
+ setupAttemptsByProject: Record<string, SetupAttempt>
+ setupProjectKey: string | null
skipped: boolean
skippedByTeam: Record<number, boolean>
status: ProductSetupStatus
@@ -35,9 +52,44 @@ export interface productSetupStatusLogicActions {
status: ProductSetupStatus
teamId: number | null
}
+ reportSetupInteraction: (
+ action: string,
+ mode: ProductEmptyStateMode,
+ route?: ProductSetupRoute | null,
+ preview?: boolean,
+ wizardSession?: {
+ phase: string
+ session_id: string
+ }
+ ) => {
+ action: string
+ mode: ProductEmptyStateMode
+ preview: boolean
+ route: ProductSetupRoute | null
+ wizardSession:
+ | {
+ phase: string
+ session_id: string
+ }
+ | undefined
+ }
+ reportSetupShown: (
+ mode: ProductEmptyStateMode,
+ preview?: boolean
+ ) => {
+ mode: ProductEmptyStateMode
+ preview: boolean
+ }
setDetectedStatus: (status: ProductSetupStatus) => {
status: ProductSetupStatus
}
+ setSetupAttempt: (
+ projectKey: string,
+ attempt: SetupAttempt
+ ) => {
+ attempt: SetupAttempt
+ projectKey: string
+ }
setSkippedForTeam: (
teamId: number,
skipped: boolean
@@ -57,6 +109,11 @@ export interface productSetupStatusLogicActions {
export interface productSetupStatusLogicMeta {
key: ProductKey
__keaTypeGenInternalSelectorTypes: {
+ setupProjectKey: (currentTeam: TeamPublicType | TeamType | null) => string | null
+ setupAttempt: (
+ setupAttemptsByProject: Record<string, SetupAttempt>,
+ setupProjectKey: string | null
+ ) => SetupAttempt | null
status: (detected: DetectedStatus, currentTeamId: number | null) => ProductSetupStatus
skipped: (skippedByTeam: Record<number, boolean>, currentTeamId: number | null) => boolean
mode: (status: ProductSetupStatus) => ProductEmptyStateMode
@@ -96,15 +153,29 @@ export const productSetupStatusLogic = kea<productSetupStatusLogicType>([
return props.productKey
}),
path((key) => ['lib', 'components', 'ProductEmptyState', 'productSetupStatusLogic', key]),
- connect(() => ({ values: [teamLogic, ['currentTeamId']] })),
+ connect(() => ({ values: [teamLogic, ['currentTeamId', 'currentTeam']] })),
actions({
setDetectedStatus: (status: ProductSetupStatus) => ({ status }),
applyDetectedStatus: (status: ProductSetupStatus, teamId: number | null) => ({ status, teamId }),
skipEmptyState: true,
unskipEmptyState: true,
setSkippedForTeam: (teamId: number, skipped: boolean) => ({ teamId, skipped }),
+ setSetupAttempt: (projectKey: string, attempt: SetupAttempt) => ({ projectKey, attempt }),
+ reportSetupShown: (mode: ProductEmptyStateMode, preview: boolean = false) => ({ mode, preview }),
+ reportSetupInteraction: (
+ action: string,
+ mode: ProductEmptyStateMode,
+ route: ProductSetupRoute | null = null,
+ preview: boolean = false,
+ wizardSession?: { session_id: string; phase: string }
+ ) => ({ action, mode, route, preview, wizardSession }),
}),
reducers({
+ setupAttemptsByProject: [
+ {} as Record<string, SetupAttempt>,
+ { persist: true },
+ { setSetupAttempt: (state, { projectKey, attempt }) => ({ ...state, [projectKey]: attempt }) },
+ ],
// Stamped with the team the detection ran against, so a stale answer is
// never served across a project switch (see the `status` selector).
detected: [
@@ -123,6 +194,12 @@ export const productSetupStatusLogic = kea<productSetupStatusLogicType>([
],
}),
selectors({
+ setupProjectKey: [(s) => [s.currentTeam], (team: TeamType | null): string | null => team?.uuid ?? null],
+ setupAttempt: [
+ (s) => [s.setupAttemptsByProject, s.setupProjectKey],
+ (attempts: Record<string, SetupAttempt>, projectKey: string | null): SetupAttempt | null =>
+ projectKey ? (attempts[projectKey] ?? null) : null,
+ ],
// A detected status only counts for the team it was detected for; after a
// project switch we're back to `loading` until a detection (or the preload)
// answers for the new team.
@@ -143,6 +220,56 @@ export const productSetupStatusLogic = kea<productSetupStatusLogicType>([
],
}),
listeners(({ actions, values, props }) => ({
+ reportSetupShown: ({ mode, preview }) => {
+ actions.reportSetupInteraction('shown', mode, null, preview)
+ },
+ reportSetupInteraction: ({ action, mode, route, preview, wizardSession }) => {
+ if (
+ preview ||
+ !values.setupProjectKey ||
+ !values.currentTeamId ||
+ userLogic.findMounted()?.values.user?.is_impersonated
+ ) {
+ return
+ }
+ const attempt = values.setupAttempt ?? { id: uuid(), initialRoute: null, route: null, completed: false }
+ const updated = { ...attempt, initialRoute: attempt.initialRoute ?? route, route: route ?? attempt.route }
+ actions.setSetupAttempt(values.setupProjectKey, updated)
+ posthog.capture(`product empty state ${action}`, {
+ product_key: props.productKey,
+ project_id: values.currentTeamId,
+ project_uuid: values.setupProjectKey,
+ mode,
+ setup_attempt_id: updated.id,
+ initial_setup_route: updated.initialRoute,
+ setup_route: updated.route,
+ ...(wizardSession
+ ? { wizard_session_id: wizardSession.session_id, wizard_phase: wizardSession.phase }
+ : {}),
+ })
+ },
+ applyDetectedStatus: ({ status, teamId }) => {
+ const attempt = values.setupAttempt
+ if (
+ status === 'has-data' &&
+ teamId &&
+ teamId === values.currentTeamId &&
+ values.setupProjectKey &&
+ attempt &&
+ !attempt.completed &&
+ !userLogic.findMounted()?.values.user?.is_impersonated
+ ) {
+ actions.setSetupAttempt(values.setupProjectKey, { ...attempt, completed: true })
+ posthog.capture('product empty state data detected', {
+ product_key: props.productKey,
+ project_id: teamId,
+ project_uuid: values.setupProjectKey,
+ setup_attempt_id: attempt.id,
+ initial_setup_route: attempt.initialRoute,
+ setup_route: attempt.route,
+ })
+ }
+ },
setDetectedStatus: ({ status }) => {
// Detection answers more than once per session: several products poll while their
// scene is mounted. Once a status has put the real scene on screen, a later
diff --git a/frontend/src/lib/components/ProductEmptyState/storybookHelpers.tsx b/frontend/src/lib/components/ProductEmptyState/storybookHelpers.tsx
index dbbdfb5aabd9..a0a6eaa4cebb 100644
--- a/frontend/src/lib/components/ProductEmptyState/storybookHelpers.tsx
+++ b/frontend/src/lib/components/ProductEmptyState/storybookHelpers.tsx
@@ -41,7 +41,7 @@ export function productEmptyStateStory(
// Empty states show a persistent "listening for data" spinner (and animated preview)
// by design, so the snapshot runner must not wait for loaders to disappear here.
parameters: { testOptions: { waitForLoadersToDisappear: false } },
- args: { config: { ...emptyState.config, ...config }, mode },
+ args: { config: { ...emptyState.config, ...config }, mode, preview: true },
decorators: [
// The snapshot root is inline-block. Give the query container a width so
// inline-size containment cannot collapse that root to zero.
diff --git a/frontend/src/lib/components/ProductEmptyState/types.ts b/frontend/src/lib/components/ProductEmptyState/types.ts
index 84809675ad61..5a1c55846213 100644
--- a/frontend/src/lib/components/ProductEmptyState/types.ts
+++ b/frontend/src/lib/components/ProductEmptyState/types.ts
@@ -141,6 +141,8 @@ export interface ProductEmptyStateConfig {
* stays the hero and this renders under the "or" divider.
*/
PrimaryAction?: ComponentType
+ /** Product-specific installation options below the primary setup action. */
+ SetupActions?: ComponentType<{ mode: ProductEmptyStateMode; preview: boolean }>
docsUrl?: string
/** Target of the small "Or configure manually" link; falls back to `docsUrl` */
manualSetupUrl?: string
diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressContent.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressContent.tsx
index d73cb96a2210..dec60f99fdc6 100644
--- a/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressContent.tsx
+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressContent.tsx
@@ -27,6 +27,7 @@ const HedgehogWizard = pngHoggie(wizardPng)
export function InstallationProgressContent({
workflowId,
continueHint,
+ docsUrl = 'https://posthog.com/docs/getting-started/install',
progress,
mode,
onViewReport,
@@ -40,6 +41,7 @@ export function InstallationProgressContent({
workflowId?: string
/** Shown while the run is in flight, to say it keeps going if the user navigates away. */
continueHint?: ReactNode
+ docsUrl?: string
/** Opens the run's handoff doc (the setup report) — the completed state's payoff. Only rendered
* when the progress actually carries a doc. */
onViewReport?: () => void
@@ -200,11 +202,7 @@ export function InstallationProgressContent({
Run it yourself
</LemonButton>
)}
- <LemonButton
- type={onRetryLocally ? 'secondary' : 'primary'}
- to="https://posthog.com/docs/getting-started/install"
- targetBlank
- >
+ <LemonButton type={onRetryLocally ? 'secondary' : 'primary'} to={docsUrl} targetBlank>
Read the docs
</LemonButton>
</div>
diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.tsx
index e3e32161b1ba..474d2c66a266 100644
--- a/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.tsx
+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.tsx
@@ -19,6 +19,7 @@ export function InstallationProgressView({
taskId,
workflowId,
continueHint,
+ docsUrl,
floating = false,
onDismiss,
onRetryLocally,
@@ -31,6 +32,7 @@ export function InstallationProgressView({
workflowId?: string
/** Shown while the run is in flight, to say it keeps going if the user navigates away. */
continueHint?: ReactNode
+ docsUrl?: string
/** Rendered in the floating FAB rather than inline on the install step. */
floating?: boolean
onDismiss?: () => void
@@ -84,6 +86,7 @@ export function InstallationProgressView({
<InstallationProgressContent
workflowId={workflowId}
continueHint={continueHint}
+ docsUrl={docsUrl}
progress={installationProgress}
mode={mode}
onViewReport={handleViewReport}
diff --git a/products/mcp_analytics/frontend/emptyState/MCPAnalyticsSetupActions.tsx b/products/mcp_analytics/frontend/emptyState/MCPAnalyticsSetupActions.tsx
new file mode 100644
index 000000000000..8da6f07c378e
--- /dev/null
+++ b/products/mcp_analytics/frontend/emptyState/MCPAnalyticsSetupActions.tsx
@@ -0,0 +1,67 @@
+import { useActions, useValues } from 'kea'
+
+import { IconSparkles } from '@posthog/icons'
+import { LemonButton, LemonModal } from '@posthog/lemon-ui'
+
+import { CodeSnippet } from 'lib/components/CodeSnippet/CodeSnippet'
+import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'
+import type { ProductEmptyStateMode } from 'lib/components/ProductEmptyState/types'
+import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+
+import { mcpAnalyticsSetupLogic } from './mcpAnalyticsSetupLogic'
+import { MCPAnalyticsSetupProgress } from './MCPAnalyticsSetupProgress'
+
+export function MCPAnalyticsSetupActions({
+ mode,
+ preview,
+}: {
+ mode: ProductEmptyStateMode
+ preview: boolean
+}): JSX.Element {
+ const { agentPromptOpen, agentPrompt } = useValues(mcpAnalyticsSetupLogic)
+ const { setAgentPromptOpen } = useActions(mcpAnalyticsSetupLogic)
+ const { reportSetupInteraction } = useActions(productSetupStatusLogic({ productKey: ProductKey.MCP_ANALYTICS }))
+ const { isCloudOrDev } = useValues(preflightLogic)
+
+ return (
+ <>
+ <LemonButton
+ type="secondary"
+ icon={<IconSparkles />}
+ className="self-start"
+ data-attr="mcp-analytics-install-with-agent"
+ disabledReason={agentPrompt ? undefined : 'Select a project to get installation instructions.'}
+ onClick={() => {
+ setAgentPromptOpen(true)
+ reportSetupInteraction('agent instructions opened', mode, null, preview)
+ }}
+ >
+ Install with your agent
+ </LemonButton>
+ <LemonModal
+ title="Install with your coding agent"
+ isOpen={agentPromptOpen}
+ onClose={() => setAgentPromptOpen(false)}
+ width={640}
+ >
+ <p>Open the repository containing your MCP server in your coding agent, then paste this prompt.</p>
+ <CodeSnippet
+ wrap
+ compact
+ maxLinesWithoutExpansion={5}
+ thing="installation prompt"
+ onCopy={() => reportSetupInteraction('agent prompt copied', mode, 'agent', preview)}
+ >
+ {agentPrompt}
+ </CodeSnippet>
+ <p className="text-secondary mt-4 mb-0">
+ After setup, call an existing tool from your server. This page updates when its tool-call event
+ arrives.
+ </p>
+ </LemonModal>
+ {isCloudOrDev && !preview ? <MCPAnalyticsSetupProgress mode={mode} /> : null}
+ </>
+ )
+}
diff --git a/products/mcp_analytics/frontend/emptyState/MCPAnalyticsSetupProgress.tsx b/products/mcp_analytics/frontend/emptyState/MCPAnalyticsSetupProgress.tsx
new file mode 100644
index 000000000000..18e47b0f1e3a
--- /dev/null
+++ b/products/mcp_analytics/frontend/emptyState/MCPAnalyticsSetupProgress.tsx
@@ -0,0 +1,36 @@
+import { useActions, useValues } from 'kea'
+import { useEffect } from 'react'
+
+import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'
+import type { ProductEmptyStateMode } from 'lib/components/ProductEmptyState/types'
+import { installationProgressLogic } from 'scenes/onboarding/shared/wizard-sync/installationProgressLogic'
+import { InstallationProgressView } from 'scenes/onboarding/shared/wizard-sync/InstallationProgressView'
+import { teamLogic } from 'scenes/teamLogic'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+
+export function MCPAnalyticsSetupProgress({ mode }: { mode: ProductEmptyStateMode }): JSX.Element | null {
+ const { installationProgress, latestSession } = useValues(
+ installationProgressLogic({ mode: 'local', workflowId: 'mcp-analytics' })
+ )
+ const { reportSetupInteraction } = useActions(productSetupStatusLogic({ productKey: ProductKey.MCP_ANALYTICS }))
+ const sessionId = latestSession?.session_id
+ const { isCurrent, phase } = installationProgress
+ const { currentTeamId } = useValues(teamLogic)
+ const matchesProject = latestSession?.team_id === currentTeamId
+
+ useEffect(() => {
+ if (isCurrent && matchesProject && sessionId) {
+ reportSetupInteraction('wizard session observed', mode, null, false, { session_id: sessionId, phase })
+ }
+ }, [isCurrent, matchesProject, sessionId, phase, mode, reportSetupInteraction])
+
+ return isCurrent && matchesProject ? (
+ <InstallationProgressView
+ mode="local"
+ workflowId="mcp-analytics"
+ docsUrl="https://posthog.com/docs/mcp-analytics/installation"
+ continueHint="After setup, call an existing tool from your server to verify that its event arrives here."
+ />
+ ) : null
+}
diff --git a/products/mcp_analytics/frontend/emptyState/mcpAnalyticsEmptyState.tsx b/products/mcp_analytics/frontend/emptyState/mcpAnalyticsEmptyState.tsx
index 659511230adb..ffcd99eb42cd 100644
--- a/products/mcp_analytics/frontend/emptyState/mcpAnalyticsEmptyState.tsx
+++ b/products/mcp_analytics/frontend/emptyState/mcpAnalyticsEmptyState.tsx
@@ -9,6 +9,7 @@ import { ProductKey } from '~/queries/schema/schema-general'
import { mcpAnalyticsOnboardingLogic } from '../mcpAnalyticsOnboardingLogic'
import { MCP_ANALYTICS_DOCS_URL, MCPListeningIndicator } from '../onboarding/MCPAnalyticsInstall'
+import { MCPAnalyticsSetupActions } from './MCPAnalyticsSetupActions'
import { MCPToolCallPreview } from './MCPToolCallPreview'
const HedgehogRobot = pngHoggie(robotPng)
@@ -28,7 +29,7 @@ export const mcpAnalyticsEmptyState: SceneProductEmptyState = {
'needs-setup': {
headline: 'Know how agents actually use your tools',
lead: 'Capture every MCP tool call, argument and result, so you can see which tools agents reach for, where they fail, and how long each call takes.',
- hint: 'Point the wizard at your MCP server. LLM inference is on us, no API key needed:',
+ hint: 'Run Wizard in the repository containing your MCP server. The setup agent installs analytics for you:',
},
'waiting-for-data': {
headline: "You're connected. Now make a tool call",
@@ -37,6 +38,7 @@ export const mcpAnalyticsEmptyState: SceneProductEmptyState = {
},
},
wizard: { slug: 'mcp-analytics', pinProjectId: true },
+ SetupActions: MCPAnalyticsSetupActions,
docsUrl: MCP_ANALYTICS_DOCS_URL,
manualSetupUrl: 'https://posthog.com/docs/mcp-analytics/installation',
previewLabel: 'Tool calls, once connected',
diff --git a/products/mcp_analytics/frontend/emptyState/mcpAnalyticsSetupLogic.ts b/products/mcp_analytics/frontend/emptyState/mcpAnalyticsSetupLogic.ts
new file mode 100644
index 000000000000..f7d879340bad
--- /dev/null
+++ b/products/mcp_analytics/frontend/emptyState/mcpAnalyticsSetupLogic.ts
@@ -0,0 +1,51 @@
+import { MakeLogicType, actions, connect, kea, path, reducers, selectors } from 'kea'
+
+import { getBackendHost } from 'lib/oauth/oauthClient'
+import { teamLogic } from 'scenes/teamLogic'
+
+import type { TeamType } from '~/types'
+
+import type { TeamPublicType } from '../../../../frontend/src/types'
+import { mcpAnalyticsSetupPrompt } from './mcpAnalyticsSetupPrompt'
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface mcpAnalyticsSetupLogicValues {
+ currentTeam: TeamPublicType | TeamType | null // teamLogic
+ agentPrompt: string | null
+ agentPromptOpen: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface mcpAnalyticsSetupLogicActions {
+ setAgentPromptOpen: (open: boolean) => {
+ open: boolean
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface mcpAnalyticsSetupLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ agentPrompt: (currentTeam: TeamPublicType | TeamType | null) => string | null
+ }
+}
+
+export type mcpAnalyticsSetupLogicType = MakeLogicType<
+ mcpAnalyticsSetupLogicValues,
+ mcpAnalyticsSetupLogicActions,
+ Record<string, any>,
+ mcpAnalyticsSetupLogicMeta
+>
+
+export const mcpAnalyticsSetupLogic = kea<mcpAnalyticsSetupLogicType>([
+ path(['products', 'mcp_analytics', 'frontend', 'emptyState', 'mcpAnalyticsSetupLogic']),
+ connect(() => ({ values: [teamLogic, ['currentTeam']] })),
+ actions({ setAgentPromptOpen: (open: boolean) => ({ open }) }),
+ reducers({ agentPromptOpen: [false, { setAgentPromptOpen: (_, { open }) => open }] }),
+ selectors({
+ agentPrompt: [
+ (s) => [s.currentTeam],
+ (team: TeamPublicType | TeamType | null): string | null =>
+ team ? mcpAnalyticsSetupPrompt(team.id, getBackendHost() || window.location.origin) : null,
+ ],
+ }),
+])
diff --git a/products/mcp_analytics/frontend/emptyState/mcpAnalyticsSetupPrompt.test.ts b/products/mcp_analytics/frontend/emptyState/mcpAnalyticsSetupPrompt.test.ts
new file mode 100644
index 000000000000..51e5089ca3cb
--- /dev/null
+++ b/products/mcp_analytics/frontend/emptyState/mcpAnalyticsSetupPrompt.test.ts
@@ -0,0 +1,13 @@
+import { mcpAnalyticsSetupPrompt } from './mcpAnalyticsSetupPrompt'
+
+describe('mcpAnalyticsSetupPrompt', () => {
+ it.each(['https://us.posthog.com', 'https://eu.posthog.com', 'https://analytics.example.com'])(
+ 'targets the selected project on %s',
+ (origin) => {
+ const prompt = mcpAnalyticsSetupPrompt(123, origin)
+ expect(prompt).toContain(`project 123 at ${origin}`)
+ expect(prompt).toContain(`${origin}/project/123/mcp-analytics/activity`)
+ expect(prompt).not.toContain('/project/2/')
+ }
+ )
+})
diff --git a/products/mcp_analytics/frontend/emptyState/mcpAnalyticsSetupPrompt.ts b/products/mcp_analytics/frontend/emptyState/mcpAnalyticsSetupPrompt.ts
new file mode 100644
index 000000000000..ccb4e4717a05
--- /dev/null
+++ b/products/mcp_analytics/frontend/emptyState/mcpAnalyticsSetupPrompt.ts
@@ -0,0 +1,15 @@
+export function mcpAnalyticsSetupPrompt(projectId: number, appUrl: string): string {
+ const projectUrl = new URL(`/project/${projectId}/mcp-analytics/activity`, appUrl).href
+
+ return `Install PostHog MCP analytics in the MCP server in this repository.
+Target PostHog project ${projectId} at ${appUrl}.
+Read https://posthog.com/docs/mcp-analytics/installation.md first and follow the instructions for this server's language, framework, and SDK version.
+
+Locate the existing MCP server entry point before editing. If you cannot find a server, explain which directories you checked and ask me for the correct directory. This task instruments my server; it does not install the PostHog MCP connector or create a new server.
+
+Confirm the matching ingestion host and project token. Use the repository's environment configuration for credentials; ask me for missing configuration without putting secrets in source code or terminal output.
+
+Make the smallest necessary change, including flushing events correctly for this runtime. Run the relevant checks, then help me invoke an existing safe, read-only tool. Verify that its $mcp_tool_call arrives in the target project and comes from the server you instrumented. An initialize event is optional and is not enough to verify installation.
+
+Open ${projectUrl} to inspect the call. If you cannot access the project, give me the verification steps and mark verification as pending. Report the files changed and any remaining restart or deployment steps. Only report verification as complete after the tool-call event is observed.`
+}
diff --git a/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.test.ts b/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.test.ts
index 6a675475d871..eb334629e6be 100644
--- a/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.test.ts
+++ b/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.test.ts
@@ -2,6 +2,7 @@ import { expectLogic } from 'kea-test-utils'
import api from 'lib/api'
import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'
+import { teamLogic } from 'scenes/teamLogic'
import { ProductKey } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
@@ -15,6 +16,7 @@ const mockApi = api as jest.Mocked<typeof api>
// Signal row shape: [has_initialize, tool_calls_total, tool_calls_7d, first_call_at]
describe('mcpAnalyticsOnboardingLogic', () => {
beforeEach(() => {
+ localStorage.clear()
jest.clearAllMocks()
initKeaTests()
})
@@ -103,4 +105,41 @@ describe('mcpAnalyticsOnboardingLogic', () => {
await expectLogic(logic).toFinishAllListeners()
expect(productSetupStatusLogic({ productKey: ProductKey.MCP_ANALYTICS }).values.status).toBe('has-data')
})
+
+ it.each(['success', 'failure'] as const)(
+ 'ignores a signal query %s from a previous project without completing the new setup attempt',
+ async (outcome) => {
+ let resolveQuery!: (response: any) => void
+ let rejectQuery!: (error: Error) => void
+ mockApi.query.mockReturnValueOnce(
+ new Promise((resolve, reject) => {
+ resolveQuery = resolve
+ rejectQuery = reject
+ })
+ )
+ const logic = mcpAnalyticsOnboardingLogic()
+ logic.mount()
+ const setupLogic = productSetupStatusLogic({ productKey: ProductKey.MCP_ANALYTICS })
+ teamLogic.actions.loadCurrentTeamSuccess({
+ ...teamLogic.values.currentTeam!,
+ id: teamLogic.values.currentTeamId! + 1,
+ uuid: '00000000-0000-4000-8000-000000000456',
+ })
+ setupLogic.actions.reportSetupShown('needs-setup')
+ const attemptId = setupLogic.values.setupAttempt!.id
+
+ if (outcome === 'success') {
+ resolveQuery({ results: [[1, 1, 1, '2026-07-01T00:00:00Z']] })
+ } else {
+ rejectQuery(new Error('previous project query failed'))
+ }
+ await expectLogic(logic).toFinishAllListeners()
+ expect(setupLogic.values.status).toBe('loading')
+ expect(setupLogic.values.setupAttempt).toMatchObject({ id: attemptId, completed: false })
+
+ mockApi.query.mockResolvedValue({ results: [[1, 1, 1, '2026-07-01T00:00:00Z']] } as any)
+ await expectLogic(logic, () => logic.actions.loadSignals()).toFinishAllListeners()
+ expect(setupLogic.values.setupAttempt).toMatchObject({ id: attemptId, completed: true })
+ }
+ )
})
diff --git a/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.ts b/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.ts
index bd9f0a705e90..ed43ce6bc585 100644
--- a/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.ts
+++ b/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.ts
@@ -5,6 +5,7 @@ import api from 'lib/api'
import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'
import type { ProductSetupStatus } from 'lib/components/ProductEmptyState/types'
import { addProductIntent } from 'lib/utils/product-intents'
+import { teamLogic } from 'scenes/teamLogic'
import { userLogic } from 'scenes/userLogic'
import { HogQLQueryResponse, NodeKind, ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
@@ -107,10 +108,10 @@ export interface mcpAnalyticsOnboardingLogicActions {
errorObject?: any
}
loadSignalsSuccess: (
- signals: MCPOnboardingSignals,
+ signals: MCPOnboardingSignals | null,
payload?: void
) => {
- signals: MCPOnboardingSignals
+ signals: MCPOnboardingSignals | null
payload?: void
}
}
@@ -140,7 +141,8 @@ export const mcpAnalyticsOnboardingLogic = kea<mcpAnalyticsOnboardingLogicType>(
loaders({
signals: {
__default: null as MCPOnboardingSignals | null,
- loadSignals: async (_: void, breakpoint): Promise<MCPOnboardingSignals> => {
+ loadSignals: async (_: void, breakpoint): Promise<MCPOnboardingSignals | null> => {
+ const projectUuid = teamLogic.values.currentTeam?.uuid
// Force a fresh calculation instead of reading a cached result. The first
// events on a new project land a beat after capture returns 200, so a poll
// during that gap caches `[0,0]` — and with the default cache TTL the page
@@ -150,14 +152,25 @@ export const mcpAnalyticsOnboardingLogic = kea<mcpAnalyticsOnboardingLogicType>(
// graduates to the full dashboard (see loadSignalsSuccess), so this is bounded
// to the onboarding + activity window, and the query itself is cheap (event-name
// counts on the sort key).
- const response = (await api.query(
- {
- kind: NodeKind.HogQLQuery,
- query: ONBOARDING_SIGNAL_QUERY,
- },
- { refresh: 'force_blocking' }
- )) as HogQLQueryResponse
+ const response = (await api
+ .query(
+ {
+ kind: NodeKind.HogQLQuery,
+ query: ONBOARDING_SIGNAL_QUERY,
+ },
+ { refresh: 'force_blocking' }
+ )
+ .catch((error: unknown) => {
+ breakpoint()
+ if (projectUuid !== teamLogic.values.currentTeam?.uuid) {
+ return null
+ }
+ throw error
+ })) as HogQLQueryResponse | null
breakpoint()
+ if (projectUuid !== teamLogic.values.currentTeam?.uuid) {
+ return null
+ }
const row = (response?.results?.[0] as unknown[] | undefined) ?? []
const toolCallsTotal = asNumber(row[1])
return {
@@ -216,7 +229,10 @@ export const mcpAnalyticsOnboardingLogic = kea<mcpAnalyticsOnboardingLogicType>(
actions.setDetectedStatus('unknown')
}
},
- loadSignalsSuccess: () => {
+ loadSignalsSuccess: ({ signals }) => {
+ if (!signals) {
+ return
+ }
// Feed the app-wide setup-status layer (drives the scene empty-state gate).
actions.setDetectedStatus(emptyStateStatusForOnboardingState(values.onboardingState))
diff --git a/products/mcp_analytics/frontend/onboarding/MCPAnalyticsInstall.tsx b/products/mcp_analytics/frontend/onboarding/MCPAnalyticsInstall.tsx
index 4dc2a5d2ba46..93171f6a7e0d 100644
--- a/products/mcp_analytics/frontend/onboarding/MCPAnalyticsInstall.tsx
+++ b/products/mcp_analytics/frontend/onboarding/MCPAnalyticsInstall.tsx
@@ -27,7 +27,7 @@ export function MCPListeningIndicator(): JSX.Element {
return (
<div className="flex items-center gap-2 text-success">
<IconCheckCircle className="text-lg" />
- <span>Tool calls are flowing — you're all set.</span>
+ <span>Tool calls are flowing. You're all set.</span>
</div>
)
}
@@ -35,14 +35,14 @@ export function MCPListeningIndicator(): JSX.Element {
return (
<div className="flex items-center gap-2 text-secondary">
<IconCheckCircle className="text-lg text-success" />
- <span>Server connected — waiting for the first tool call…</span>
+ <span>Server connected. Call an existing tool from your agent to verify event delivery.</span>
</div>
)
}
return (
<div className="flex items-center gap-2 text-secondary">
<Spinner />
- <span>Listening for your first MCP event…</span>
+ <span>Waiting for a tool call. After setup, call an existing tool from your agent.</span>
</div>
)
}