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): open tool report from the error rate chart (#110561)

Georgis Andonis0610859dd24b
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx b/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
index 45af29dffcc5..16ff59234c0d 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
@@ -59,7 +59,7 @@ export function MCPAnalyticsDashboardOverview(): JSX.Element {
canShowFeedback,
feedbackContextKey,
} = useValues(mcpDashboardOverviewLogic)
- const { setDateFilter, reloadAll, markFilterInteraction } = useActions(mcpDashboardOverviewLogic)
+ const { setDateFilter, reloadAll, markFilterInteraction, openToolReport } = useActions(mcpDashboardOverviewLogic)
const { hiddenCards, isCardVisible } = useValues(mcpDashboardCardsLogic)
const { showAllCards } = useActions(mcpDashboardCardsLogic)
const { timezone } = useValues(teamLogic)
@@ -194,7 +194,12 @@ export function MCPAnalyticsDashboardOverview(): JSX.Element {
<h2 className="mb-0 text-xl font-semibold text-primary">Reliability</h2>
<CardRow twoColumnsClassName="@min-[64rem]/mcp-overview:grid-cols-2">
{showToolErrors && (
- <ToolErrorRateChart rows={toolRows} loading={toolRowsLoading} theme={theme} />
+ <ToolErrorRateChart
+ rows={toolRows}
+ loading={toolRowsLoading}
+ theme={theme}
+ onToolClick={openToolReport}
+ />
)}
{showNotableSessions && (
<NotableSessionsTable sessions={notableSessions} loading={sessionRowsLoading} />
diff --git a/products/mcp_analytics/frontend/dashboard/ToolErrorRateChart.tsx b/products/mcp_analytics/frontend/dashboard/ToolErrorRateChart.tsx
index b9e14f563774..e63674b08422 100644
--- a/products/mcp_analytics/frontend/dashboard/ToolErrorRateChart.tsx
+++ b/products/mcp_analytics/frontend/dashboard/ToolErrorRateChart.tsx
@@ -4,6 +4,7 @@ import {
BarChart,
type BarChartConfig,
type ChartTheme,
+ type PointClickData,
type Series,
type TooltipContext,
ValueLabels,
@@ -29,10 +30,12 @@ export function ToolErrorRateChart({
rows,
loading,
theme,
+ onToolClick,
}: {
rows: ToolRow[]
loading: boolean
theme: ChartTheme
+ onToolClick?: (tool: string) => void
}): JSX.Element {
const sorted = useMemo(
() => [...rows].sort((a, b) => b.error_rate_pct - a.error_rate_pct).slice(0, MAX_TOOLS),
@@ -86,6 +89,7 @@ export function ToolErrorRateChart({
},
[byTool]
)
+ const handlePointClick = useCallback((data: PointClickData) => onToolClick?.(data.label), [onToolClick])
return (
<Card title="Tools with the highest error rate">
@@ -102,7 +106,14 @@ export function ToolErrorRateChart({
empty={<div className="py-6 text-center text-[12px] text-secondary">No tool calls yet.</div>}
>
<div className="flex min-h-80 flex-1 flex-col">
- <BarChart series={series} labels={labels} config={config} theme={theme} tooltip={renderTooltip}>
+ <BarChart
+ series={series}
+ labels={labels}
+ config={config}
+ theme={theme}
+ tooltip={renderTooltip}
+ onPointClick={onToolClick ? handlePointClick : undefined}
+ >
<ValueLabels
valueFormatter={(value) => formatPercentage(value, { compact: true })}
offset={6}
diff --git a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts
index d51bca135401..be50003bd665 100644
--- a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts
+++ b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts
@@ -569,6 +569,25 @@ describe('mcpDashboardOverviewLogic', () => {
reloads.every((call) => JSON.stringify(filtersOf(call).properties) === JSON.stringify([EVENT_FILTER]))
).toBe(true)
})
+ it('opens a tool report on the dashboard window with the shared filters', async () => {
+ router.actions.push(urls.mcpAnalyticsDashboard(), {
+ properties: [EVENT_FILTER],
+ filter_test_accounts: true,
+ })
+ const logic = mcpDashboardOverviewLogic()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ logic.actions.openToolReport('search docs')
+
+ const { pathname, searchParams } = router.values.currentLocation
+ expect(pathname.endsWith(urls.mcpAnalyticsTool('search docs'))).toBe(true)
+ expect(searchParams).toEqual({
+ date_from: '-7d',
+ properties: [EVENT_FILTER],
+ filter_test_accounts: true,
+ })
+ })
it('reloads tiles once when the URL changes the date and shared filters together', async () => {
router.actions.push(urls.mcpAnalyticsDashboard())
const logic = mcpDashboardOverviewLogic()
diff --git a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts
index 3a846e157fa6..f9c06d9a8113 100644
--- a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts
+++ b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts
@@ -29,6 +29,7 @@ import { AnyPropertyFilter, IntervalType } from '~/types'
import { mcpClusteringLogic } from './clustering/mcpClusteringLogic'
import type { MCPIntentClusterApi } from './generated/api.schemas'
import { type MCPSharedQueryFilters, mcpAnalyticsFiltersLogic } from './mcpAnalyticsFiltersLogic'
+import { mcpToolReportUrl } from './mcpAnalyticsToolQualityLogic'
export interface DateFilter {
dateFrom: string | null
@@ -612,6 +613,9 @@ export interface mcpDashboardOverviewLogicActions {
markFilterInteraction: () => {
value: true
}
+ openToolReport: (tool: string) => {
+ tool: string
+ }
reloadAll: () => {
value: true
}
@@ -686,6 +690,7 @@ export const mcpDashboardOverviewLogic = kea<mcpDashboardOverviewLogicType>([
setDateFilter: (dateFrom: string | null, dateTo: string | null) => ({ dateFrom, dateTo }),
reloadAll: true,
markFilterInteraction: true,
+ openToolReport: (tool: string) => ({ tool }),
}),
reducers({
hasFilterInteraction: [false, { markFilterInteraction: () => true }],
@@ -1003,6 +1008,9 @@ export const mcpDashboardOverviewLogic = kea<mcpDashboardOverviewLogicType>([
setDateFilter: () => {
actions.reloadAll()
},
+ openToolReport: ({ tool }) => {
+ router.actions.push(mcpToolReportUrl(tool, values.dateFilter))
+ },
setFilterTestAccounts: () => {
actions.markFilterInteraction()
actions.reloadAll()