: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): make the feed the activity tab's hero (#103107)
Lucas Faria8db7ad5ee3de
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 3852bf5d15e5..6d4fc632579b 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -9389,9 +9389,9 @@ snapshots:scenes-app-max-ai-replay-vision-scan-widget--with-skipped--light:hash: v1.k794b7964.c543228b0f31abb2aae3b274819abdee4ba6a89fb3324fc6aaa2b18aefee5815.S9etTEY8oT2JhOgLO5hdc6VqvbvYhD-nU4P1WKh24ygscenes-app-mcp-analytics--activity--dark:- hash: v1.k794b7964.00f97861fa156d012a6cadda9803ead69a56979837d992f287de841ad8b0d303.auxpVnXeHCG3i8WWD3Lf-xwFtaMlkYsYRZhf2iIHpXw+ hash: v1.k794b7964.edf86d02a0ac4cabd95b3e8af8db7abd119a53c680f3f1b71df2b3a27049cfea.zOBLOGJlEPy2ashr-wi9dmUHykgI0F5TDO3Tl2aBNWkscenes-app-mcp-analytics--activity--light:- hash: v1.k794b7964.07eb69e8d1b5cf2b74a60f5c8b7e6eebf4db9430368ec576b96a5fa3a88449a8.yn7ORnsE9a5c2FZGJbzFylVqx-Y82LVj7TH7Lhh4KOY+ hash: v1.k794b7964.cf96991f52bc956ec928681ee1f96e42140d31e0991c5a40c7da6b81259503b7.CgitfYGcu4KCWE6xQwDuctd_OZUhu99nMoY4gY8C2oQscenes-app-mcp-analytics--dashboard--medium--dark:hash: v1.k794b7964.d720f243a9d94d614c00a31063df879f070eac53b3fce76c9d42931304941769.nsNkPSEGWTyU5u1XdmhHnveET4Lvu2hC4egcz9pV12Mscenes-app-mcp-analytics--dashboard--medium--light:@@ -9405,9 +9405,9 @@ snapshots:scenes-app-mcp-analytics--dashboard-narrow--light:hash: v1.k794b7964.1b0f034d65b83b016c1b956f6fd26ceeea9b3eec2b911fd914abdba311d3bcdf.u4FmLXfh5WKo8bYdFk1OcMlYEt7RDMn3Gs2hjTOiCPwscenes-app-mcp-analytics--dashboard-with-menu-bar--dark:- hash: v1.k794b7964.8a64effc30dcb139ee46eb38eab71c5f7ee39b5fdd8df865f9ebd82b15e9e752.lF2iXnflVWCXsmZXOukWLUQTKgKM5Ijb9OGMO1jUwUc+ hash: v1.k794b7964.07cc8cb35a57fde33df026df8215dcf756051282b7308852bdfa04580c028ef1._z2sT7s18QVHgntxbY0lgZ-jl_s_gzZpfSX8GUaVrloscenes-app-mcp-analytics--dashboard-with-menu-bar--light:- hash: v1.k794b7964.5950f14c1cba87ea5610ce1ae7f67791bf2320688e3bd04ffbd1154e465a163f.dyk-zwl99Fj0Dg39JnvwPOnx-zbxUeoxq1nT9FHqGfM+ hash: v1.k794b7964.8ab00a0c164b749682df44ba4c3242570a49a273597c02f33c713bf06bdae66a.mCVrrwiO3s7_HpM-H9awFD4PAI-JgGKeDyp9z8cLemIscenes-app-mcp-analytics--intent-clustering--dark:hash: v1.k794b7964.9549b853f80d754b9d6ccf17ab144d24218143200c90df7af687e184e7de5329.Er1_HM8avmrqmulj2hCLnkp98-HeuRvF5ed3j-_jS2Ascenes-app-mcp-analytics--intent-clustering--light:diff --git a/products/mcp_analytics/frontend/earlyData/ActivityCallers.tsx b/products/mcp_analytics/frontend/earlyData/ActivityCallers.tsxnew file mode 100644index 000000000000..8a5cc8ad12a0--- /dev/null+++ b/products/mcp_analytics/frontend/earlyData/ActivityCallers.tsx@@ -0,0 +1,23 @@+import { useValues } from 'kea'++import { useChartTheme } from 'lib/charts/hooks'++import { HarnessBarChart } from '../dashboard/HarnessBarChart'+import { ModelBarChart } from '../dashboard/ModelBarChart'+import { ACTIVITY_FILTERS, mcpEarlyDataLogic } from './mcpEarlyDataLogic'++// The same two cards as the dashboard's Usage section, over the activity tab's fixed window.+export function ActivityCallers(): JSX.Element {+ const { harnessRows, harnessRowsLoading, modelRows, hasModelData } = useValues(mcpEarlyDataLogic)+ const theme = useChartTheme()++ return (+ <section className="@container flex min-w-0 flex-col gap-2" data-attr="mcp-analytics-activity-callers">+ <h3 className="mb-0 text-sm font-semibold">Who is calling your server</h3>+ <div className="grid min-w-0 grid-cols-1 gap-4 @3xl:grid-cols-2" data-quill>+ <HarnessBarChart rows={harnessRows} loading={harnessRowsLoading} theme={theme} />+ {hasModelData ? <ModelBarChart rows={modelRows} theme={theme} filters={ACTIVITY_FILTERS} /> : null}+ </div>+ </section>+ )+}diff --git a/products/mcp_analytics/frontend/earlyData/ActivityFeed.tsx b/products/mcp_analytics/frontend/earlyData/ActivityFeed.tsxnew file mode 100644index 000000000000..5f823031f1f7--- /dev/null+++ b/products/mcp_analytics/frontend/earlyData/ActivityFeed.tsx@@ -0,0 +1,26 @@+import { useActions, useValues } from 'kea'++import { ToolCallFeed } from '../components/ToolCallFeed'+import { MCP_ACTIVITY_DATA_COLLECTION_ID } from '../components/toolCallFeedQuery'+import { mcpEarlyDataLogic } from './mcpEarlyDataLogic'++export function ActivityFeed(): JSX.Element {+ const { activityQuery } = useValues(mcpEarlyDataLogic)+ const { setActivityQuery } = useActions(mcpEarlyDataLogic)++ return (+ <section className="flex flex-col" data-attr="mcp-analytics-activity-feed">+ <h3 className="mb-2 text-sm font-semibold">Live activity</h3>+ {/* Capped so the page ends without scrolling past a thousand rows; the rest scrolls inside. */}+ <div className="flex max-h-[36rem] overflow-hidden">+ <ToolCallFeed+ query={activityQuery}+ setQuery={setActivityQuery}+ uniqueKey="mcp-analytics-activity"+ dataNodeCollectionId={MCP_ACTIVITY_DATA_COLLECTION_ID}+ attachTo={mcpEarlyDataLogic}+ />+ </div>+ </section>+ )+}diff --git a/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx b/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsxindex 6771659a7080..37dba5c7af8d 100644--- a/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx+++ b/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx@@ -1,56 +1,34 @@-import { useActions, useValues } from 'kea'+import { useValues } from 'kea'-import * as explorerPng from '@posthog/brand/hoggies/png/explorer'-import { IconCheckCircle, IconClock, IconWarning } from '@posthog/icons'-import { LemonBanner, LemonSkeleton, LemonTag, Link } from '@posthog/lemon-ui'+import { LemonSkeleton, Link } from '@posthog/lemon-ui'-import { pngHoggie } from 'lib/brand/hoggies'-import { dataColorVars } from 'lib/colors'-import { LemonProgress } from 'lib/lemon-ui/LemonProgress'import { urls } from 'scenes/urls'-import { ToolCallFeed } from '../components/ToolCallFeed'-import { MCP_ACTIVITY_DATA_COLLECTION_ID } from '../components/toolCallFeedQuery'-import { Card } from '../dashboard/Card'import { formatNumber } from '../dashboard/formatters'-import { HarnessLogo } from '../dashboard/harness'-import type { MCPIntentThemeApi } from '../generated/api.schemas'import { METRICS_UNLOCK_LIFETIME_CALLS, mcpAnalyticsOnboardingLogic } from '../mcpAnalyticsOnboardingLogic'-import type { ChecklistItem } from './mcpEarlyDataLogic'+import { ActivityCallers } from './ActivityCallers'+import { ActivityFeed } from './ActivityFeed'import { mcpEarlyDataLogic } from './mcpEarlyDataLogic'-const HedgehogExplorer = pngHoggie(explorerPng)-/**- * The Activity tab: answers "what are agents doing with my server?" — a- * plain-language summary instead of KPI tiles, the live feed as the hero, an- * AI digest of agent intents, and an instrumentation checklist. It refreshes- * live and is the default landing tab for low-volume projects, where the- * windowed metrics dashboard would be noise; higher-volume projects land on- * the Dashboard tab but can always come here for recency.+ * The Activity tab: answers "what are agents doing with my server?" with the+ * live feed as the hero, a one-line summary above it, and the dashboard's+ * caller charts below. It refreshes live and is the default landing tab for+ * low-volume projects, where the windowed metrics dashboard would be noise;+ * higher-volume projects land on the Dashboard tab but can always come here+ * for recency.*/export function MCPAnalyticsActivityDashboard(): JSX.Element {return (<div className="flex flex-col gap-4" data-attr="mcp-analytics-activity">- <SummaryCard />- <div className="grid grid-cols-1 lg:grid-cols-4 gap-4 lg:min-h-[36rem]">- {/* Matched column heights are the goal: the sidebar sets the row height and the feed- fills it. Taking the feed out of flow is what makes that one-directional — in- flow its own row count would be the taller side and stretch the grid. */}- <div className="lg:relative lg:col-span-3">- <LiveActivityCard />- </div>- <div className="flex flex-col gap-4">- <IntentsCard />- <ClientsCard />- <ChecklistCard />- </div>- </div>+ <ActivitySummary />+ <ActivityFeed />+ <ActivityCallers /></div>)}-function SummaryCard(): JSX.Element {+function ActivitySummary(): JSX.Element {const { dashboardStage } = useValues(mcpAnalyticsOnboardingLogic)const { summary, overview, overviewLoading } = useValues(mcpEarlyDataLogic)// The sentence is derived from the overview, and an absent overview reads as zero calls —@@ -60,218 +38,22 @@ function SummaryCard(): JSX.Element {const awaitingFirstOverview = overviewLoading && !overviewreturn (- <LemonBanner type="info" dismissKey="mcp-analytics-activity-summary" hideIcon>- <div className="flex items-center gap-3 py-1">- <HedgehogExplorer className="h-14 w-14 shrink-0 hidden sm:block" />- <div className="min-w-0">- {awaitingFirstOverview ? (- <LemonSkeleton className="h-6 w-80 max-w-full my-1" />- ) : (- <h3 className="text-lg font-semibold m-0">{summary}</h3>- )}- <p className="text-muted text-base m-0 mt-1">- This view fills in live as agents use your server.- {dashboardStage === 'activity' ? (- <>- {' '}- Charts and trends live in the{' '}- <Link to={urls.mcpAnalyticsDashboard()}>Dashboard tab</Link>. They become meaningful as- usage grows (~{formatNumber(METRICS_UNLOCK_LIFETIME_CALLS)} calls).- </>- ) : null}- </p>- </div>- </div>- </LemonBanner>- )-}--function LiveActivityCard(): JSX.Element {- const { activityQuery } = useValues(mcpEarlyDataLogic)- const { setActivityQuery } = useActions(mcpEarlyDataLogic)-- return (- <section className="flex h-full flex-col overflow-hidden lg:absolute lg:inset-0">- <h3 className="mb-2 text-sm font-semibold">Live activity</h3>- {/* Fills the card so the feed ends where the sidebar does; the rest scrolls. Stacked- layouts have no sidebar to match, so they fall back to a fixed cap. */}- <div className="flex flex-1 min-h-0 max-h-[36rem] overflow-hidden lg:max-h-none">- <ToolCallFeed- query={activityQuery}- setQuery={setActivityQuery}- uniqueKey="mcp-analytics-activity"- dataNodeCollectionId={MCP_ACTIVITY_DATA_COLLECTION_ID}- attachTo={mcpEarlyDataLogic}- />- </div>- </section>- )-}--// `total` is every intent analysed, so the bar reads as this theme's share of them. The backend-// assigns each intent to at most one theme, which is what keeps the shares adding up.-//-// Themes are categories rather than one measure over time, so each gets its own colour from the-// data palette — a stack of identical brand-blue bars reads as one repeated thing.-//-// LemonProgress needs an explicit bgColor here: its default is `var(--color-bg-primary)`, which is a-// neutral in LemonUI but brand orange inside a quill Card, so the unfilled remainder renders as a-// second, larger-looking value. Applies to every LemonProgress under a quill Card.-function IntentThemeRow({- theme,- total,- color,-}: {- theme: MCPIntentThemeApi- total: number- color: string-}): JSX.Element {- return (- <div className="flex flex-col gap-1">- <div className="flex items-baseline justify-between gap-2">- <span className="text-base font-medium">{theme.name}</span>- <span className="text-muted text-sm shrink-0">{formatNumber(theme.intent_count)}</span>- </div>- <LemonProgress- percent={total > 0 ? (theme.intent_count / total) * 100 : 0}- bgColor="var(--color-bg-surface-tertiary)"- strokeColor={color}- />- <p className="text-muted text-sm m-0">{theme.description}</p>- {theme.example_intent ? (- <p className="text-muted text-sm italic m-0 line-clamp-2" title={theme.example_intent}>- “{theme.example_intent}”- </p>- ) : null}- {theme.tools.length > 0 ? (- <div className="flex gap-1 flex-wrap">- {theme.tools.slice(0, 4).map((tool) => (- <LemonTag key={tool} size="small">- {tool}- </LemonTag>- ))}- </div>- ) : null}- </div>- )-}--// The AI digest is the product here: real intents are all worded differently, so-// verbatim grouping can't answer "what are agents trying to do". We ask the LLM to-// group them into themes and render those as structured rows; the raw frequency-// list is strictly the degraded state for when generation is unavailable (no LLM key).-function IntentsCard(): JSX.Element {- const { intentDigest, intentDigestLoading, intentFrequencies } = useValues(mcpEarlyDataLogic)-- return (- <Card title="What agents are trying to do">- {/* Both, not just the summary: nothing resolved into themes means the rows would be an- empty gap under a headline, and the verbatim list says more than that. */}- {intentDigest?.digest && intentDigest.themes.length > 0 ? (- <div className="flex flex-col gap-3">- <p className="text-base m-0">{intentDigest.digest}</p>- {intentDigest.themes.map((theme, index) => (- <IntentThemeRow- key={`${index}-${theme.name}`}- theme={theme}- total={intentDigest.intentCount}- color={`var(--${dataColorVars[index % dataColorVars.length]})`}- />- ))}- <span className="text-muted text-sm">- AI grouping of the last {formatNumber(intentDigest.intentCount)} agent intents- </span>- </div>- ) : intentDigestLoading ? (- <div className="flex flex-col gap-2">- <LemonSkeleton className="h-4 w-full" />- <LemonSkeleton className="h-4 w-5/6" />- <LemonSkeleton className="h-4 w-2/3" />- <span className="text-muted text-sm">Summarizing recent agent intents…</span>- </div>- ) : intentFrequencies.length === 0 ? (- <span className="text-muted text-base">- No agent intents captured yet — they show up here as agents explain what they're doing.- </span>+ <div data-attr="mcp-analytics-activity-summary">+ {awaitingFirstOverview ? (+ <LemonSkeleton className="h-6 w-80 max-w-full my-1" />) : (- <div className="flex flex-col gap-2">- <ul className="flex flex-col gap-2 m-0 pl-4">- {intentFrequencies.map(({ intent, count }) => (- <li key={intent} className="text-base">- {intent}- {count > 1 ? <span className="text-muted text-sm"> ×{count}</span> : null}- </li>- ))}- </ul>- <span className="text-muted text-sm">- AI summary unavailable — showing the most recent intents verbatim.- </span>- </div>+ <h2 className="text-lg font-semibold m-0">{summary}</h2>)}- </Card>- )-}--function ClientsCard(): JSX.Element {- const { clients } = useValues(mcpEarlyDataLogic)- const maxCalls = clients[0]?.calls ?? 0-- return (- <Card title="Clients calling your server">- {clients.length === 0 ? (- <span className="text-muted text-base">No client info captured yet</span>- ) : (- <div className="flex flex-col gap-2">- {clients.map((row) => (- <div key={row.client}>- <div className="flex justify-between text-base">- <span className="flex items-center gap-1.5">- <HarnessLogo category={row.client} className="h-3.5 w-3.5" />- {row.client}- </span>- <span className="text-muted">{formatNumber(row.calls)}</span>- </div>- <LemonProgress- percent={maxCalls > 0 ? (row.calls / maxCalls) * 100 : 0}- bgColor="var(--color-bg-surface-tertiary)"- />- </div>- ))}- </div>- )}- </Card>- )-}--const CHECKLIST_ICONS: Record<ChecklistItem['status'], JSX.Element> = {- ok: <IconCheckCircle className="text-success shrink-0 mt-0.5" />,- warning: <IconWarning className="text-warning shrink-0 mt-0.5" />,- pending: <IconClock className="text-muted shrink-0 mt-0.5" />,-}--function ChecklistCard(): JSX.Element {- const { checklist } = useValues(mcpEarlyDataLogic)-- return (- <Card title="Instrumentation checklist">- <div className="flex flex-col gap-3">- {checklist.map((item) => (- <div key={item.key} className="flex gap-2">- {CHECKLIST_ICONS[item.status]}- <div>- <div className="text-base font-medium">{item.title}</div>- <div className="text-muted text-sm">- {item.detail}{' '}- {item.appLink ? (- <Link to={item.appLink.to}>{item.appLink.label}</Link>- ) : item.status !== 'ok' ? (- <Link to={item.docsUrl}>Learn more</Link>- ) : null}- </div>- </div>- </div>- ))}- </div>- </Card>+ <p className="text-muted m-0 mt-1">+ This view fills in live as agents use your server.+ {dashboardStage === 'activity' ? (+ <>+ {' '}+ Charts and trends live in the <Link to={urls.mcpAnalyticsDashboard()}>Dashboard tab</Link>. They+ become meaningful as usage grows (~{formatNumber(METRICS_UNLOCK_LIFETIME_CALLS)} calls).+ </>+ ) : null}+ </p>+ </div>)}diff --git a/products/mcp_analytics/frontend/earlyData/earlyData.test.ts b/products/mcp_analytics/frontend/earlyData/earlyData.test.tsindex c33cb4111194..b0bca23360f6 100644--- a/products/mcp_analytics/frontend/earlyData/earlyData.test.ts+++ b/products/mcp_analytics/frontend/earlyData/earlyData.test.ts@@ -1,16 +1,4 @@import { buildActivitySummary } from './activitySummary'-import { buildChecklist, EarlyStats } from './earlyDataChecklist'--const stats = (overrides: Partial<EarlyStats>): EarlyStats => ({- totalCalls: 0,- distinctTools: 0,- distinctSessions: 0,- distinctClients: 0,- callsWithIntent: 0,- errorCalls: 0,- missingCapabilityReports: 0,- ...overrides,-})describe('early data derivations', () => {it.each([@@ -67,31 +55,4 @@ describe('early data derivations', () => {])('summarizes %j', (input, expected) => {expect(buildActivitySummary(input)).toMatch(expected)})-- it.each([- // Under 10 calls ratios are noise: hold judgment instead of warning.- [stats({ totalCalls: 5, callsWithIntent: 0, distinctSessions: 5 }), 'pending', 'pending'],- // Intent wired + sessions grouping: both healthy.- [stats({ totalCalls: 40, callsWithIntent: 35, distinctSessions: 8 }), 'ok', 'ok'],- // No intent + one session per call (stateless server): both warn.- [stats({ totalCalls: 40, callsWithIntent: 2, distinctSessions: 40 }), 'warning', 'warning'],- // 90% of calls being sessions is already degenerate, not just 100%.- [stats({ totalCalls: 100, callsWithIntent: 90, distinctSessions: 90 }), 'ok', 'warning'],- ])('checklist grades intent/sessions for %j as %s/%s', (input, intentStatus, sessionsStatus) => {- const checklist = buildChecklist(input)- expect(checklist.find((i) => i.key === 'intent')?.status).toBe(intentStatus)- expect(checklist.find((i) => i.key === 'sessions')?.status).toBe(sessionsStatus)- })-- it.each([- [0, 'pending', undefined],- [2, 'ok', '/mcp-analytics/missing-capabilities'],- ])('grades %i missing-capability reports as %s and links to %s', (reports, status, appLinkTo) => {- const item = buildChecklist(stats({ missingCapabilityReports: reports })).find(- (i) => i.key === 'missing-capability'- )-- expect(item?.status).toBe(status)- expect(item?.appLink?.to).toBe(appLinkTo)- })})diff --git a/products/mcp_analytics/frontend/earlyData/earlyDataChecklist.ts b/products/mcp_analytics/frontend/earlyData/earlyDataChecklist.tsdeleted file mode 100644index 3d797119c3f4..000000000000--- a/products/mcp_analytics/frontend/earlyData/earlyDataChecklist.ts+++ /dev/null@@ -1,85 +0,0 @@-import { urls } from 'scenes/urls'--export interface EarlyStats {- totalCalls: number- distinctTools: number- distinctSessions: number- distinctClients: number- callsWithIntent: number- errorCalls: number- missingCapabilityReports: number-}--export type ChecklistStatus = 'ok' | 'warning' | 'pending'--export interface ChecklistItem {- key: string- title: string- detail: string- status: ChecklistStatus- docsUrl: string- appLink?: { to: string; label: string }-}--const DOCS = {- intent: 'https://posthog.com/docs/mcp-analytics/intent',- conversationId: 'https://posthog.com/docs/mcp-analytics/conversation-id',- missingCapability: 'https://posthog.com/docs/mcp-analytics/missing-capability',-}--/** Below this, instrumentation ratios are noise — hold judgment rather than warn. */-const MIN_CALLS_FOR_SIGNAL = 10--/**- * Instrumentation-quality checks for the early-data view. At low volume, better- * instrumentation is the highest-leverage thing a user can do — every later feature- * (intent summaries, clustering, sessions) depends on these being wired correctly.- */-export function buildChecklist(stats: EarlyStats): ChecklistItem[] {- const enoughSignal = stats.totalCalls >= MIN_CALLS_FOR_SIGNAL-- const intentShare = stats.totalCalls > 0 ? stats.callsWithIntent / stats.totalCalls : 0- const intentOk = intentShare >= 0.5-- // One session per call means no session state survives between calls- // (stateless/serverless server) — sessions degrade to singletons.- const sessionsDegenerate = enoughSignal && stats.distinctSessions >= Math.max(2, Math.floor(stats.totalCalls * 0.9))-- return [- {- key: 'intent',- title: 'Intent capture',- detail: intentOk- ? `${Math.round(intentShare * 100)}% of tool calls carry agent intent.`- : 'Few or no tool calls carry agent intent. Enable the context parameter so you can see what agents are trying to do.',- status: !enoughSignal ? 'pending' : intentOk ? 'ok' : 'warning',- docsUrl: DOCS.intent,- },- {- key: 'sessions',- title: 'Session stitching',- // Deliberately informational: conversation IDs are opt-in (the echo-back loop- // can read as prompt injection to some agents), so we describe the tradeoff- // via docs instead of prescribing it.- detail: sessionsDegenerate- ? 'Almost every tool call starts a new session — typical for stateless or serverless servers. Session views will treat each call separately.'- : 'Tool calls are grouping into sessions.',- status: !enoughSignal ? 'pending' : sessionsDegenerate ? 'warning' : 'ok',- docsUrl: DOCS.conversationId,- },- {- key: 'missing-capability',- title: 'Missing capability reporting',- detail:- stats.missingCapabilityReports > 0- ? `Agents have filed ${stats.missingCapabilityReports} missing-capability report${stats.missingCapabilityReports === 1 ? '' : 's'}.`- : 'No missing-capability reports yet. Enable reportMissing so agents can tell you which tools they wish you had.',- status: stats.missingCapabilityReports > 0 ? 'ok' : 'pending',- docsUrl: DOCS.missingCapability,- appLink:- stats.missingCapabilityReports > 0- ? { to: urls.mcpAnalyticsMissingCapabilities(), label: 'Read the reports' }- : undefined,- },- ]-}diff --git a/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts b/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.tsindex b06797311ab7..dd6962c23a09 100644--- a/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts+++ b/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts@@ -1,53 +1,34 @@-import {- MakeLogicType,- actions,- afterMount,- connect,- isBreakpoint,- kea,- listeners,- path,- reducers,- selectors,-} from 'kea'+import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'import { loaders } from 'kea-loaders'+import api from 'lib/api'import { teamLogic } from 'scenes/teamLogic'import { dataNodeCollectionLogic } from '~/queries/nodes/DataNode/dataNodeCollectionLogic'-import { DataTableNode } from '~/queries/schema/schema-general'+import {+ DataTableNode,+ HogQLFilters,+ MCPHarnessBreakdownItem,+ MCPModelBreakdownItem,+ NodeKind,+} from '~/queries/schema/schema-general'import { DEFAULT_MCP_ACTIVITY_QUERY, MCP_ACTIVITY_DATA_COLLECTION_ID } from '../components/toolCallFeedQuery'-import { mcpAnalyticsSessionsActivityOverview, mcpAnalyticsSessionsIntentDigest } from '../generated/api'-import type { MCPActivityOverviewApi, MCPIntentThemeApi } from '../generated/api.schemas'+import { mcpAnalyticsSessionsActivityOverview } from '../generated/api'+import type { MCPActivityOverviewApi } from '../generated/api.schemas'import { mcpAnalyticsOnboardingLogic } from '../mcpAnalyticsOnboardingLogic'import type { MCPOnboardingSignals } from '../mcpAnalyticsOnboardingLogic'+import type { HarnessRow, ModelRow } from '../mcpDashboardOverviewLogic'import { buildActivitySummary } from './activitySummary'-import { ChecklistItem, EarlyStats, buildChecklist } from './earlyDataChecklist'--export type { ChecklistItem, EarlyStats } from './earlyDataChecklist'--export interface EarlyRecentCall {- timestamp: string- tool: string- intent: string | null- isError: boolean- /** Short human-readable error extracted from the tool's response, when the call failed. */- errorMessage: string | null- durationMs: number | null- clientName: string | null-}-// Frequency-grouped verbatim intents, the fallback shown when no AI digest is available.-export interface IntentFrequency {- intent: string- count: number-}--export interface IntentDigest {- digest: string | null- intentCount: number- themes: readonly MCPIntentThemeApi[]+export interface EarlyStats {+ totalCalls: number+ distinctTools: number+ distinctSessions: number+ distinctClients: number+ callsWithIntent: number+ errorCalls: number+ missingCapabilityReports: number}export interface EarlyToolRow {@@ -56,11 +37,6 @@ export interface EarlyToolRow {errors: number}-export interface EarlyClientRow {- client: string- calls: number-}-const EMPTY_STATS: EarlyStats = {totalCalls: 0,distinctTools: 0,@@ -71,6 +47,10 @@ const EMPTY_STATS: EarlyStats = {missingCapabilityReports: 0,}+// The feed's default range, unfiltered like the feed and the overview endpoint, so every number on+// the tab describes the same calls. The dashboard applies its own test-account filter.+export const ACTIVITY_FILTERS: HogQLFilters = { dateRange: { date_from: '-30d' } }+// Refresh cadence for the early view. Slower than the onboarding signal poll: the// overview aggregates 30 days of property-reading queries server-side, and "within// a minute" is live enough.@@ -81,14 +61,13 @@ export interface mcpEarlyDataLogicValues {signals: MCPOnboardingSignals | null // mcpAnalyticsOnboardingLogiccurrentProjectId: number | string // teamLogicactivityQuery: DataTableNode- checklist: ChecklistItem[]- clients: EarlyClientRow[]- intentDigest: IntentDigest | null- intentDigestLoading: boolean- intentFrequencies: IntentFrequency[]+ harnessRows: HarnessRow[]+ harnessRowsLoading: boolean+ hasModelData: boolean+ modelRows: ModelRow[]+ modelRowsLoading: booleanoverview: MCPActivityOverviewApi | nulloverviewLoading: boolean- recentCalls: EarlyRecentCall[]stats: EarlyStatssummary: stringtopTools: EarlyToolRow[]@@ -98,19 +77,34 @@ export interface mcpEarlyDataLogicValues {export interface mcpEarlyDataLogicActions {reloadActivityQuery: () => {} // dataNodeCollectionLogicloadSignals: (_?: void | undefined) => void // mcpAnalyticsOnboardingLogic- loadIntentDigest: (_: void) => void- loadIntentDigestFailure: (+ loadHarnessRows: (_: void) => void+ loadHarnessRowsFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadHarnessRowsSuccess: (+ harnessRows: HarnessRow[],+ payload?: void+ ) => {+ harnessRows: HarnessRow[]+ payload?: void+ }+ loadModelRows: (_: void) => void+ loadModelRowsFailure: (error: string,errorObject?: any) => {error: stringerrorObject?: any}- loadIntentDigestSuccess: (- intentDigest: IntentDigest | null,+ loadModelRowsSuccess: (+ modelRows: ModelRow[],payload?: void) => {- intentDigest: IntentDigest | null+ modelRows: ModelRow[]payload?: void}loadOverview: (_: void) => void@@ -141,11 +135,8 @@ export interface mcpEarlyDataLogicMeta {__keaTypeGenInternalSelectorTypes: {stats: (overview: MCPActivityOverviewApi | null) => EarlyStatstopTools: (overview: MCPActivityOverviewApi | null) => EarlyToolRow[]- clients: (overview: MCPActivityOverviewApi | null) => EarlyClientRow[]- recentCalls: (overview: MCPActivityOverviewApi | null) => EarlyRecentCall[]summary: (signals: MCPOnboardingSignals | null, stats: EarlyStats, topTools: EarlyToolRow[]) => string- intentFrequencies: (recentCalls: EarlyRecentCall[]) => IntentFrequency[]- checklist: (stats: EarlyStats) => ChecklistItem[]+ hasModelData: (modelRows: ModelRow[]) => boolean}}@@ -160,12 +151,11 @@ export const mcpEarlyDataLogic = kea<mcpEarlyDataLogicType>([path(['products', 'mcp_analytics', 'frontend', 'earlyData', 'mcpEarlyDataLogic']),connect(() => ({values: [mcpAnalyticsOnboardingLogic, ['signals'], teamLogic, ['currentProjectId']],- // Refresh the lifetime signal with the overview so first-call copy can- // advance even after the onboarding signal poll stops.- actions: [mcpAnalyticsOnboardingLogic, ['loadSignals']],- })),- connect(() => ({actions: [+ // Refresh the lifetime signal with the overview so first-call copy can+ // advance even after the onboarding signal poll stops.+ mcpAnalyticsOnboardingLogic,+ ['loadSignals'],dataNodeCollectionLogic({ key: MCP_ACTIVITY_DATA_COLLECTION_ID }),['reloadAll as reloadActivityQuery'],],@@ -178,32 +168,6 @@ export const mcpEarlyDataLogic = kea<mcpEarlyDataLogicType>([activityQuery: [DEFAULT_MCP_ACTIVITY_QUERY, { setActivityQuery: (_, { query }) => query }],}),loaders(({ values }) => ({- intentDigest: {- __default: null as IntentDigest | null,- loadIntentDigest: async (_: void, breakpoint): Promise<IntentDigest | null> => {- if (!values.currentProjectId) {- return null- }- try {- const response = await mcpAnalyticsSessionsIntentDigest(String(values.currentProjectId))- breakpoint()- return {- digest: response.digest,- intentCount: response.intent_count,- themes: response.themes ?? [],- }- } catch (error: unknown) {- // A newer load superseded this one; let kea-loaders skip the stale success- // rather than reporting it as a failed digest.- if (isBreakpoint(error as Error)) {- throw error- }- // LLM unconfigured (503) or transient failure: the card falls back- // to the verbatim intent list.- return null- }- },- },overview: {__default: null as MCPActivityOverviewApi | null,loadOverview: async (_: void, breakpoint): Promise<MCPActivityOverviewApi | null> => {@@ -215,6 +179,38 @@ export const mcpEarlyDataLogic = kea<mcpEarlyDataLogicType>([return response},},+ harnessRows: [+ [] as HarnessRow[],+ {+ loadHarnessRows: async (_: void, breakpoint): Promise<HarnessRow[]> => {+ const response = (await api.query({+ kind: NodeKind.MCPHarnessBreakdownQuery,+ ...ACTIVITY_FILTERS,+ })) as { results?: MCPHarnessBreakdownItem[] }+ breakpoint()+ return (response?.results ?? []).map((r) => ({+ category: r.harness,+ total_calls: r.total_calls,+ errors: r.errors,+ error_rate_pct: r.error_rate_pct,+ sessions: r.sessions,+ }))+ },+ },+ ],+ modelRows: [+ [] as ModelRow[],+ {+ loadModelRows: async (_: void, breakpoint): Promise<ModelRow[]> => {+ const response = (await api.query({+ kind: NodeKind.MCPModelBreakdownQuery,+ ...ACTIVITY_FILTERS,+ })) as { results?: MCPModelBreakdownItem[] }+ breakpoint()+ return response?.results ?? []+ },+ },+ ],})),selectors({stats: [@@ -237,24 +233,6 @@ export const mcpEarlyDataLogic = kea<mcpEarlyDataLogicType>([(overview: MCPActivityOverviewApi | null): EarlyToolRow[] =>(overview?.top_tools ?? []).map((row) => ({ tool: row.tool, calls: row.calls, errors: row.errors })),],- clients: [- (s) => [s.overview],- (overview: MCPActivityOverviewApi | null): EarlyClientRow[] =>- (overview?.clients ?? []).map((row) => ({ client: row.client, calls: row.calls })),- ],- recentCalls: [- (s) => [s.overview],- (overview: MCPActivityOverviewApi | null): EarlyRecentCall[] =>- (overview?.recent_calls ?? []).map((row) => ({- timestamp: row.timestamp,- tool: row.tool,- intent: row.intent,- isError: row.is_error,- errorMessage: row.error_message,- durationMs: row.duration_ms,- clientName: row.client_name,- })),- ],summary: [(s) => [s.signals, s.stats, s.topTools],(signals: MCPOnboardingSignals | null, stats: EarlyStats, topTools: EarlyToolRow[]): string =>@@ -266,39 +244,24 @@ export const mcpEarlyDataLogic = kea<mcpEarlyDataLogicType>([topTool: stats.totalCalls > 10 ? (topTools[0]?.tool ?? null) : null,}),],- // Verbatim agent intents grouped by frequency — the fallback when no AI- // digest is available. At low volume, reading what agents actually tried- // beats any lossy aggregation of it.- intentFrequencies: [- (s) => [s.recentCalls],- (recentCalls: EarlyRecentCall[]): IntentFrequency[] => {- const counts = new Map<string, number>()- for (const call of recentCalls) {- if (call.intent) {- counts.set(call.intent, (counts.get(call.intent) ?? 0) + 1)- }- }- return [...counts.entries()]- .map(([intent, count]) => ({ intent, count }))- .sort((a, b) => b.count - a.count)- .slice(0, 6)- },+ hasModelData: [+ (s) => [s.modelRows],+ (modelRows: ModelRow[]): boolean => modelRows.some((row) => row.total_calls > 0),],- checklist: [(s) => [s.stats], (stats: EarlyStats): ChecklistItem[] => buildChecklist(stats)],}),listeners(({ actions }) => ({refreshAll: () => {actions.loadSignals()actions.loadOverview()+ actions.loadHarnessRows()+ actions.loadModelRows()actions.reloadActivityQuery()- // Server-side the digest is content-addressed, so this only reaches the- // LLM when new intents have actually arrived.- actions.loadIntentDigest()},})),afterMount(({ actions, cache }) => {actions.loadOverview()- actions.loadIntentDigest()+ actions.loadHarnessRows()+ actions.loadModelRows()cache.disposables.add(() => {const id = window.setInterval(() => actions.refreshAll(), REFRESH_INTERVAL_MS)return () => clearInterval(id)