: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(mcp-analytics): track onboarding activation via product intents (#67182)
Lucas Faria9da2357c41ee
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex f8cc5546a2e5..c61b78263cf1 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -32184,6 +32184,8 @@"llm_dataset_created","llm_evaluation_created","llm_prompt_created",+ "mcp_analytics_viewed",+ "mcp_analytics_connected","logs_docs_viewed","logs_set_filters","logs_settings_opened",diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex 79378746265a..d0c522572137 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -7787,6 +7787,10 @@ export enum ProductIntentContext {LLM_EVALUATION_CREATED = 'llm_evaluation_created',LLM_PROMPT_CREATED = 'llm_prompt_created',+ // MCP Analytics+ MCP_ANALYTICS_VIEWED = 'mcp_analytics_viewed',+ MCP_ANALYTICS_CONNECTED = 'mcp_analytics_connected',+// LogsLOGS_DOCS_VIEWED = 'logs_docs_viewed',LOGS_SET_FILTERS = 'logs_set_filters',diff --git a/posthog/models/product_intent/product_intent.py b/posthog/models/product_intent/product_intent.pyindex 4d2c2b71e067..d49b2a542c0c 100644--- a/posthog/models/product_intent/product_intent.py+++ b/posthog/models/product_intent/product_intent.py@@ -206,6 +206,24 @@ class ProductIntent(UUIDTModel, RootTeamMixin):# Activated when the user has engaged with the dashboard (15s dwell) or viewed a tracereturn contexts.get("llm_analytics_viewed", 0) >= 1 or contexts.get("llm_analytics_trace_viewed", 0) >= 1+ def has_activated_mcp_analytics(self) -> bool:+ # The instrumented MCP server is sending tool calls (registers the $mcp_tool_call+ # definition in this team) and the user has opened the dashboard at least once.+ has_tool_call = EventDefinition.objects.filter(team=self.team, name="$mcp_tool_call").exists()+ if not has_tool_call:+ return False++ intent = ProductIntent.objects.filter(+ team=self.team,+ product_type="mcp_analytics",+ ).first()++ if not intent:+ return False++ contexts = intent.contexts or {}+ return contexts.get("mcp_analytics_viewed", 0) >= 1+def has_activated_workflows(self) -> bool:# At least one workflow needs to be active (not just drafted)return HogFlow.objects.filter(team=self.team, status=HogFlow.State.ACTIVE).exists()@@ -228,6 +246,7 @@ class ProductIntent(UUIDTModel, RootTeamMixin):"product_analytics": self.has_activated_product_analytics,"surveys": self.has_activated_surveys,"llm_analytics": self.has_activated_llm_analytics,+ "mcp_analytics": self.has_activated_mcp_analytics,"workflows": self.has_activated_workflows,}diff --git a/posthog/models/test/test_product_intent.py b/posthog/models/test/test_product_intent.pyindex 617cfad4c750..5260138d9143 100644--- a/posthog/models/test/test_product_intent.py+++ b/posthog/models/test/test_product_intent.py@@ -771,6 +771,40 @@ class TestProductIntent(BaseTest):assert self.product_intent.has_activated_llm_analytics() is False+ def _make_mcp_tool_call_event_definition(self) -> EventDefinition:+ return EventDefinition.objects.create(team=self.team, name="$mcp_tool_call")++ def _make_mcp_intent(self, contexts: dict) -> ProductIntent:+ ProductIntent.objects.filter(team=self.team, product_type=ProductKey.MCP_ANALYTICS).delete()+ return ProductIntent.objects.create(+ team=self.team,+ product_type=ProductKey.MCP_ANALYTICS,+ contexts=contexts,+ )++ def test_has_activated_mcp_analytics_with_tool_calls_and_dashboard_viewed(self):+ self._make_mcp_tool_call_event_definition()+ intent = self._make_mcp_intent({"mcp_analytics_viewed": 1})++ assert intent.has_activated_mcp_analytics() is True++ def test_has_not_activated_mcp_analytics_without_tool_calls(self):+ intent = self._make_mcp_intent({"mcp_analytics_viewed": 5})++ assert intent.has_activated_mcp_analytics() is False++ def test_has_not_activated_mcp_analytics_with_tool_calls_but_no_engagement(self):+ self._make_mcp_tool_call_event_definition()+ intent = self._make_mcp_intent({})++ assert intent.has_activated_mcp_analytics() is False++ def test_has_not_activated_mcp_analytics_without_intent(self):+ self._make_mcp_tool_call_event_definition()+ ProductIntent.objects.filter(team=self.team, product_type=ProductKey.MCP_ANALYTICS).delete()++ assert self.product_intent.has_activated_mcp_analytics() is False+def test_has_activated_workflows_with_active_workflow(self):self.product_intent.product_type = ProductKey.WORKFLOWSself.product_intent.save()diff --git a/posthog/schema_enums.py b/posthog/schema_enums.pyindex 9ab662c61078..861f983c4d03 100644--- a/posthog/schema_enums.py+++ b/posthog/schema_enums.py@@ -2647,6 +2647,8 @@ class ProductIntentContext(StrEnum):LLM_DATASET_CREATED = "llm_dataset_created"LLM_EVALUATION_CREATED = "llm_evaluation_created"LLM_PROMPT_CREATED = "llm_prompt_created"+ MCP_ANALYTICS_VIEWED = "mcp_analytics_viewed"+ MCP_ANALYTICS_CONNECTED = "mcp_analytics_connected"LOGS_DOCS_VIEWED = "logs_docs_viewed"LOGS_SET_FILTERS = "logs_set_filters"LOGS_SETTINGS_OPENED = "logs_settings_opened"diff --git a/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.ts b/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.tsindex db974085d787..852085434d5f 100644--- a/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.ts+++ b/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.ts@@ -2,8 +2,9 @@ import { afterMount, kea, listeners, path, selectors } from 'kea'import { loaders } from 'kea-loaders'import api from 'lib/api'+import { addProductIntent } from 'lib/utils/product-intents'-import { HogQLQueryResponse, NodeKind } from '~/queries/schema/schema-general'+import { HogQLQueryResponse, NodeKind, ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'import type { mcpAnalyticsOnboardingLogicType } from './mcpAnalyticsOnboardingLogicType'@@ -84,6 +85,17 @@ export const mcpAnalyticsOnboardingLogic = kea<mcpAnalyticsOnboardingLogicType>(}),listeners(({ values, cache }) => ({loadSignalsSuccess: () => {+ // Mark the diagnostic middle of the funnel: the SDK is connected but no+ // tool calls have landed yet. Separates an install problem (never+ // instrumented) from a traffic problem (wired up, but the server isn't+ // being called). Registered once per mount so the poll doesn't repeat it.+ if (values.onboardingState === 'connected-no-calls' && !cache.registeredConnected) {+ cache.registeredConnected = true+ void addProductIntent({+ product_type: ProductKey.MCP_ANALYTICS,+ intent_context: ProductIntentContext.MCP_ANALYTICS_CONNECTED,+ })+ }// Once tool calls show up the gate flips for good — stop polling.if (values.isOnboarded) {cache.disposables.dispose('poll')@@ -92,6 +104,12 @@ export const mcpAnalyticsOnboardingLogic = kea<mcpAnalyticsOnboardingLogicType>(})),afterMount(({ actions, cache }) => {actions.loadSignals()+ // Register product intent so activation lands in the standard cross-customer+ // funnel (`has_activated_mcp_analytics` flips once tool calls arrive too).+ void addProductIntent({+ product_type: ProductKey.MCP_ANALYTICS,+ intent_context: ProductIntentContext.MCP_ANALYTICS_VIEWED,+ })cache.disposables.add(() => {const id = window.setInterval(() => actions.loadSignals(), POLL_INTERVAL_MS)return () => clearInterval(id)