: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
fix(mcp-analytics): dash the in-progress bucket on a tool's report (#75888)
Georgis Andonis03191988cc67
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx b/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsxindex 081032abdd92..fbffdc03bb12 100644--- a/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx+++ b/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx@@ -228,6 +228,7 @@ function StatTiles({theme,dateRangeLabel,interval,+ incompleteTail,}: {summary: ToolSummary | nullloading: boolean@@ -235,6 +236,10 @@ function StatTiles({theme: ChartThemedateRangeLabel: stringinterval: TimeInterval+ // When true, the final bucket is the current in-progress interval — dash the sparkline from+ // there so a partial period doesn't read as a decline. Required rather than optional: an+ // omitted prop silently renders the partial bucket as settled data.+ incompleteTail: boolean}): JSX.Element {const calls = summary?.calls ?? 0const errors = summary?.errors ?? 0@@ -311,6 +316,7 @@ function StatTiles({theme={theme}restingSubtitle={dateRangeLabel}sparklineHeight={40}+ sparklineDashedFromIndex={incompleteTail ? sparkLabels.length - 1 : undefined}/>))}</div>@@ -410,12 +416,16 @@ const SERIES_META: Record<TrendSeriesKey, { label: string; colorIndex: number }>p95: { label: 'p95', colorIndex: 0 },}-function seriesFor(data: DailyChartData, theme: ChartTheme, keys: TrendSeriesKey[]): Series[] {+// `incompleteTail` is only true when the window has ≥2 buckets (lastBucketIsInProgress owns that+// rule), and every series is filled to the bucket count, so the final segment exists.+function seriesFor(data: DailyChartData, theme: ChartTheme, keys: TrendSeriesKey[], incompleteTail: boolean): Series[] {+ const stroke = incompleteTail ? { partial: { fromIndex: data.labels.length - 1 } } : undefinedreturn keys.map((key) => ({key,label: SERIES_META[key].label,color: theme.colors[SERIES_META[key].colorIndex],data: data[key],+ stroke,}))}@@ -493,18 +503,19 @@ function MCPAnalyticsToolDetailContent({ toolName }: { toolName: string }): JSX.dateRangeLabel,dateFilter,interval,+ incompleteTail,} = useValues(mcpAnalyticsToolDetailLogic({ toolName }))const { selectFailure } = useActions(mcpAnalyticsToolDetailLogic({ toolName }))const { timezone } = useValues(teamLogic)const theme = useChartTheme()const callsSeries = useMemo<Series[]>(- () => seriesFor(dailyChartData, theme, ['calls', 'errors']),- [dailyChartData, theme]+ () => seriesFor(dailyChartData, theme, ['calls', 'errors'], incompleteTail),+ [dailyChartData, theme, incompleteTail])const latencySeries = useMemo<Series[]>(- () => seriesFor(dailyChartData, theme, ['p50', 'p95']),- [dailyChartData, theme]+ () => seriesFor(dailyChartData, theme, ['p50', 'p95'], incompleteTail),+ [dailyChartData, theme, incompleteTail])const countsConfig = useChartConfig(() => trendChartConfig(timezone, interval), [timezone, interval])const latencyConfig = useChartConfig(@@ -534,6 +545,7 @@ function MCPAnalyticsToolDetailContent({ toolName }: { toolName: string }): JSX.theme={theme}dateRangeLabel={dateRangeLabel}interval={interval}+ incompleteTail={incompleteTail}/></div>diff --git a/products/mcp_analytics/frontend/dashboard/MetricTile.tsx b/products/mcp_analytics/frontend/dashboard/MetricTile.tsxindex 75cda9b06505..7269840e9bbe 100644--- a/products/mcp_analytics/frontend/dashboard/MetricTile.tsx+++ b/products/mcp_analytics/frontend/dashboard/MetricTile.tsx@@ -26,6 +26,8 @@ export interface MetricTileProps {changeTooltip?: stringhoverChangeFromPreviousPoint?: booleansparklineHeight?: number+ // Dash the sparkline from this index on, for a trailing bucket that is still collecting.+ sparklineDashedFromIndex?: numberclassName?: string}@@ -44,6 +46,7 @@ export function MetricTile({changeTooltip,hoverChangeFromPreviousPoint = false,sparklineHeight,+ sparklineDashedFromIndex,className,}: MetricTileProps): JSX.Element {const hasSparkline = data != null && data.length > 0@@ -69,6 +72,7 @@ export function MetricTile({hoverChangeFromPreviousPoint={hoverChangeFromPreviousPoint}restingSubtitle={restingSubtitle}sparklineHeight={sparklineHeight}+ sparklineDashedFromIndex={sparklineDashedFromIndex}><MetricHeader><MetricTitle>{label}</MetricTitle>diff --git a/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.test.ts b/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.test.tsindex 8ea0675c8512..87df8da5c5af 100644--- a/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.test.ts+++ b/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.test.ts@@ -65,6 +65,32 @@ describe('buildDailyChartData', () => {})})+describe('incompleteTail', () => {+ beforeEach(() => {+ jest.clearAllMocks()+ initKeaTests()+ jest.spyOn(mockApi, 'query').mockResolvedValue({ results: [] })+ })++ // An open-ended relative window always ends in the bucket that is still collecting, and a window+ // that closed in the past never does, so this holds whenever the suite runs.+ it.each([+ ['an open-ended window', '-30d', null, true],+ ['a window that already closed', '2026-06-01', '2026-06-10', false],+ ])('is %s: %s', async (_label, dateFrom, dateTo, expected) => {+ const logic = mcpAnalyticsToolDetailLogic({ toolName: 'query_run' })+ logic.mount()+ await expectLogic(logic, () => {+ logic.actions.setDateFilter(dateFrom, dateTo)+ }).toFinishAllListeners()+ // Seeded directly: with no rows the chart data short-circuits to empty, and an empty axis+ // has no tail to dash either way.+ logic.actions.loadDailyStatsSuccess([stat({ day: '2026-06-02 00:00:00', calls: 1 })])++ expect(logic.values.incompleteTail).toBe(expected)+ })+})+describe('failure drill-down', () => {beforeEach(() => {jest.clearAllMocks()diff --git a/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.ts b/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.tsindex 75b9df616be5..31b26708bfc1 100644--- a/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.ts+++ b/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.ts@@ -23,7 +23,7 @@ import {} from '~/queries/schema/schema-general'import { IntervalType } from '~/types'-import { buildBucketKeys, normalizeBucket } from './timeBuckets'+import { buildBucketKeys, lastBucketIsInProgress, normalizeBucket } from './timeBuckets'export interface ToolSummary {calls: numbererrors: number@@ -143,6 +143,7 @@ export interface mcpAnalyticsToolDetailLogicValues {failureBucketsLoading: booleanfailureOccurrences: MCPToolFailureOccurrenceItem[]failureOccurrencesLoading: boolean+ incompleteTail: booleanintentCoverage: IntentCoverage | nullintentCoverageLoading: booleaninterval: IntervalType@@ -353,6 +354,7 @@ export interface mcpAnalyticsToolDetailLogicMeta {interval: IntervalType,timezone: string) => DailyChartData+ incompleteTail: (dailyChartData: DailyChartData, interval: IntervalType, timezone: string) => booleaninterval: (dateFilter: DateFilter) => IntervalTypedateRange: (dateFilter: DateFilter, timezone: string) => DateRangedateRangeLabel: (dateFilter: DateFilter) => string@@ -616,6 +618,14 @@ export const mcpAnalyticsToolDetailLogic = kea<mcpAnalyticsToolDetailLogicType>(},],+ // The trend charts and sparklines dash the final segment when it is the current, still-+ // collecting interval, so a partial period doesn't read as a fall in calls or a latency win.+ incompleteTail: [+ (s) => [s.dailyChartData, s.interval, teamLogic.selectors.timezone],+ (dailyChartData: DailyChartData, interval: IntervalType, timezone: string): boolean =>+ lastBucketIsInProgress(dailyChartData.labels, timezone, interval),+ ],+// Grouping interval for the daily series — PostHog's standard auto-choice, matching the query's// dateTrunc so a sub-day window buckets by hour/minute instead of collapsing to one day point.interval: [