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(mcp-analytics): skip product intent during impersonation (#71903)

Georgis Andonisb7d2b5546344
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 2f0ffd55ed8a..c3db053a2cef 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -409,9 +409,9 @@ snapshots:
components-definition-popover--action--light:
hash: v1.k794b7964.f4bdb784a34e7a4af0c33043858f96c15234c1a161a635ad793ac749159d2fd2.xZjT6j6vvsEbrfG4iwhv0aoiOumGvVSJajzL3CNmZ8w
components-definition-popover--data-warehouse-column-mapping--dark:
- hash: v1.k794b7964.c38f182b346c519d1332cfd066782c3b4b9e0b5661fbe926253da902fc3c388b.micG7HfZSdoQxZl9DsRJk9wX2So89qflq-sxr9DYS4A
+ hash: v1.k794b7964.0ee1ae1caf0ca944fb346482ec211be87e2d9d60bdd8a2a9d77dd912ba1d8478.uULoWLevn28NDuEgq5QLrfOFU9pnVjHLjlDscwW9Q9E
components-definition-popover--data-warehouse-column-mapping--light:
- hash: v1.k794b7964.3201bcfb76a5bc9e9144f88ccb819af400442196804dc0ab84e1ecac6e141e28.U68Q077AoH6AtdHda3iCWWJelz2JyHqHs8JpJA_Onao
+ hash: v1.k794b7964.af82e8d5620ef50e40b5d55f260024fd9247480883ddd2a2ba2718f7cf8396ba.IcUjNqlNOxFbqF93utorC6_HCChPGXD7bVi7i8YckEE
components-definition-popover--event--dark:
hash: v1.k794b7964.4a10c0206e60aa629075aac850bcebdb2b5980a7d6953926911f1ebb7114a96e.Cpyg354rVEyXVrlBzOsJJGSmwPL4-YEhXboxDPMVY_s
components-definition-popover--event--light:
diff --git a/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.ts b/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.ts
index 1bc72416039a..bd2163ed3718 100644
--- a/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.ts
+++ b/products/mcp_analytics/frontend/mcpAnalyticsOnboardingLogic.ts
@@ -3,11 +3,19 @@ import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { addProductIntent } from 'lib/utils/product-intents'
+import { userLogic } from 'scenes/userLogic'
import { HogQLQueryResponse, NodeKind, ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
import { asNumber } from './queryResultParsers'
+// These intents fire on view, not on a user action, so during impersonation they'd register
+// staff navigation as the team's intent — and the read-only middleware rejects the write (403),
+// toasting on every mount. Skip firing while impersonating.
+function isImpersonatedSession(): boolean {
+ return userLogic.findMounted()?.values.user?.is_impersonated ?? false
+}
+
export type MCPOnboardingState = 'not-instrumented' | 'connected-no-calls' | 'onboarded'
/**
@@ -179,7 +187,11 @@ export const mcpAnalyticsOnboardingLogic = kea<mcpAnalyticsOnboardingLogicType>(
// 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) {
+ if (
+ values.onboardingState === 'connected-no-calls' &&
+ !cache.registeredConnected &&
+ !isImpersonatedSession()
+ ) {
cache.registeredConnected = true
void addProductIntent({
product_type: ProductKey.MCP_ANALYTICS,
@@ -197,10 +209,12 @@ export const mcpAnalyticsOnboardingLogic = kea<mcpAnalyticsOnboardingLogicType>(
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,
- })
+ if (!isImpersonatedSession()) {
+ 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)