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): compare harness calls with horizontal bars (#98471)

Lucas Fariaa2c7833b0d13
diff --git a/docs/published/docs/mcp-analytics/harness-share.mdx b/docs/published/docs/mcp-analytics/harness-share.mdx
new file mode 100644
index 000000000000..ea9e8bfda8d3
--- /dev/null
+++ b/docs/published/docs/mcp-analytics/harness-share.mdx
@@ -0,0 +1,13 @@
+---
+title: Share of calls by harness
+---
+
+The MCP Analytics dashboard shows tool calls by harness as horizontal bars, ranked from most to fewest calls.
+Each row shows the harness name and logo, its call count, and its percentage of all calls in the selected filters and date range.
+
+Colors stay consistent when rankings change. Claude harnesses use terracotta shades, OpenAI harnesses use green shades, and VS Code uses blue.
+Monochrome brands such as Cursor and Grok use a neutral color that adapts to light and dark themes. Other harnesses use brand colors or stable palette colors.
+The existing **Other** category stays gray and includes calls whose client identity does not match a recognized harness.
+
+Scroll within the card to see every harness. Percentages include all returned harnesses, including rows below the visible area and Other.
+Hover over a bar to see the full harness name, calls, share, sessions, and error rate.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index fdf5c33d834b..1fc9a2253e89 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8469,13 +8469,13 @@ snapshots:
scenes-app-mcp-analytics--activity--light:
hash: v1.k794b7964.ebade8669d9a80698871d805207c0d9ac8a69d0f9e2f6667afb7499e176f7004.hp-uMrZGUIrd8_BFPt-cpTUF_qO-4M8v6pzKMEjQjmg
scenes-app-mcp-analytics--dashboard--dark:
- hash: v1.k794b7964.28e8830f28c77c1815afd94747a5f8633a0ff6dff72e7e8a104a84e3d131730c.-r295uHlJ_mpxJzjEHlMP9iM4FsOwaWVrRcfaW-Q4zM
+ hash: v1.k794b7964.ed17495a7e554671abc094f7e507bb58a1a443b25efc32647ace960347196059.iIi7KHOkQ0a6sOQUBmrawaLEgI50osK4E1D_2kYwXso
scenes-app-mcp-analytics--dashboard--light:
- hash: v1.k794b7964.6589aff34fd8f919ee7ba778e08bbe014e6ce6879bcf9685f6767326019d5864.r8Hqmi8hT0hyU7UYQ6cbEqrTl684LwA_EGIcis8ua_k
+ hash: v1.k794b7964.a00226c01e710118794a5c634412e0c7f9cf3a8ea716d48c90e21f643fba295d.AHjcwWLpgSn30w7nn9VWGWndfc3Iero10Wu68N1etOE
scenes-app-mcp-analytics--dashboard-with-menu-bar--dark:
- hash: v1.k794b7964.29be085c9a74e345db1e01d2f6b00215a00cf0fecf0f103c12ac889120ba496c.Q9PSjP5NmIpX3_-JisenZc6BcEx-71p1k7cSZSBfwOs
+ hash: v1.k794b7964.8323af09a0cd4695627ee7f5123411d2a3e70ed8dc158fab63e0ffe818cb6ed0.CgDY9QxkvQmW2a9fiMdzeQmVM0GKMZMftulonVZDxUE
scenes-app-mcp-analytics--dashboard-with-menu-bar--light:
- hash: v1.k794b7964.fed2fab63229808ff080f6fbaba0ac2b62a142115aef7cabf7cf76e9b76df4c1.3RjkxSUK0AH36KxmtfENWCEu7H3bwvKzz0kyYQYcjGE
+ hash: v1.k794b7964.daa62a06d9a64b0ab59420f5ccf179e9a080215aa3b5bafb9894b7cc4cf54320.t3qsYgRM-SenY6FnNb2yfIZ2t0FEe21g51KCGRv_uXs
scenes-app-mcp-analytics--intent-clustering--dark:
hash: v1.k794b7964.9549b853f80d754b9d6ccf17ab144d24218143200c90df7af687e184e7de5329.Er1_HM8avmrqmulj2hCLnkp98-HeuRvF5ed3j-_jS2A
scenes-app-mcp-analytics--intent-clustering--light:
@@ -8517,9 +8517,25 @@ snapshots:
scenes-app-mcp-analytics-dashboard-cards--key-metrics-in-progress-bucket--light:
hash: v1.k794b7964.987a4b9f762bab3f88f39ea33fb0eca000d0e5f6aeb2c0a89e2979399f4d5797.ziZ_6D2TpdPk2pVJqrCMfEcmRufZDVVVqN51I5vIHgM
scenes-app-mcp-analytics-dashboard-cards--share-by-harness--dark:
- hash: v1.k794b7964.a4f65ae92d92d3600674689dc61f5ba834aac470154fb26b82821cb17b12cada.vAYLkto1-GBp1WeHETUeB5R0Pljn-RwHDW9h3bib1KQ
+ hash: v1.k794b7964.085facb7ddb323955c333d1471e181110b3a4e2f4b9515204835355e71bbaaef.1dQCdLYloR9Tk_UkxdWllVUrfTy5k69BzzX8yO-LErw
scenes-app-mcp-analytics-dashboard-cards--share-by-harness--light:
- hash: v1.k794b7964.c5eae070d2b0728ce676a8248650123f9a153ec8a9b9052f119d28b82e112e75.CdS-40DZGyT0t1Th9qh7g6Cc9Dgt__lEEujO7OXp4IM
+ hash: v1.k794b7964.522962a9f1db497cdab2d910a4106694d021d29dcce7731c79bf37733289e654.eRjJqHVTqxmuxdr-PxYb2IbzDECR1w56r2DNJsemHiY
+ scenes-app-mcp-analytics-dashboard-cards--share-by-harness-empty--dark:
+ hash: v1.k794b7964.f26fe244c8e64b1685ef88c9178d01b5bb8191bc704498c49a38ce64d0bfd621.v4ox5Nwy_Psv1OP0m3yEfARNPpjLDt8urQZeBzwxBy0
+ scenes-app-mcp-analytics-dashboard-cards--share-by-harness-empty--light:
+ hash: v1.k794b7964.97b4601df675b3aa697aa1ecc3dacb52e9c3d6494e2677252ecc788e312dc944.iz0C6lg8PM033M1FxfJJBTxpoBgrray2hQCR-BQ8CcY
+ scenes-app-mcp-analytics-dashboard-cards--share-by-harness-loading--dark:
+ hash: v1.k794b7964.d4aef6468be1e2dcd532ed036ffc85a7cf986c0907fc36cee53d0c29dd60fd51.iUsO1RBt1ViIZy7EC4AjQILEKELLIPckDJbmCVbeSVY
+ scenes-app-mcp-analytics-dashboard-cards--share-by-harness-loading--light:
+ hash: v1.k794b7964.ea60be490da88bff7b3d2fa17c0ef9b293f217d12a9519485b270703a52c717f.VgyhMlaA3w_XqwFTXOu8j78EhSM2wacTfbGdgG70hEk
+ scenes-app-mcp-analytics-dashboard-cards--share-by-harness-narrow--dark:
+ hash: v1.k794b7964.3b5423ed51c1b3f431a48935848aa150ed2ec1c3a64b4f14c0c49fc652001fb6.33TBGSLna7f3fznGdU3ngjJTjOw6k_c5N3_Hq7RcPY8
+ scenes-app-mcp-analytics-dashboard-cards--share-by-harness-narrow--light:
+ hash: v1.k794b7964.342976b023a228ba60c0cbd75d34e254c6a19e927232b5791a335d58544e7b28.hxuxBxQIwTjQEGyvuFJozWxfR6Gjax4eg3dqpPFsF-w
+ scenes-app-mcp-analytics-dashboard-cards--share-by-harness-other-only--dark:
+ hash: v1.k794b7964.b8cda2526a0a1bd86f44ba5872c568ad265083a62e61ca31d1fe61d19d3e025f.j9P2-fVJTa2eryh7vjg4yngGrgngi7xry3Wgay91YGs
+ scenes-app-mcp-analytics-dashboard-cards--share-by-harness-other-only--light:
+ hash: v1.k794b7964.3840a56231cceb8235aa7a2453ac98085a9d7d4512310bfc2d4b2c06504a6841.NaSlblb4-MUJVz5TGs6sFT-siZ63-pBuiLzaSyqyh8g
scenes-app-mcp-analytics-dashboard-cards--share-by-model--dark:
hash: v1.k794b7964.f1cd0d50270811709b21860ec24f74dbc4a0ccce9841fc41b4cecabcd97ca447.S1pSjSh-DsFc_Onzdgc7zvj6g4n5Q5YROMGTKnp3iuc
scenes-app-mcp-analytics-dashboard-cards--share-by-model--light:
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx b/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
index ff01a7f8d976..e95097652843 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
@@ -12,7 +12,7 @@ import { teamLogic } from 'scenes/teamLogic'
import { McpDateFilter } from './components/McpDateFilter'
import { ActivityChart } from './dashboard/ActivityChart'
-import { HarnessDonut } from './dashboard/HarnessDonut'
+import { HarnessBarChart } from './dashboard/HarnessBarChart'
import { KpiTiles } from './dashboard/KpiTiles'
import { ModelBarChart } from './dashboard/ModelBarChart'
import { NotableSessionsTable } from './dashboard/NotableSessionsTable'
@@ -122,7 +122,7 @@ export function MCPAnalyticsDashboardOverview(): JSX.Element {
incompleteTail={activityIncompleteTail}
/>
</div>
- <HarnessDonut rows={harnessRows} loading={harnessRowsLoading} theme={theme} />
+ <HarnessBarChart rows={harnessRows} loading={harnessRowsLoading} theme={theme} />
{hasKnownModelData ? <ModelBarChart rows={modelRows} theme={theme} /> : null}
</div>
<div className="grid grid-cols-1 gap-[22px] lg:grid-cols-2">
diff --git a/products/mcp_analytics/frontend/dashboard/DashboardCards.stories.tsx b/products/mcp_analytics/frontend/dashboard/DashboardCards.stories.tsx
index 42052098b29d..fc0e7d9c656f 100644
--- a/products/mcp_analytics/frontend/dashboard/DashboardCards.stories.tsx
+++ b/products/mcp_analytics/frontend/dashboard/DashboardCards.stories.tsx
@@ -15,7 +15,7 @@ import {
type ToolRow,
} from '../mcpDashboardOverviewLogic'
import { ActivityChart } from './ActivityChart'
-import { HarnessDonut } from './HarnessDonut'
+import { HarnessBarChart } from './HarnessBarChart'
import { KpiTiles } from './KpiTiles'
import { ModelBarChart } from './ModelBarChart'
import { NotableSessionsTable } from './NotableSessionsTable'
@@ -58,11 +58,13 @@ const TOOL_ROWS: ToolRow[] = [
]
const HARNESS_ROWS: HarnessRow[] = [
- { category: 'Claude Code', total_calls: 6200, errors: 240, error_rate_pct: 3.9, sessions: 820 },
- { category: 'Cursor', total_calls: 2100, errors: 96, error_rate_pct: 4.6, sessions: 410 },
- { category: 'OpenAI Codex', total_calls: 980, errors: 71, error_rate_pct: 7.2, sessions: 180 },
- { category: 'Claude.ai', total_calls: 760, errors: 22, error_rate_pct: 2.9, sessions: 240 },
- { category: 'VS Code', total_calls: 540, errors: 12, error_rate_pct: 2.2, sessions: 120 },
+ { category: 'OpenAI Codex', total_calls: 4200, errors: 84, error_rate_pct: 2, sessions: 600 },
+ { category: 'Claude Code', total_calls: 2800, errors: 112, error_rate_pct: 4, sessions: 400 },
+ { category: 'Claude Agent SDK', total_calls: 1600, errors: 48, error_rate_pct: 3, sessions: 200 },
+ { category: 'Cursor', total_calls: 1200, errors: 24, error_rate_pct: 2, sessions: 180 },
+ { category: 'Cowork', total_calls: 800, errors: 8, error_rate_pct: 1, sessions: 120 },
+ { category: 'Claude.ai', total_calls: 400, errors: 12, error_rate_pct: 3, sessions: 80 },
+ { category: 'Other', total_calls: 200, errors: 10, error_rate_pct: 5, sessions: 50 },
]
const MODEL_ROWS: ModelRow[] = [
@@ -221,7 +223,50 @@ export const DailyCallsAndErrorsInProgressBucket: Story = {
}
export const ShareByHarness: Story = {
- render: withTheme((theme) => <HarnessDonut rows={HARNESS_ROWS} loading={false} theme={theme} />),
+ render: withTheme((theme) => <HarnessBarChart rows={HARNESS_ROWS} loading={false} theme={theme} />),
+}
+
+export const ShareByHarnessNarrow: Story = {
+ render: () => (
+ <div className="w-80">
+ <HarnessBarChart
+ rows={[
+ {
+ category: 'Example custom client with a very long name',
+ total_calls: 1,
+ errors: 0,
+ error_rate_pct: 0,
+ sessions: 1,
+ },
+ ...HARNESS_ROWS.toReversed(),
+ { category: 'Claude Code (VS Code)', total_calls: 140, errors: 7, error_rate_pct: 5, sessions: 20 },
+ { category: 'opencode', total_calls: 80, errors: 0, error_rate_pct: 0, sessions: 16 },
+ { category: 'Antigravity', total_calls: 40, errors: 0, error_rate_pct: 0, sessions: 8 },
+ { category: 'Grok', total_calls: 20, errors: 1, error_rate_pct: 5, sessions: 4 },
+ ]}
+ loading={false}
+ theme={buildTheme()}
+ />
+ </div>
+ ),
+}
+
+export const ShareByHarnessLoading: Story = {
+ render: withTheme((theme) => <HarnessBarChart rows={[]} loading theme={theme} />),
+}
+
+export const ShareByHarnessEmpty: Story = {
+ render: withTheme((theme) => <HarnessBarChart rows={[]} loading={false} theme={theme} />),
+}
+
+export const ShareByHarnessOtherOnly: Story = {
+ render: withTheme((theme) => (
+ <HarnessBarChart
+ rows={[{ category: 'Other', total_calls: 15, errors: 0, error_rate_pct: 0, sessions: 3 }]}
+ loading={false}
+ theme={theme}
+ />
+ )),
}
export const ShareByModel: Story = {
diff --git a/products/mcp_analytics/frontend/dashboard/HarnessBarChart.tsx b/products/mcp_analytics/frontend/dashboard/HarnessBarChart.tsx
new file mode 100644
index 000000000000..4665ab387e3a
--- /dev/null
+++ b/products/mcp_analytics/frontend/dashboard/HarnessBarChart.tsx
@@ -0,0 +1,145 @@
+import { useMemo } from 'react'
+
+import {
+ BarChart,
+ type BarChartConfig,
+ type ChartTheme,
+ type Series,
+ type TooltipContext,
+ useChartLayout,
+} from '@posthog/quill-charts'
+import { Skeleton } from '@posthog/quill-primitives'
+
+import { useChartConfig } from 'lib/charts/hooks'
+import { formatPercentage } from 'lib/utils/numbers'
+
+import { type HarnessRow } from '../mcpDashboardOverviewLogic'
+import { Card, CardState } from './Card'
+import { ChartTooltip } from './ChartTooltip'
+import { formatNumber } from './formatters'
+import { HarnessLogo } from './harness'
+import { harnessColor } from './harnessRegistry'
+
+function HarnessBarLabels({ rows, totalCalls }: { rows: HarnessRow[]; totalCalls: number }): JSX.Element {
+ const { scales } = useChartLayout()
+ return (
+ <>
+ {rows.map((row) => (
+ <div
+ key={row.category}
+ className="absolute left-0 right-0 flex items-center justify-between gap-2 text-xs"
+ style={{ top: (scales.x(row.category) ?? 0) - 26 }}
+ >
+ <span className="flex min-w-0 items-center gap-1.5" title={row.category}>
+ <HarnessLogo category={row.category} />
+ <span className="truncate">{row.category}</span>
+ </span>
+ <span className="shrink-0 text-secondary tabular-nums">
+ {formatPercentage(totalCalls > 0 ? (row.total_calls / totalCalls) * 100 : 0, { compact: true })}{' '}
+ · {formatNumber(row.total_calls)} {row.total_calls === 1 ? 'call' : 'calls'}
+ </span>
+ </div>
+ ))}
+ </>
+ )
+}
+
+function renderTooltip(ctx: TooltipContext<HarnessRow & { share: number }>): JSX.Element | null {
+ const entry = ctx.seriesData[0]
+ const row = entry?.series.meta
+ if (!row) {
+ return null
+ }
+ return (
+ <ChartTooltip
+ title={row.category}
+ rows={[
+ ['Calls', formatNumber(row.total_calls)],
+ ['Share', formatPercentage(row.share, { compact: true })],
+ ['Sessions', formatNumber(row.sessions)],
+ ['Error rate', formatPercentage(row.error_rate_pct, { compact: true })],
+ ]}
+ />
+ )
+}
+
+export function HarnessBarChart({
+ rows,
+ loading,
+ theme,
+}: {
+ rows: HarnessRow[]
+ loading: boolean
+ theme: ChartTheme
+}): JSX.Element {
+ const totalCalls = rows.reduce((total, row) => total + row.total_calls, 0)
+ const sortedRows = useMemo(() => [...rows].sort((a, b) => b.total_calls - a.total_calls), [rows])
+ const labels = useMemo(() => sortedRows.map((row) => row.category), [sortedRows])
+ const series = useMemo<Series<HarnessRow & { share: number }>[]>(
+ () => [
+ {
+ key: 'calls',
+ label: 'Calls',
+ data: sortedRows.map((row) => row.total_calls),
+ bars: sortedRows.map((row) => ({
+ label: row.category,
+ color: harnessColor(theme, row.category),
+ meta: { ...row, share: totalCalls > 0 ? (row.total_calls / totalCalls) * 100 : 0 },
+ })),
+ },
+ ],
+ [sortedRows, theme, totalCalls]
+ )
+ const config = useChartConfig<BarChartConfig>(
+ () => ({
+ axisOrientation: 'horizontal',
+ hideXAxis: true,
+ hideYAxis: true,
+ showGrid: false,
+ showAxisLines: false,
+ showTickMarks: false,
+ margins: { left: 0, right: 0, top: 20, bottom: 0 },
+ barCornerRadius: 4,
+ bars: { bandPadding: 0.65, maxBandRange: rows.length * 40, minBarSize: 6, minBarSizeScope: 'hover' },
+ }),
+ [rows.length]
+ )
+
+ return (
+ <Card className="flex flex-1 flex-col" title="Share of calls by harness">
+ <CardState
+ loading={loading}
+ isEmpty={rows.length === 0}
+ skeleton={
+ <div className="h-80 space-y-6 py-3">
+ {Array.from({ length: 6 }).map((_, index) => (
+ <Skeleton key={index} className="h-4 w-full" />
+ ))}
+ </div>
+ }
+ empty={
+ <div className="flex h-80 items-center justify-center text-xs text-secondary">
+ No harness data yet.
+ </div>
+ }
+ >
+ <div className="text-xs text-secondary" translate="no">
+ {formatNumber(totalCalls)} {totalCalls === 1 ? 'call' : 'calls'}
+ </div>
+ <div
+ className="h-80 overflow-y-auto"
+ translate="no"
+ tabIndex={0}
+ role="region"
+ aria-label="Calls by harness"
+ >
+ <div className="flex min-h-80 flex-col" style={{ height: rows.length * 40 + 20 }}>
+ <BarChart series={series} labels={labels} theme={theme} config={config} tooltip={renderTooltip}>
+ <HarnessBarLabels rows={sortedRows} totalCalls={totalCalls} />
+ </BarChart>
+ </div>
+ </div>
+ </CardState>
+ </Card>
+ )
+}
diff --git a/products/mcp_analytics/frontend/dashboard/HarnessDonut.tsx b/products/mcp_analytics/frontend/dashboard/HarnessDonut.tsx
deleted file mode 100644
index 63f4d5278442..000000000000
--- a/products/mcp_analytics/frontend/dashboard/HarnessDonut.tsx
+++ /dev/null
@@ -1,150 +0,0 @@
-import { useCallback, useMemo } from 'react'
-
-import {
- type ChartTheme,
- PieChart,
- type PieChartConfig,
- type Series,
- type TooltipContext,
- useRadialLayout,
-} from '@posthog/quill-charts'
-import { Skeleton } from '@posthog/quill-primitives'
-
-import { formatPercentage } from 'lib/utils/numbers'
-
-import { type HarnessRow } from '../mcpDashboardOverviewLogic'
-import { Card } from './Card'
-import { ChartTooltip } from './ChartTooltip'
-import { formatNumber } from './formatters'
-import { HarnessPill } from './harness'
-import { harnessLogo, harnessSliceColor } from './harnessRegistry'
-
-const HARNESS_DONUT_CONFIG: PieChartConfig = {
- innerRadiusRatio: 0.6,
- // Built-in text labels are off — HarnessSliceLabels draws logo pills instead.
- showLabelOnSlice: false,
- showValueOnSlice: false,
-}
-
-// Slices smaller than this don't get a logo overlay — it wouldn't fit on the arc.
-const MIN_LABELLED_SLICE_FRACTION = 0.05
-
-// Rendered as a PieChart child so it can read the slice geometry from the radial layout context.
-function HarnessSliceLabels(): JSX.Element | null {
- const { layout } = useRadialLayout()
- const midRadius = layout.innerRadius + (layout.outerRadius - layout.innerRadius) / 2
- return (
- <>
- {layout.slices.map((slice) => {
- if (slice.fraction < MIN_LABELLED_SLICE_FRACTION) {
- return null
- }
- const x = layout.cx + Math.sin(slice.centroidAngle) * midRadius
- const y = layout.cy - Math.cos(slice.centroidAngle) * midRadius
- const category = slice.series.label
- const logo = harnessLogo(category)
- return (
- <div
- key={slice.series.key}
- className="pointer-events-none absolute"
- style={{ left: x, top: y, transform: 'translate(-50%, -50%)' }}
- >
- {logo ? (
- <img
- src={logo.src}
- alt={logo.alt}
- title={category}
- className="h-7 w-7 object-contain"
- style={{ filter: 'drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45))' }}
- />
- ) : (
- <HarnessPill category={category} />
- )}
- </div>
- )
- })}
- </>
- )
-}
-
-export function HarnessDonut({
- rows,
- loading,
- theme,
-}: {
- rows: HarnessRow[]
- loading: boolean
- theme: ChartTheme
-}): JSX.Element {
- const totalCalls = rows.reduce((acc, r) => acc + r.total_calls, 0)
- const series = useMemo<Series<HarnessRow>[]>(
- () =>
- rows.map((r, i) => ({
- key: r.category,
- label: r.category,
- color: harnessSliceColor(theme, r.category, i),
- data: [r.total_calls],
- meta: r,
- })),
- [rows, theme]
- )
- const renderTooltip = useCallback((ctx: TooltipContext<HarnessRow>): JSX.Element | null => {
- const entry = ctx.seriesData[0]
- const row = entry?.series.meta
- if (!row) {
- return null
- }
- const share = entry.fraction !== undefined ? entry.fraction * 100 : 0
- return (
- <ChartTooltip
- title={row.category}
- rows={[
- ['Calls', String(row.total_calls)],
- ['Share', formatPercentage(share, { compact: true })],
- ['Sessions', String(row.sessions)],
- ['Error rate', formatPercentage(row.error_rate_pct, { compact: true })],
- ]}
- />
- )
- }, [])
-
- if (loading && rows.length === 0) {
- return (
- <Card className="flex flex-1 flex-col" title="Share of calls by harness">
- <div className="flex min-h-[300px] flex-1 items-center justify-center">
- <Skeleton className="h-[180px] w-[180px] rounded-full" />
- </div>
- </Card>
- )
- }
- if (rows.length === 0) {
- return (
- <Card className="flex flex-1 flex-col" title="Share of calls by harness">
- <div className="flex min-h-[300px] flex-1 items-center justify-center text-[12px] text-secondary">
- No harness data yet.
- </div>
- </Card>
- )
- }
-
- return (
- <Card className="flex flex-1 flex-col" title="Share of calls by harness">
- <div className="flex min-h-[300px] flex-1 flex-col">
- <PieChart<HarnessRow>
- series={series}
- theme={theme}
- config={HARNESS_DONUT_CONFIG}
- tooltip={renderTooltip}
- centerLabel={
- <div className="text-center">
- <div className="text-3xl font-semibold text-primary">{formatNumber(totalCalls)}</div>
- <div className="text-xs text-secondary">calls</div>
- </div>
- }
- >
- <HarnessSliceLabels />
- </PieChart>
- </div>
- </Card>
- )
-}
diff --git a/products/mcp_analytics/frontend/dashboard/harnessRegistry.test.ts b/products/mcp_analytics/frontend/dashboard/harnessRegistry.test.ts
new file mode 100644
index 000000000000..5a692e54b31c
--- /dev/null
+++ b/products/mcp_analytics/frontend/dashboard/harnessRegistry.test.ts
@@ -0,0 +1,51 @@
+import { type ChartTheme } from '@posthog/quill-charts'
+
+import { buildTheme } from 'lib/charts/utils/theme'
+
+import { harnessColor } from './harnessRegistry'
+
+const theme: ChartTheme = { ...buildTheme(), colors: ['#204080', '#804020'], axisColor: '#888888' }
+
+describe('harnessColor', () => {
+ it('keeps colors attached to harness names when their ranking changes', () => {
+ const harnesses = ['OpenAI Codex', 'Claude Code', 'Claude Agent SDK', 'opencode', 'Example custom client']
+ const colors = Object.fromEntries(harnesses.map((label) => [label, harnessColor(theme, label)]))
+ const reorderedColors = Object.fromEntries(
+ harnesses.toReversed().map((label) => [label, harnessColor(theme, label)])
+ )
+
+ expect(reorderedColors).toEqual(colors)
+ expect(Object.values(colors).every(Boolean)).toBe(true)
+ })
+
+ it.each([
+ ['Claude Code', 'Claude Agent SDK'],
+ ['OpenAI Codex', 'ChatGPT'],
+ ])('distinguishes %s from %s within the same family', (first, second) => {
+ expect(harnessColor(theme, first)).not.toEqual(harnessColor(theme, second))
+ })
+
+ it.each(['Other', 'Unidentified client'])('keeps %s neutral with calls from identified harnesses', (label) => {
+ expect(harnessColor(theme, label)).toBe(theme.axisColor)
+ expect(harnessColor(theme, 'OpenAI Codex')).not.toBe(theme.axisColor)
+ })
+
+ it.each(['Claude Code', 'OpenAI Codex', 'VS Code', 'CodeRabbit'])(
+ 'preserves the brand color for %s independently of the categorical palette',
+ (label) => {
+ expect(harnessColor({ ...theme, colors: [] }, label)).toBe(harnessColor(theme, label))
+ }
+ )
+
+ it.each(['Cursor', 'Grok', 'Notion', 'opencode', 'Windsurf'])(
+ 'adapts the monochrome %s color to the chart theme',
+ (label) => {
+ expect(harnessColor(theme, label)).toBe(theme.axisColor)
+ expect(harnessColor({ ...theme, axisColor: '#eeeeee' }, label)).toBe('#eeeeee')
+ }
+ )
+
+ it('uses the neutral color when the theme has no palette', () => {
+ expect(harnessColor({ ...theme, colors: [] }, 'Example custom client')).toBe(theme.axisColor)
+ })
+})
diff --git a/products/mcp_analytics/frontend/dashboard/harnessRegistry.ts b/products/mcp_analytics/frontend/dashboard/harnessRegistry.ts
index 717ef9bb0e1e..2ffbed92e36b 100644
--- a/products/mcp_analytics/frontend/dashboard/harnessRegistry.ts
+++ b/products/mcp_analytics/frontend/dashboard/harnessRegistry.ts
@@ -1,5 +1,8 @@
import { type ChartTheme } from '@posthog/quill-charts'
+import { lightenDarkenColor, toOpaqueHex } from 'lib/utils/colors'
+import { hashCodeForString } from 'lib/utils/strings'
+
import antigravityLogo from '../harness-logos/antigravity.png'
import claudeLogo from '../harness-logos/claude.svg'
import coderabbitLogo from '../harness-logos/coderabbit.svg'
@@ -22,47 +25,55 @@ export interface HarnessLogo {
alt: string
}
+const HARNESS_BRAND_COLORS = {
+ claude: '#d97757',
+ openai: '#74aa9c',
+ vscode: '#007acc',
+ coderabbit: '#ff570a',
+} as const
+
interface HarnessDescriptor {
logo?: HarnessLogo
- // Index into the data-viz palette, chosen so the logo drawn on top keeps
- // enough contrast against its slice.
+ color?: keyof typeof HARNESS_BRAND_COLORS | 'monochrome'
+ // Index into the data-viz palette for harnesses without a brand color.
colorIndex?: number
+ shade?: number
}
-// Maps a *resolved* harness label to its logo and slice colour. The label itself is
+// Maps a *resolved* harness label to its logo and chart colour. The label itself is
// produced server-side by the backend classifier (products/mcp_analytics/backend/mcp_harness.py,
// the single source of truth); this map owns only the frontend-specific concerns the backend
// has no opinion on. Keys must match HARNESS_LABELS / harness_label_sql in mcp_harness.py.
// Exported so tests can assert coverage against the backend HARNESS_LABELS tuple.
export const HARNESS_BY_LABEL: Record<string, HarnessDescriptor> = {
- 'Claude Desktop': { logo: { src: claudeLogo, alt: 'Claude Desktop logo' }, colorIndex: 5 },
- 'Claude Code (VS Code)': { logo: { src: claudeLogo, alt: 'Claude Code logo' }, colorIndex: 6 },
- 'Claude Agent SDK': { logo: { src: claudeLogo, alt: 'Claude Agent SDK logo' }, colorIndex: 7 },
- 'Claude Code': { logo: { src: claudeLogo, alt: 'Claude Code logo' }, colorIndex: 0 },
- 'Claude.ai': { logo: { src: claudeLogo, alt: 'Claude.ai logo' }, colorIndex: 2 },
- 'Anthropic API': {},
- Cowork: { logo: { src: claudeLogo, alt: 'Cowork logo' }, colorIndex: 3 },
- 'Claude Design': { logo: { src: claudeLogo, alt: 'Claude Design logo' }, colorIndex: 4 },
- ChatGPT: { logo: { src: openaiLogo, alt: 'ChatGPT logo' }, colorIndex: 8 },
- 'OpenAI Agent Builder': { logo: { src: openaiLogo, alt: 'OpenAI Agent Builder logo' }, colorIndex: 9 },
- 'OpenAI Responses API': { logo: { src: openaiLogo, alt: 'OpenAI Responses API logo' }, colorIndex: 10 },
- OpenAI: { logo: { src: openaiLogo, alt: 'OpenAI logo' }, colorIndex: 1 },
- 'OpenAI Codex': { logo: { src: openaiLogo, alt: 'OpenAI Codex logo' }, colorIndex: 13 },
- Grok: { logo: { src: grokLogo, alt: 'Grok logo' }, colorIndex: 14 },
- Cursor: { logo: { src: cursorLogo, alt: 'Cursor logo' }, colorIndex: 12 },
- 'VS Code': { logo: { src: vscodeLogo, alt: 'VS Code logo' }, colorIndex: 11 },
- Windsurf: { logo: { src: windsurfLogo, alt: 'Windsurf logo' } },
- Replit: { logo: { src: replitLogo, alt: 'Replit logo' } },
- Lovable: { logo: { src: lovableLogo, alt: 'Lovable logo' } },
- Manus: { logo: { src: manusLogo, alt: 'Manus logo' } },
- CodeRabbit: { logo: { src: coderabbitLogo, alt: 'CodeRabbit logo' } },
- Notion: { logo: { src: notionLogo, alt: 'Notion logo' } },
- Linear: { logo: { src: linearLogo, alt: 'Linear logo' } },
- LibreChat: { logo: { src: librechatLogo, alt: 'LibreChat logo' } },
- Pi: { logo: { src: piLogo, alt: 'Pi logo' } },
- Antigravity: { logo: { src: antigravityLogo, alt: 'Antigravity logo' } },
+ 'Claude Desktop': { logo: { src: claudeLogo, alt: 'Claude Desktop logo' }, color: 'claude', shade: -8 },
+ 'Claude Code (VS Code)': { logo: { src: claudeLogo, alt: 'Claude Code logo' }, color: 'claude', shade: -4 },
+ 'Claude Agent SDK': { logo: { src: claudeLogo, alt: 'Claude Agent SDK logo' }, color: 'claude', shade: 4 },
+ 'Claude Code': { logo: { src: claudeLogo, alt: 'Claude Code logo' }, color: 'claude', shade: 0 },
+ 'Claude.ai': { logo: { src: claudeLogo, alt: 'Claude.ai logo' }, color: 'claude', shade: 8 },
+ 'Anthropic API': { color: 'claude', shade: -12 },
+ Cowork: { logo: { src: claudeLogo, alt: 'Cowork logo' }, color: 'claude', shade: 12 },
+ 'Claude Design': { logo: { src: claudeLogo, alt: 'Claude Design logo' }, color: 'claude', shade: 16 },
+ ChatGPT: { logo: { src: openaiLogo, alt: 'ChatGPT logo' }, color: 'openai', shade: 0 },
+ 'OpenAI Agent Builder': { logo: { src: openaiLogo, alt: 'OpenAI Agent Builder logo' }, color: 'openai', shade: 4 },
+ 'OpenAI Responses API': { logo: { src: openaiLogo, alt: 'OpenAI Responses API logo' }, color: 'openai', shade: -4 },
+ OpenAI: { logo: { src: openaiLogo, alt: 'OpenAI logo' }, color: 'openai', shade: 8 },
+ 'OpenAI Codex': { logo: { src: openaiLogo, alt: 'OpenAI Codex logo' }, color: 'openai', shade: -8 },
+ Grok: { logo: { src: grokLogo, alt: 'Grok logo' }, color: 'monochrome' },
+ Cursor: { logo: { src: cursorLogo, alt: 'Cursor logo' }, color: 'monochrome' },
+ 'VS Code': { logo: { src: vscodeLogo, alt: 'VS Code logo' }, color: 'vscode' },
+ Windsurf: { logo: { src: windsurfLogo, alt: 'Windsurf logo' }, color: 'monochrome' },
+ Replit: { logo: { src: replitLogo, alt: 'Replit logo' }, colorIndex: 11, shade: 15 },
+ Lovable: { logo: { src: lovableLogo, alt: 'Lovable logo' }, colorIndex: 4 },
+ Manus: { logo: { src: manusLogo, alt: 'Manus logo' }, color: 'monochrome' },
+ CodeRabbit: { logo: { src: coderabbitLogo, alt: 'CodeRabbit logo' }, color: 'coderabbit' },
+ Notion: { logo: { src: notionLogo, alt: 'Notion logo' }, color: 'monochrome' },
+ Linear: { logo: { src: linearLogo, alt: 'Linear logo' }, colorIndex: 9 },
+ LibreChat: { logo: { src: librechatLogo, alt: 'LibreChat logo' }, colorIndex: 14 },
+ Pi: { logo: { src: piLogo, alt: 'Pi logo' }, color: 'monochrome' },
+ Antigravity: { logo: { src: antigravityLogo, alt: 'Antigravity logo' }, colorIndex: 7 },
Poke: {},
- opencode: { logo: { src: opencodeLogo, alt: 'opencode logo' } },
+ opencode: { logo: { src: opencodeLogo, alt: 'opencode logo' }, color: 'monochrome' },
Kiro: {},
'Desktop Commander': {},
'PostHog CLI': {},
@@ -72,7 +83,21 @@ export function harnessLogo(label: string): HarnessLogo | undefined {
return HARNESS_BY_LABEL[label]?.logo
}
-export function harnessSliceColor(theme: ChartTheme, label: string, fallbackIndex: number): string {
- const index = HARNESS_BY_LABEL[label]?.colorIndex ?? fallbackIndex
- return theme.colors[index % theme.colors.length]
+export function harnessColor(theme: ChartTheme, label: string): string | undefined {
+ if (label === 'Other' || label === 'Unidentified client') {
+ return theme.axisColor
+ }
+ const descriptor = HARNESS_BY_LABEL[label]
+ if (descriptor?.color === 'monochrome') {
+ return theme.axisColor
+ }
+ const index = descriptor?.colorIndex ?? hashCodeForString(label)
+ const base = descriptor?.color ? HARNESS_BRAND_COLORS[descriptor.color] : theme.colors[index % theme.colors.length]
+ if (!base) {
+ return theme.axisColor
+ }
+ const hex = toOpaqueHex(base)
+ return descriptor?.shade && /^#[\da-f]{3}([\da-f]{3})?$/i.test(hex)
+ ? lightenDarkenColor(hex, descriptor.shade)
+ : base
}