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): render the explore models insight (#101301)

Lucas Faria4bf36bd62055
diff --git a/docs/internal/mcp-model-identification.md b/docs/internal/mcp-model-identification.md
index d8a386c8395f..bd2c0c9ecbd5 100644
--- a/docs/internal/mcp-model-identification.md
+++ b/docs/internal/mcp-model-identification.md
@@ -13,6 +13,7 @@ For a date range ending now, the first page fixes the time bounds for subsequent
Late-arriving events within those bounds can still affect counts; the table is not a database snapshot.
The query's `includeAllModels` option enables this ungrouped view; `limit` (1 to 100) and `offset` select a page, and `hasMore` indicates another page is available.
Explore models opens a Trends table that trims model identifiers and groups missing or blank values under Unknown, with the dashboard's date range, property filters, and test-account exclusion preserved.
+The insight link wraps the Trends query in an `InsightVizNode` so the insight editor can render the table.
The table can show up to 50 identifiers before grouping the remaining values.
Identifiers come from client metadata or the agent's self-report; the identified percentage measures reporting coverage, not verified model identity.
diff --git a/products/mcp_analytics/frontend/dashboard/modelBreakdown.test.ts b/products/mcp_analytics/frontend/dashboard/modelBreakdown.test.ts
index 6f61440c5da7..76b50f3eb39a 100644
--- a/products/mcp_analytics/frontend/dashboard/modelBreakdown.test.ts
+++ b/products/mcp_analytics/frontend/dashboard/modelBreakdown.test.ts
@@ -55,7 +55,11 @@ describe('model breakdown', () => {
},
],
}
- const query = buildModelExplorationQuery(filters)
+ const visualization = buildModelExplorationQuery(filters)
+
+ expect(visualization.kind).toBe(NodeKind.InsightVizNode)
+ const query = visualization.source
+ expect(query.kind).toBe(NodeKind.TrendsQuery)
expect(query).toMatchObject(filters)
expect(query.series).toEqual([{ kind: NodeKind.EventsNode, event: '$mcp_tool_call', math: 'total' }])
diff --git a/products/mcp_analytics/frontend/dashboard/modelBreakdown.ts b/products/mcp_analytics/frontend/dashboard/modelBreakdown.ts
index 7c6f8a652e80..5f91d8d713f7 100644
--- a/products/mcp_analytics/frontend/dashboard/modelBreakdown.ts
+++ b/products/mcp_analytics/frontend/dashboard/modelBreakdown.ts
@@ -1,7 +1,14 @@
import { dayjs } from 'lib/dayjs'
import { dateStringToComponents, dateStringToDayJs } from 'lib/utils/dateFilters'
-import { DateRange, HogQLFilters, MCPModelBreakdownItem, NodeKind, TrendsQuery } from '~/queries/schema/schema-general'
+import {
+ DateRange,
+ HogQLFilters,
+ InsightVizNode,
+ MCPModelBreakdownItem,
+ NodeKind,
+ TrendsQuery,
+} from '~/queries/schema/schema-general'
import { BaseMathType, ChartDisplayType } from '~/types'
export function summarizeModelBreakdown(rows: MCPModelBreakdownItem[]): {
@@ -25,17 +32,20 @@ export function summarizeModelBreakdown(rows: MCPModelBreakdownItem[]): {
}
}
-export function buildModelExplorationQuery(filters: HogQLFilters): TrendsQuery {
+export function buildModelExplorationQuery(filters: HogQLFilters): InsightVizNode<TrendsQuery> {
return {
- ...filters,
- kind: NodeKind.TrendsQuery,
- series: [{ kind: NodeKind.EventsNode, event: '$mcp_tool_call', math: BaseMathType.TotalCount }],
- breakdownFilter: {
- breakdown: "coalesce(nullIf(trim(toString(properties.$mcp_llm_model)), ''), 'Unknown')",
- breakdown_type: 'hogql',
- breakdown_limit: 50,
+ kind: NodeKind.InsightVizNode,
+ source: {
+ ...filters,
+ kind: NodeKind.TrendsQuery,
+ series: [{ kind: NodeKind.EventsNode, event: '$mcp_tool_call', math: BaseMathType.TotalCount }],
+ breakdownFilter: {
+ breakdown: "coalesce(nullIf(trim(toString(properties.$mcp_llm_model)), ''), 'Unknown')",
+ breakdown_type: 'hogql',
+ breakdown_limit: 50,
+ },
+ trendsFilter: { display: ChartDisplayType.ActionsTable },
},
- trendsFilter: { display: ChartDisplayType.ActionsTable },
}
}