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): align activity counts and scrolling (#92035)

Lucas Faria5041db1e232f
diff --git a/docs/internal/mcp-analytics-activity.md b/docs/internal/mcp-analytics-activity.md
new file mode 100644
index 000000000000..e32f34abd54f
--- /dev/null
+++ b/docs/internal/mcp-analytics-activity.md
@@ -0,0 +1,19 @@
+# MCP Analytics activity counts
+
+The Activity banner summarizes the activity overview's fixed 30-day window. Its
+call count, client count, favorite tool, and failures all come from that overview.
+The lifetime onboarding signal only determines whether to show first-call copy;
+it does not replace the 30-day count. A project with older calls and no recent
+activity sees "No tool calls in the last 30 days".
+
+The live activity table defaults to 30 days, but its date and property filters
+apply only to the table. Changing them does not change the banner's window.
+Event count queries preserve the selected event names and date range. The total
+removes property and `where` filters; the matched count retains them. Both retain
+fixed properties that scope the table.
+
+The activity table labels counts and pagination as "tool calls". Its toolbar
+stays fixed while results scroll through LemonTable's content scroll support.
+Other DataTable consumers opt into this behavior through
+`QueryContext.dataTableAllowContentScroll` and can customize count and pagination
+nouns through `QueryContext.dataTableNouns`.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 66f62be6fed0..e07e7d2f44f5 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -7905,9 +7905,9 @@ snapshots:
scenes-app-max-ai-replay-vision-scan-widget--with-skipped--light:
hash: v1.k794b7964.c543228b0f31abb2aae3b274819abdee4ba6a89fb3324fc6aaa2b18aefee5815.S9etTEY8oT2JhOgLO5hdc6VqvbvYhD-nU4P1WKh24yg
scenes-app-mcp-analytics--activity--dark:
- hash: v1.k794b7964.e43f01115e658ff2fea09722ea5cb300bbbf69c2103208d69804d34502a35f62.aQyYxy1CZmD1iLTeyjuJ_6k3g1rmepel-hBO4QH_5AI
+ hash: v1.k794b7964.24c2ea47b4646d797ff267400c12d79a7456fd00d54135b4374cdf2a85f80b7c.3WZ2BzGDB7XDOtIlTzMu05xM_Xn2EBUw9Z0EDhUM94A
scenes-app-mcp-analytics--activity--light:
- hash: v1.k794b7964.dd75d6391ed61626117b8663455371f781bf194a29d0ebf20fb6c34d82703447.81TtCF9h-4bTKpiXUIAGV_qvAspkri9Ro014hr9uTIA
+ hash: v1.k794b7964.ebade8669d9a80698871d805207c0d9ac8a69d0f9e2f6667afb7499e176f7004.hp-uMrZGUIrd8_BFPt-cpTUF_qO-4M8v6pzKMEjQjmg
scenes-app-mcp-analytics--dashboard--dark:
hash: v1.k794b7964.28e8830f28c77c1815afd94747a5f8633a0ff6dff72e7e8a104a84e3d131730c.-r295uHlJ_mpxJzjEHlMP9iM4FsOwaWVrRcfaW-Q4zM
scenes-app-mcp-analytics--dashboard--light:
diff --git a/frontend/src/queries/nodes/DataNode/LoadNext.tsx b/frontend/src/queries/nodes/DataNode/LoadNext.tsx
index 0b215925b2ab..567864ea64dc 100644
--- a/frontend/src/queries/nodes/DataNode/LoadNext.tsx
+++ b/frontend/src/queries/nodes/DataNode/LoadNext.tsx
@@ -12,9 +12,10 @@ import { DEFAULT_PAGE_SIZE } from '../DataVisualization/Components/Table'
interface LoadNextProps {
query: DataNode
+ nouns?: [string, string]
}
-export function LoadNext({ query }: LoadNextProps): JSX.Element {
+export function LoadNext({ query, nouns = ['entry', 'entries'] }: LoadNextProps): JSX.Element {
const { canLoadNextData, nextDataLoading, numberOfRows, hasMoreData, dataLimit } = useValues(dataNodeLogic)
const { loadNextData } = useActions(dataNodeLogic)
@@ -40,16 +41,17 @@ export function LoadNext({ query }: LoadNextProps): JSX.Element {
} else if (isHogQLQuery(query) && !canLoadNextData && hasMoreData && dataLimit) {
return `Default limit of ${dataLimit} rows reached. Try adding a LIMIT clause to adjust.`
}
+ const noun = numberOfRows === 1 ? nouns[0] : nouns[1]
let result = `Showing ${
hasMoreData && (numberOfRows ?? 0) > 1 ? 'first ' : canLoadNextData || numberOfRows === 1 ? '' : 'all '
- }${numberOfRows === 1 ? 'one' : numberOfRows} ${numberOfRows === 1 ? 'entry' : 'entries'}`
+ }${numberOfRows === 1 ? 'one' : numberOfRows} ${noun}`
if (canLoadNextData) {
result += nextDataLoading ? ' – loading more…' : ' – click to load more'
} else if (hasMoreData) {
result += ' – reached the end of results'
}
return result
- }, [query, dataLimit, numberOfRows, canLoadNextData, nextDataLoading, hasMoreData])
+ }, [query, dataLimit, numberOfRows, canLoadNextData, nextDataLoading, hasMoreData, nouns])
// pagination component exists
if (
diff --git a/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.ts b/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.ts
index 24aace056ffa..e86d0e007ec3 100644
--- a/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.ts
+++ b/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.ts
@@ -241,6 +241,37 @@ describe('dataNodeLogic', () => {
})
})
+ it.each([{ event: '$mcp_tool_call' }, { events: ['$mcp_tool_call'] }])(
+ 'keeps the $event event scope in count queries',
+ (eventScope) => {
+ const properties = [{ key: '$mcp_is_error', type: 'event', value: true, operator: 'exact' as const }]
+ logic = dataNodeLogic({
+ autoLoad: false,
+ key: testUniqueKey,
+ query: setLatestVersionsOnQuery({
+ kind: NodeKind.EventsQuery,
+ select: ['*'],
+ ...eventScope,
+ properties,
+ }),
+ })
+ logic.mount()
+
+ expect(logic.values.totalCountQuery).toMatchObject({
+ kind: NodeKind.EventsQuery,
+ ...eventScope,
+ properties: undefined,
+ select: ['count(*)'],
+ })
+ expect(logic.values.filteredCountQuery).toMatchObject({
+ kind: NodeKind.EventsQuery,
+ ...eventScope,
+ properties,
+ select: ['count(*)'],
+ })
+ }
+ )
+
it('clamps EventsQuery pagination to the maximum accumulated rows', async () => {
const results = [
[
diff --git a/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts b/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
index 2f965b6c45ab..39dc45fe9217 100644
--- a/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
+++ b/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
@@ -1859,7 +1859,6 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
}
if (isEventsQuery(query)) {
return !!(
- query.event ||
(query.properties && query.properties.length > 0) ||
(query.where && query.where.length > 0) ||
(query.fixedProperties && query.fixedProperties.length > 0)
@@ -1892,8 +1891,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
orderBy: undefined,
limit: undefined,
offset: undefined,
- // Remove all filters for total count
- event: undefined,
+ // Keep the selected event scope while removing property filters.
properties: undefined,
where: undefined,
} as EventsQuery
diff --git a/frontend/src/queries/nodes/DataTable/DataTable.tsx b/frontend/src/queries/nodes/DataTable/DataTable.tsx
index fa4c51e22f52..9da7d78c717c 100644
--- a/frontend/src/queries/nodes/DataTable/DataTable.tsx
+++ b/frontend/src/queries/nodes/DataTable/DataTable.tsx
@@ -952,7 +952,9 @@ export function DataTable({
const shouldShowCount = showCount && sourceFeatures.has(QueryFeature.showCount)
const secondRowLeft = [
showReload ? <Reload key="reload" /> : null,
- showCount && sourceFeatures.has(QueryFeature.showCount) ? <DataTableCount key="count" /> : null,
+ showCount && sourceFeatures.has(QueryFeature.showCount) ? (
+ <DataTableCount key="count" nouns={context?.dataTableNouns} />
+ ) : null,
shouldShowCount && showElapsedTime ? <LemonDivider vertical={true} key="divider" /> : null,
showElapsedTime ? <ElapsedTime key="elapsed-time" showTimings={showTimings} /> : null,
].filter((x) => !!x)
@@ -1010,7 +1012,7 @@ export function DataTable({
return (
<BindLogic logic={dataTableLogic} props={dataTableLogicProps}>
<BindLogic logic={dataNodeLogic} props={dataNodeLogicProps}>
- <div className="relative w-full flex flex-col gap-2 flex-1 h-full">
+ <div className="relative w-full flex flex-col gap-2 flex-1 h-full min-h-0">
{showHogQLEditor && isHogQLQuery(query.source) && !isReadOnly ? (
<HogQLQueryEditor query={query.source} setQuery={setQuerySource} embedded={embedded} />
) : null}
@@ -1064,7 +1066,12 @@ export function DataTable({
<div className="absolute right-0 z-10 p-1">{editorButton}</div>
) : null}
{showResultsTable && (
- <div className="relative">
+ <div
+ className={clsx(
+ 'relative',
+ context?.dataTableAllowContentScroll && 'min-h-0 flex-1 overflow-hidden'
+ )}
+ >
{usedWebAnalyticsLazyPrecompute ? (
<PreAggregatedBadge
variant="precomputed"
@@ -1076,6 +1083,7 @@ export function DataTable({
<LemonTable
data-attr={dataAttr}
className="DataTable"
+ allowContentScroll={context?.dataTableAllowContentScroll}
loading={responseLoading && !nextDataLoading && !newDataLoading}
columns={lemonColumns}
tableLayout={context?.tableLayout}
@@ -1143,9 +1151,10 @@ export function DataTable({
(dataTableRows ?? []).length > 0 &&
(context?.showLoadNextButton ||
!sourceFeatures.has(QueryFeature.hideLoadNextButton)) ? (
- <LoadNext query={query.source} />
+ <LoadNext query={query.source} nouns={context?.dataTableNouns} />
) : null
}
+ nouns={context?.dataTableNouns}
onRow={onRow}
pinnedColumns={query.pinnedColumns}
rowActions={rowActions}
diff --git a/frontend/src/queries/nodes/DataTable/DataTableCount.tsx b/frontend/src/queries/nodes/DataTable/DataTableCount.tsx
index f79ea47c85b2..ea74da64a9bd 100644
--- a/frontend/src/queries/nodes/DataTable/DataTableCount.tsx
+++ b/frontend/src/queries/nodes/DataTable/DataTableCount.tsx
@@ -5,7 +5,7 @@ import { pluralize } from 'lib/utils/strings'
import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'
import { isActorsQuery, isEventsQuery, isGroupsQuery, isSessionsQuery } from '~/queries/utils'
-export function DataTableCount(): JSX.Element | null {
+export function DataTableCount({ nouns }: { nouns?: [string, string] }): JSX.Element | null {
const { totalCount, totalCountLoading, filteredCount, filteredCountLoading, hasActiveFilters, query } =
useValues(dataNodeLogic)
@@ -19,7 +19,7 @@ export function DataTableCount(): JSX.Element | null {
return null
}
- const entityType = getEntityType(query)
+ const entityType = nouns ? { singular: nouns[0], plural: nouns[1] } : getEntityType(query)
const displayFilteredCount = filteredCount !== null ? filteredCount : 0
const text = hasActiveFilters
diff --git a/frontend/src/queries/types.ts b/frontend/src/queries/types.ts
index afb8fbc91d72..f9ae361b1d25 100644
--- a/frontend/src/queries/types.ts
+++ b/frontend/src/queries/types.ts
@@ -61,6 +61,10 @@ export interface QueryContext<Q extends QuerySchema = QuerySchema> {
dataTableMaxPaginationLimit?: number
/** Stop Data Table pagination after this many accumulated rows. */
dataTableMaxPaginationRows?: number
+ /** Keep the Data Table toolbar fixed while its table content scrolls. */
+ dataTableAllowContentScroll?: boolean
+ /** Override the nouns used by Data Table counts and pagination. */
+ dataTableNouns?: [string, string]
compactDataTableToolbar?: boolean
hideRecordingButton?: boolean
/** Custom expandable config for DataTable rows */
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx b/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx
index 8d15a7fdc86d..6aa39653129f 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx
@@ -775,7 +775,12 @@ const meta: Meta = {
// Onboarding gate: report the project as instrumented so the scene
// renders the dashboard/tabs instead of the empty state.
if (query.includes('has_initialize')) {
- return [200, { results: [[true, true]] }]
+ return [
+ 200,
+ {
+ results: [[true, ACTIVITY_OVERVIEW.stats.total_calls, 72, '2026-05-15T09:00:00Z']],
+ },
+ ]
}
if (query.includes('AS session_id')) {
return [200, { results: SESSION_RESULTS }]
diff --git a/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx b/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx
index a4ceff92382a..6e3193d6fd5e 100644
--- a/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx
+++ b/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx
@@ -6,7 +6,6 @@ import { LemonBanner, LemonSkeleton, LemonTag, Link } from '@posthog/lemon-ui'
import { pngHoggie } from 'lib/brand/hoggies'
import { dataColorVars } from 'lib/colors'
-import { dayjs } from 'lib/dayjs'
import { LemonProgress } from 'lib/lemon-ui/LemonProgress'
import { urls } from 'scenes/urls'
@@ -54,7 +53,7 @@ export function MCPAnalyticsActivityDashboard(): JSX.Element {
}
function SummaryCard(): JSX.Element {
- const { signals, dashboardStage } = useValues(mcpAnalyticsOnboardingLogic)
+ const { dashboardStage } = useValues(mcpAnalyticsOnboardingLogic)
const { summary } = useValues(mcpEarlyDataLogic)
return (
@@ -62,16 +61,7 @@ function SummaryCard(): JSX.Element {
<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">
- <h3 className="text-lg font-semibold m-0">
- {summary}
- {/* Omitted on day one — "since today" is noise. */}
- {signals?.firstCallAt && !dayjs(signals.firstCallAt).isSame(dayjs(), 'day') ? (
- <span className="text-muted font-normal">
- {' '}
- since {dayjs(signals.firstCallAt).format('MMM D')}
- </span>
- ) : null}
- </h3>
+ <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' ? (
@@ -98,7 +88,7 @@ function LiveActivityCard(): JSX.Element {
<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-1 min-h-0 max-h-[36rem] lg:max-h-none overflow-y-auto">
+ <div className="flex flex-1 min-h-0 max-h-[36rem] overflow-hidden lg:max-h-none">
<Query
attachTo={mcpEarlyDataLogic}
uniqueKey="mcp-analytics-activity"
@@ -106,6 +96,8 @@ function LiveActivityCard(): JSX.Element {
setQuery={setActivityQuery}
context={{
dataTableMaxPaginationRows: MCP_ACTIVITY_MAX_ROWS,
+ dataTableAllowContentScroll: true,
+ dataTableNouns: ['tool call', 'tool calls'],
compactDataTableToolbar: true,
hideRecordingButton: true,
columns: {
diff --git a/products/mcp_analytics/frontend/earlyData/activitySummary.ts b/products/mcp_analytics/frontend/earlyData/activitySummary.ts
index 13d7379bf6ed..455c0cf8bf8f 100644
--- a/products/mcp_analytics/frontend/earlyData/activitySummary.ts
+++ b/products/mcp_analytics/frontend/earlyData/activitySummary.ts
@@ -1,6 +1,7 @@
import { humanFriendlyLargeNumber, humanFriendlyNumber } from 'lib/utils/numbers'
export interface ActivitySummaryInput {
+ lifetimeCalls: number | null
totalCalls: number
distinctClients: number
errorCalls: number
@@ -15,28 +16,29 @@ export interface ActivitySummaryInput {
* one-time first-look hero, but persistent and tailored to early data.
*/
export function buildActivitySummary(input: ActivitySummaryInput): string {
- const { totalCalls, distinctClients, errorCalls, topTool } = input
+ const { lifetimeCalls, totalCalls, distinctClients, errorCalls, topTool } = input
+ const resolvedLifetimeCalls = lifetimeCalls === null ? null : Math.max(lifetimeCalls, totalCalls)
if (totalCalls === 0) {
- return 'Waiting for your first tool call…'
+ return resolvedLifetimeCalls === 0 ? 'Waiting for your first tool call…' : 'No tool calls in the last 30 days'
}
- if (totalCalls <= 5) {
- return totalCalls === 1
- ? "Your first tool call arrived — here's what the agent tried."
- : `Your first ${totalCalls} tool calls arrived — here's what agents tried.`
+ if (resolvedLifetimeCalls !== null && resolvedLifetimeCalls <= 5) {
+ return resolvedLifetimeCalls === 1
+ ? "Your first tool call arrived. Here's what the agent tried."
+ : `Your first ${resolvedLifetimeCalls} tool calls arrived. Here's what agents tried.`
}
- const parts = [`${humanFriendlyLargeNumber(totalCalls)} tool calls`]
+ const parts = [`${humanFriendlyLargeNumber(totalCalls)} tool calls in the last 30 days`]
if (distinctClients > 0) {
parts.push(`from ${humanFriendlyNumber(distinctClients)} client${distinctClients === 1 ? '' : 's'}`)
}
- let summary = `${parts.join(' ')} so far`
+ let summary = parts.join(' ')
if (topTool) {
- summary += ` — ${topTool} is the favorite`
+ summary += `. ${topTool} is the favorite`
}
if (errorCalls > 0) {
const failures = `${humanFriendlyNumber(errorCalls)} failure${errorCalls === 1 ? '' : 's'}`
- summary += `${topTool ? ',' : ' —'} ${failures} worth a look`
+ summary += `. ${failures} worth a look`
}
return summary
}
diff --git a/products/mcp_analytics/frontend/earlyData/earlyData.test.ts b/products/mcp_analytics/frontend/earlyData/earlyData.test.ts
index 334987e424fc..8a385cd6870f 100644
--- a/products/mcp_analytics/frontend/earlyData/earlyData.test.ts
+++ b/products/mcp_analytics/frontend/earlyData/earlyData.test.ts
@@ -40,24 +40,55 @@ describe('early data derivations', () => {
it.each([
// First calls get the celebratory copy, not a stats sentence.
- [{ totalCalls: 1, distinctClients: 1, errorCalls: 0, topTool: null }, /first tool call arrived/],
- [{ totalCalls: 4, distinctClients: 1, errorCalls: 1, topTool: 'search' }, /first 4 tool calls arrived/],
+ [
+ { lifetimeCalls: 1, totalCalls: 1, distinctClients: 1, errorCalls: 0, topTool: null },
+ /first tool call arrived/,
+ ],
+ [
+ { lifetimeCalls: 4, totalCalls: 4, distinctClients: 1, errorCalls: 1, topTool: 'search' },
+ /first 4 tool calls arrived/,
+ ],
+ [
+ { lifetimeCalls: 25_000_000, totalCalls: 0, distinctClients: 0, errorCalls: 0, topTool: null },
+ /^No tool calls in the last 30 days$/,
+ ],
+ [
+ { lifetimeCalls: null, totalCalls: 0, distinctClients: 0, errorCalls: 0, topTool: null },
+ /^No tool calls in the last 30 days$/,
+ ],
+ [
+ { lifetimeCalls: null, totalCalls: 4, distinctClients: 1, errorCalls: 0, topTool: null },
+ /^4 tool calls in the last 30 days from 1 client$/,
+ ],
+ [
+ { lifetimeCalls: 3, totalCalls: 4, distinctClients: 1, errorCalls: 0, topTool: null },
+ /^Your first 4 tool calls arrived/,
+ ],
// The full sentence composes favorite + failures with correct punctuation.
[
- { totalCalls: 42, distinctClients: 3, errorCalls: 4, topTool: 'search_docs' },
- /^42 tool calls from 3 clients so far — search_docs is the favorite, 4 failures worth a look$/,
+ { lifetimeCalls: 25_000_000, totalCalls: 42, distinctClients: 3, errorCalls: 4, topTool: 'search_docs' },
+ /^42 tool calls in the last 30 days from 3 clients\. search_docs is the favorite\. 4 failures worth a look$/,
],
// Big client and failure counts get thousands separators, unlike the abbreviated call count.
[
- { totalCalls: 21_700_000, distinctClients: 1051, errorCalls: 533_638, topTool: 'execute-sql' },
- /^21\.7M tool calls from 1,051 clients so far — execute-sql is the favorite, 533,638 failures worth a look$/,
+ {
+ lifetimeCalls: 25_000_000,
+ totalCalls: 21_700_000,
+ distinctClients: 1051,
+ errorCalls: 533_638,
+ topTool: 'execute-sql',
+ },
+ /^21\.7M tool calls in the last 30 days from 1,051 clients\. execute-sql is the favorite\. 533,638 failures worth a look$/,
],
// Failures read grammatically even without a favorite tool.
[
- { totalCalls: 42, distinctClients: 0, errorCalls: 1, topTool: null },
- /^42 tool calls so far — 1 failure worth a look$/,
+ { lifetimeCalls: 42, totalCalls: 42, distinctClients: 0, errorCalls: 1, topTool: null },
+ /^42 tool calls in the last 30 days\. 1 failure worth a look$/,
+ ],
+ [
+ { lifetimeCalls: 42, totalCalls: 42, distinctClients: 1, errorCalls: 0, topTool: null },
+ /^42 tool calls in the last 30 days from 1 client$/,
],
- [{ totalCalls: 42, distinctClients: 1, errorCalls: 0, topTool: null }, /^42 tool calls from 1 client so far$/],
])('summarizes %j', (input, expected) => {
expect(buildActivitySummary(input)).toMatch(expected)
})
diff --git a/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts b/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts
index 9eb835d6f647..40d23e94733b 100644
--- a/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts
+++ b/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts
@@ -92,7 +92,6 @@ export interface mcpEarlyDataLogicValues {
stats: EarlyStats
summary: string
topTools: EarlyToolRow[]
- totalCalls: number
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -144,8 +143,7 @@ export interface mcpEarlyDataLogicMeta {
topTools: (overview: MCPActivityOverviewApi | null) => EarlyToolRow[]
clients: (overview: MCPActivityOverviewApi | null) => EarlyClientRow[]
recentCalls: (overview: MCPActivityOverviewApi | null) => EarlyRecentCall[]
- totalCalls: (signals: MCPOnboardingSignals | null, stats: EarlyStats) => number
- summary: (totalCalls: number, stats: EarlyStats, topTools: EarlyToolRow[]) => string
+ summary: (signals: MCPOnboardingSignals | null, stats: EarlyStats, topTools: EarlyToolRow[]) => string
intentFrequencies: (recentCalls: EarlyRecentCall[]) => IntentFrequency[]
checklist: (stats: EarlyStats) => ChecklistItem[]
}
@@ -162,8 +160,8 @@ export const mcpEarlyDataLogic = kea<mcpEarlyDataLogicType>([
path(['products', 'mcp_analytics', 'frontend', 'earlyData', 'mcpEarlyDataLogic']),
connect(() => ({
values: [mcpAnalyticsOnboardingLogic, ['signals'], teamLogic, ['currentProjectId']],
- // loadSignals is dispatched from refreshAll so the summary's totalCalls
- // (max of both sources) advances together with the overview.
+ // Refresh the lifetime signal with the overview so first-call copy can
+ // advance even after the onboarding signal poll stops.
actions: [mcpAnalyticsOnboardingLogic, ['loadSignals']],
})),
connect(() => ({
@@ -257,24 +255,15 @@ export const mcpEarlyDataLogic = kea<mcpEarlyDataLogicType>([
clientName: row.client_name,
})),
],
- // The onboarding signal poll and the overview query run on different cadences,
- // so during active ingestion they can briefly disagree. One number drives
- // the summary so the view never contradicts itself.
- totalCalls: [
- (s) => [s.signals, s.stats],
- (
- signals: null | import('../mcpAnalyticsOnboardingLogic').MCPOnboardingSignals,
- stats: EarlyStats
- ): number => Math.max(stats.totalCalls, signals?.toolCallsTotal ?? 0),
- ],
summary: [
- (s) => [s.totalCalls, s.stats, s.topTools],
- (totalCalls: number, stats: EarlyStats, topTools: EarlyToolRow[]): string =>
+ (s) => [s.signals, s.stats, s.topTools],
+ (signals: MCPOnboardingSignals | null, stats: EarlyStats, topTools: EarlyToolRow[]): string =>
buildActivitySummary({
- totalCalls,
+ lifetimeCalls: signals?.toolCallsTotal ?? null,
+ totalCalls: stats.totalCalls,
distinctClients: stats.distinctClients,
errorCalls: stats.errorCalls,
- topTool: totalCalls > 10 ? (topTools[0]?.tool ?? null) : null,
+ topTool: stats.totalCalls > 10 ? (topTools[0]?.tool ?? null) : null,
}),
],
// Verbatim agent intents grouped by frequency — the fallback when no AI