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): expand live activity feed (#90987)

Lucas Fariafdc31032bd0a
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index f6cc01209ecf..4ec873456042 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -7381,9 +7381,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.bca0d74d1b2639c6b1f979e341f71f07760a64f741ae2c8a52911b60dc1199c7.qXE1qgq9_TENwX5GUO2YnUiP4QcGqZlCPpGbL8cS_H4
+ hash: v1.k794b7964.0b4955189ddc9ad0cf917b5e0e3c22ae7b2c4cdfc6873dfbbee30ef73e8f92e5.2jq_QHK0JmQFsnlPwxz2530q8kG3gBm-3TLdefrRIGk
scenes-app-mcp-analytics--activity--light:
- hash: v1.k794b7964.473eea859bb71b592d4192301ff6b6f80d0b31bc60d992537d1f4c72ef5a54fa.TYyn1fQMICc0v0oJjArYuI8WHq9LrVDDeu8ECeEAFac
+ hash: v1.k794b7964.e15fa47e36d13e91df35f120207505907b20dfa6292cf5ded5ac7ab60772cd56.h7NkyFvlZKnQFvFk5fmltWi25sVeipMcoZt7THbqxGg
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/dataNodeLogic.test.ts b/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.ts
index 29b48d90b754..70ba81d3bb4b 100644
--- a/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.ts
+++ b/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.ts
@@ -209,7 +209,7 @@ describe('dataNodeLogic', () => {
})
})
- it('can load next data for EventsQuery', async () => {
+ it('clamps EventsQuery pagination to the maximum accumulated rows', async () => {
const results = [
[
{ ...commonResult, timestamp: '2022-12-24T17:00:41.165000Z' },
@@ -225,6 +225,7 @@ describe('dataNodeLogic', () => {
logic = dataNodeLogic({
key: testUniqueKey,
+ maxPaginationRows: 3,
query: setLatestVersionsOnQuery({
kind: NodeKind.EventsQuery,
select: ['*', 'event', 'timestamp'],
@@ -241,7 +242,7 @@ describe('dataNodeLogic', () => {
kind: NodeKind.EventsQuery,
select: ['*', 'event', 'timestamp'],
before: '2022-12-24T17:00:41.165000Z|01853a90-ba94-0000-8776-e8df5617c3ec',
- limit: 100,
+ limit: 2,
}),
response: partial({ results }),
})
@@ -254,6 +255,11 @@ describe('dataNodeLogic', () => {
'update user properties',
'2022-12-23T17:00:41.165000Z',
],
+ [
+ { ...commonResult, uuid: 'newer', timestamp: '2022-12-22T17:00:41.165000Z' },
+ 'update user properties',
+ '2022-12-22T17:00:41.165000Z',
+ ],
]
mockedQuery.mockResolvedValueOnce({
columns: ['*', 'event', 'timestamp'],
@@ -270,7 +276,7 @@ describe('dataNodeLogic', () => {
kind: NodeKind.EventsQuery,
select: ['*', 'event', 'timestamp'],
before: '2022-12-24T17:00:41.165000Z|01853a90-ba94-0000-8776-e8df5617c3ec',
- limit: 100,
+ limit: 2,
}),
response: partial({ results }),
})
@@ -278,15 +284,13 @@ describe('dataNodeLogic', () => {
await expectLogic(logic).toMatchValues({
responseLoading: false,
- canLoadNextData: true,
- nextQuery: setLatestVersionsOnQuery({
- kind: NodeKind.EventsQuery,
- select: ['*', 'event', 'timestamp'],
- before: '2022-12-23T17:00:41.165000Z|new',
- limit: 100,
- }),
+ canLoadNextData: false,
+ nextQuery: null,
response: partial({ results: [...results, ...results2] }),
})
+
+ await expectLogic(logic, () => logic.actions.loadNextData()).toFinishAllListeners()
+ expect(mockedQuery).toHaveBeenCalledTimes(2)
})
it('can load next data for PersonsNode', async () => {
diff --git a/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts b/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
index a627b013f3c5..d243038cc6b3 100644
--- a/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
+++ b/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
@@ -137,6 +137,8 @@ export interface DataNodeLogicProps {
autoLoad?: boolean
/** Override the maximum pagination limit. */
maxPaginationLimit?: number
+ /** Stop pagination after this many accumulated rows. */
+ maxPaginationRows?: number
/** Limit context sent to the /query endpoint */
limitContext?: 'posthog_ai'
}
@@ -744,7 +746,8 @@ export interface dataNodeLogicMeta {
responseError: string | null,
dataLoading: boolean,
isShowingCachedResults: boolean,
- arg: any
+ arg: any,
+ arg2: any
) => DataNode | null
canLoadNextData: (nextQuery: DataNode<Record<string, any>> | null, isShowingCachedResults: boolean) => boolean
hasMoreData: (
@@ -1497,6 +1500,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
s.dataLoading,
s.isShowingCachedResults,
(_, props) => props.maxPaginationLimit,
+ (_, props) => props.maxPaginationRows,
],
(
query: DataNode<Record<string, any>>,
@@ -1518,7 +1522,8 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
responseError: string | null,
dataLoading: boolean,
isShowingCachedResults: boolean,
- maxPaginationLimit
+ maxPaginationLimit: number | undefined,
+ maxPaginationRows: number | undefined
): DataNode | null => {
if (isShowingCachedResults) {
return null
@@ -1540,22 +1545,28 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
!responseError &&
!dataLoading
) {
- if (
- (
- response as
- | EventsQueryResponse
- | ActorsQueryResponse
- | GroupsQueryResponse
- | ErrorTrackingQueryResponse
- | TracesQueryResponse
- | SessionQueryResponse
- | SessionsQueryResponse
- | MarketingAnalyticsTableQueryResponse
- | AccountsQueryResponse
- | AccountsTableQueryResponse
- | WebStatsTableQueryResponse
- )?.hasMore
- ) {
+ const paginatedResponse = response as
+ | EventsQueryResponse
+ | ActorsQueryResponse
+ | GroupsQueryResponse
+ | ErrorTrackingQueryResponse
+ | TracesQueryResponse
+ | SessionQueryResponse
+ | SessionsQueryResponse
+ | MarketingAnalyticsTableQueryResponse
+ | AccountsQueryResponse
+ | AccountsTableQueryResponse
+ | WebStatsTableQueryResponse
+
+ if (paginatedResponse?.hasMore) {
+ const remainingPaginationRows =
+ maxPaginationRows === undefined
+ ? undefined
+ : maxPaginationRows - (paginatedResponse.results?.length ?? 0)
+ if (remainingPaginationRows !== undefined && remainingPaginationRows <= 0) {
+ return null
+ }
+
const sortKey =
isTracesQuery(query) || isSessionQuery(query) || isAccountsTableQuery(query)
? null
@@ -1575,9 +1586,12 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
const newQuery: EventsQuery = {
...query,
before: lastUuid ? `${lastTimestamp}|${lastUuid}` : lastTimestamp,
- limit: Math.max(
- 100,
- Math.min(2 * (typedResults?.length || 100), effectivePaginationLimit)
+ limit: Math.min(
+ remainingPaginationRows ?? Number.POSITIVE_INFINITY,
+ Math.max(
+ 100,
+ Math.min(2 * (typedResults?.length || 100), effectivePaginationLimit)
+ )
),
}
return newQuery
@@ -1602,6 +1616,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
...query,
offset: typedResults?.length || 0,
limit: Math.min(
+ remainingPaginationRows ?? Number.POSITIVE_INFINITY,
effectivePaginationLimit,
Math.max(100, 2 * (typedResults?.length || 100))
),
diff --git a/frontend/src/queries/nodes/DataTable/DataTable.tsx b/frontend/src/queries/nodes/DataTable/DataTable.tsx
index bcb6cc4a3631..41fc10df2af3 100644
--- a/frontend/src/queries/nodes/DataTable/DataTable.tsx
+++ b/frontend/src/queries/nodes/DataTable/DataTable.tsx
@@ -175,6 +175,7 @@ export function DataTable({
dataNodeCollectionId: context?.insightProps?.dataNodeCollectionId || dataKey,
refresh: context?.refresh,
maxPaginationLimit: context?.dataTableMaxPaginationLimit,
+ maxPaginationRows: context?.dataTableMaxPaginationRows,
limitContext: context?.limitContext,
}
const {
@@ -258,6 +259,7 @@ export function DataTable({
showActions && sourceFeatures.has(QueryFeature.eventActionsColumn) && columnsInResponse?.includes('*')
const recordingColumnShown =
showRecordingColumn && sourceFeatures.has(QueryFeature.eventActionsColumn) && columnsInResponse?.includes('*')
+ const hideRecordingButton = recordingColumnShown || context?.hideRecordingButton
const allColumns = useMemo(
() =>
@@ -772,7 +774,7 @@ export function DataTable({
return (
<EventRowActions
event={(result as any[])[columnsInResponse.indexOf('*')]}
- hideRecordingButton={recordingColumnShown}
+ hideRecordingButton={hideRecordingButton}
/>
)
}
@@ -795,7 +797,7 @@ export function DataTable({
)
}
: undefined,
- [eventActionsColumnShown, columnsInResponse, recordingColumnShown, sourceFeatures]
+ [eventActionsColumnShown, columnsInResponse, hideRecordingButton, sourceFeatures]
)
const setQuerySource = useCallback(
@@ -985,6 +987,10 @@ export function DataTable({
secondRowRight.push(editorButton)
}
}
+
+ const compactToolbarLeft = [...(showFirstRow ? firstRowLeft : []), ...(showSecondRow ? secondRowLeft : [])]
+ const compactToolbarRight = [...(showFirstRow ? firstRowRight : []), ...(showSecondRow ? secondRowRight : [])]
+
return (
<BindLogic logic={dataTableLogic} props={dataTableLogicProps}>
<BindLogic logic={dataNodeLogic} props={dataNodeLogicProps}>
@@ -992,22 +998,51 @@ export function DataTable({
{showHogQLEditor && isHogQLQuery(query.source) && !isReadOnly ? (
<HogQLQueryEditor query={query.source} setQuery={setQuerySource} embedded={embedded} />
) : null}
- {showFirstRow && (
- <div className="flex gap-2 items-center flex-wrap">
- {firstRowLeft}
- {firstRowLeft.length > 0 && firstRowRight.length > 0 ? <div className="flex-1" /> : null}
- {firstRowRight}
- </div>
- )}
- {showSavedFilters && uniqueKey && (
- <DataTableSavedFilters uniqueKey={String(uniqueKey)} query={query} setQuery={setQuery} />
- )}
- {showFirstRow && showSecondRow && <LemonDivider className="my-0" />}
- {showSecondRow && secondRowLeft.length > 0 && secondRowRight.length > 0 && (
- <div className="flex gap-2 justify-between flex-wrap DataTable__second-row empty:hidden">
- <div className="flex gap-2 items-center">{secondRowLeft}</div>
- <div className="flex gap-2 items-center">{secondRowRight}</div>
- </div>
+ {context?.compactDataTableToolbar ? (
+ <>
+ {compactToolbarLeft.length > 0 || compactToolbarRight.length > 0 ? (
+ <div className="flex gap-2 items-center flex-wrap">
+ {compactToolbarLeft}
+ {compactToolbarLeft.length > 0 && compactToolbarRight.length > 0 ? (
+ <div className="flex-1" />
+ ) : null}
+ {compactToolbarRight}
+ </div>
+ ) : null}
+ {showSavedFilters && uniqueKey ? (
+ <DataTableSavedFilters
+ uniqueKey={String(uniqueKey)}
+ query={query}
+ setQuery={setQuery}
+ />
+ ) : null}
+ </>
+ ) : (
+ <>
+ {showFirstRow && (
+ <div className="flex gap-2 items-center flex-wrap">
+ {firstRowLeft}
+ {firstRowLeft.length > 0 && firstRowRight.length > 0 ? (
+ <div className="flex-1" />
+ ) : null}
+ {firstRowRight}
+ </div>
+ )}
+ {showSavedFilters && uniqueKey && (
+ <DataTableSavedFilters
+ uniqueKey={String(uniqueKey)}
+ query={query}
+ setQuery={setQuery}
+ />
+ )}
+ {showFirstRow && showSecondRow && <LemonDivider className="my-0" />}
+ {showSecondRow && secondRowLeft.length > 0 && secondRowRight.length > 0 && (
+ <div className="flex gap-2 justify-between flex-wrap DataTable__second-row empty:hidden">
+ <div className="flex gap-2 items-center">{secondRowLeft}</div>
+ <div className="flex gap-2 items-center">{secondRowRight}</div>
+ </div>
+ )}
+ </>
)}
{showOpenEditorButton && inlineEditorButtonOnRow === 0 && !isReadOnly ? (
<div className="absolute right-0 z-10 p-1">{editorButton}</div>
diff --git a/frontend/src/queries/types.ts b/frontend/src/queries/types.ts
index 84764b575cec..e495d81ef184 100644
--- a/frontend/src/queries/types.ts
+++ b/frontend/src/queries/types.ts
@@ -57,6 +57,10 @@ export interface QueryContext<Q extends QuerySchema = QuerySchema> {
dataNodeLogicKey?: string
/** Override the maximum pagination limit for Data Tables. */
dataTableMaxPaginationLimit?: number
+ /** Stop Data Table pagination after this many accumulated rows. */
+ dataTableMaxPaginationRows?: number
+ compactDataTableToolbar?: boolean
+ hideRecordingButton?: boolean
/** Custom expandable config for DataTable rows */
expandable?: ExpandableConfig<DataTableRow>
/** Ignore action/event names in series labels (show only breakdown/compare values) */
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx b/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx
index f3d649709832..8d15a7fdc86d 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx
@@ -575,6 +575,73 @@ const ACTIVITY_OVERVIEW = {
})),
}
+function activityEventsResponse(select: string[]): Record<string, any> {
+ if (select.length === 1 && select[0] === 'count(*)') {
+ return {
+ columns: select,
+ hasMore: false,
+ results: [[ACTIVITY_OVERVIEW.stats.total_calls]],
+ types: ['UInt64'],
+ }
+ }
+
+ const results = ACTIVITY_CALLS.map(([tool, intent, durationMs, clientName, errorMessage], index) => {
+ const timestamp = dayjs('2026-06-07T12:00:00Z')
+ .subtract(index * 37, 'second')
+ .toISOString()
+ const event = {
+ distinct_id: `agent-${index % 4}`,
+ elements_chain: '',
+ event: '$mcp_tool_call',
+ properties: {
+ $mcp_client_name: clientName,
+ $mcp_duration_ms: durationMs,
+ $mcp_error_message: errorMessage,
+ $mcp_intent: intent,
+ $mcp_is_error: errorMessage !== null,
+ $mcp_parameters: { input: `Example input for ${tool}` },
+ $mcp_response: errorMessage ? { error: errorMessage } : { ok: true },
+ $mcp_server_name: 'example-server',
+ $mcp_tool_name: tool,
+ },
+ timestamp,
+ uuid: `0193f2a1-0000-0000-0000-${String(index + 1).padStart(12, '0')}`,
+ }
+
+ return select.map((column) => {
+ if (column === '*') {
+ return event
+ }
+ if (column === 'timestamp') {
+ return timestamp
+ }
+ if (column.endsWith('-- Tool')) {
+ return tool
+ }
+ if (column.endsWith('-- Agent intent')) {
+ return intent
+ }
+ if (column.endsWith('-- Error')) {
+ return errorMessage !== null
+ }
+ if (column.endsWith('-- Duration (ms)')) {
+ return durationMs
+ }
+ if (column.endsWith('-- Client')) {
+ return clientName
+ }
+ return null
+ })
+ })
+
+ return {
+ columns: select,
+ hasMore: true,
+ results,
+ types: select.map(() => 'String'),
+ }
+}
+
const INTENT_DIGEST = {
digest: 'Agents are extensively analyzing and validating feature flags, especially participant and scope-related flags, across multiple projects to ensure correct configuration and deployment. They are investigating user behavior, event schemas, and telemetry to support product analytics, adoption, and revenue reporting, and to diagnose issues such as interface unresponsiveness, conversion tracking failures, and LLM-related errors. Additionally, they are auditing dashboards, saved insights, and survey data to verify data freshness and rebuild product usage metrics.',
intent_count: 100,
@@ -702,6 +769,9 @@ const meta: Meta = {
if (body?.query?.kind === 'MCPToolCategoryCountsQuery') {
return [200, { results: CATEGORY_COUNTS.map((r) => ({ category: r[0], calls: r[1] })) }]
}
+ if (body?.query?.kind === 'EventsQuery') {
+ return [200, activityEventsResponse(body.query.select ?? [])]
+ }
// Onboarding gate: report the project as instrumented so the scene
// renders the dashboard/tabs instead of the empty state.
if (query.includes('has_initialize')) {
@@ -742,9 +812,8 @@ export const DashboardWithMenuBar: Story = {
},
}
-// The default landing tab for low-volume projects. The feed mock carries the endpoint's full
-// 20-row cap so the feed overflows its viewport — the case where it has to scroll rather than
-// stretch the grid past the sidebar.
+// The default landing tab for low-volume projects. The feed mock has enough rows to overflow its
+// viewport and reports more data, covering both scrolling and the load-more affordance.
export const Activity: Story = {
parameters: {
pageUrl: urls.mcpAnalyticsActivity(),
diff --git a/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx b/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx
index 6e5112e5c333..9f1b1080e361 100644
--- a/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx
+++ b/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx
@@ -1,21 +1,24 @@
import { useActions, useValues } from 'kea'
-import { IconCheckCircle, IconClock, IconRefresh, IconWarning } from '@posthog/icons'
-import { LemonButton, LemonSkeleton, LemonTable, LemonTag, Link } from '@posthog/lemon-ui'
+import { IconCheckCircle, IconClock, IconWarning } from '@posthog/icons'
+import { LemonBanner, LemonSkeleton, LemonTag, Link } from '@posthog/lemon-ui'
import { dataColorVars } from 'lib/colors'
import { ExplorerHog } from 'lib/components/hedgehogs'
-import { TZLabel } from 'lib/components/TZLabel'
import { dayjs } from 'lib/dayjs'
import { LemonProgress } from 'lib/lemon-ui/LemonProgress'
import { urls } from 'scenes/urls'
+import { QueryFeature } from '~/queries/nodes/DataTable/queryFeatures'
+import { Query } from '~/queries/Query/Query'
+
import { Card } from '../dashboard/Card'
-import { formatMs, formatNumber } from '../dashboard/formatters'
+import { formatNumber } from '../dashboard/formatters'
import { HarnessLogo } from '../dashboard/harness'
import type { MCPIntentThemeApi } from '../generated/api.schemas'
import { METRICS_UNLOCK_LIFETIME_CALLS, mcpAnalyticsOnboardingLogic } from '../mcpAnalyticsOnboardingLogic'
-import type { ChecklistItem, EarlyRecentCall } from './mcpEarlyDataLogic'
+import { MCP_ACTIVITY_DATA_COLLECTION_ID, MCP_ACTIVITY_INTENT_COLUMN, MCP_ACTIVITY_MAX_ROWS } from './mcpActivityQuery'
+import type { ChecklistItem } from './mcpEarlyDataLogic'
import { mcpEarlyDataLogic } from './mcpEarlyDataLogic'
/**
@@ -49,135 +52,81 @@ export function MCPAnalyticsActivityDashboard(): JSX.Element {
function SummaryCard(): JSX.Element {
const { signals, dashboardStage } = useValues(mcpAnalyticsOnboardingLogic)
- const { summary, isRefreshing } = useValues(mcpEarlyDataLogic)
- const { refreshAll } = useActions(mcpEarlyDataLogic)
+ const { summary } = useValues(mcpEarlyDataLogic)
return (
- // Same accent gradient as the first-look hero, so the product's intro
- // surfaces share a visual identity across stages.
- <Card className="bg-gradient-to-br from-accent/15 via-accent/5 to-surface-primary">
- <div className="flex items-center justify-between gap-4 flex-wrap">
- <div className="flex items-center gap-4 min-w-0">
- <ExplorerHog className="h-20 w-20 shrink-0 hidden sm:block" />
- <div className="min-w-0">
- <h3 className="text-xl 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>
- <p className="text-muted text-base m-0 mt-1">
- This view fills in live as agents use your server.
- {dashboardStage === 'activity' ? (
- <>
- {' '}
- Charts and trends live in the{' '}
- <Link to={urls.mcpAnalyticsDashboard()}>Dashboard tab</Link> — they get meaningful
- as usage grows (~{formatNumber(METRICS_UNLOCK_LIFETIME_CALLS)} calls).
- </>
- ) : null}
- </p>
- </div>
+ <LemonBanner type="info" dismissKey="mcp-analytics-activity-summary" hideIcon>
+ <div className="flex items-center gap-3 py-1">
+ <ExplorerHog 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>
+ <p className="text-muted text-base m-0 mt-1">
+ This view fills in live as agents use your server.
+ {dashboardStage === 'activity' ? (
+ <>
+ {' '}
+ Charts and trends live in the{' '}
+ <Link to={urls.mcpAnalyticsDashboard()}>Dashboard tab</Link>. They become meaningful as
+ usage grows (~{formatNumber(METRICS_UNLOCK_LIFETIME_CALLS)} calls).
+ </>
+ ) : null}
+ </p>
</div>
- <LemonButton
- type="secondary"
- size="small"
- icon={<IconRefresh />}
- loading={isRefreshing}
- onClick={refreshAll}
- data-attr="mcp-analytics-activity-refresh"
- >
- Refresh
- </LemonButton>
</div>
- </Card>
+ </LemonBanner>
)
}
function LiveActivityCard(): JSX.Element {
- const { recentCalls, overviewLoading } = useValues(mcpEarlyDataLogic)
+ const { activityQuery } = useValues(mcpEarlyDataLogic)
+ const { setActivityQuery } = useActions(mcpEarlyDataLogic)
return (
- <Card title="Live activity" className="h-full lg:absolute lg:inset-0" flush>
+ <section className="flex h-full flex-col overflow-hidden lg:absolute lg:inset-0">
+ <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">
- <LemonTable<EarlyRecentCall>
- embedded
- dataSource={recentCalls}
- loading={overviewLoading && recentCalls.length === 0}
- rowKey={(row, index) => `${row.timestamp}-${row.tool}-${index}`}
- emptyState="Waiting for the next tool call…"
- columns={[
- {
- title: 'When',
- key: 'timestamp',
- width: 130,
- render: (_, row) => <TZLabel time={row.timestamp} />,
- },
- {
- title: 'Tool',
- key: 'tool',
- render: (_, row) => (
- <span className="flex items-center gap-1 font-mono text-sm">
- {row.tool}
- {row.isError ? <LemonTag type="danger">error</LemonTag> : null}
- </span>
- ),
+ <Query
+ attachTo={mcpEarlyDataLogic}
+ uniqueKey="mcp-analytics-activity"
+ query={activityQuery}
+ setQuery={setActivityQuery}
+ context={{
+ dataTableMaxPaginationRows: MCP_ACTIVITY_MAX_ROWS,
+ compactDataTableToolbar: true,
+ hideRecordingButton: true,
+ columns: {
+ [MCP_ACTIVITY_INTENT_COLUMN]: { render: MCPActivityIntentCell, width: '20rem' },
},
- {
- title: 'Agent intent',
- key: 'intent',
- render: (_, row) => (
- <div>
- {row.intent ? (
- <span className="text-base">{row.intent}</span>
- ) : (
- <span className="text-muted text-base">—</span>
- )}
- {row.errorMessage ? (
- <div
- className="text-danger text-sm mt-0.5 line-clamp-2"
- title={row.errorMessage}
- >
- {row.errorMessage}
- </div>
- ) : null}
- </div>
- ),
+ emptyStateDetail: 'Adjust the date range or filters, or wait for agents to call a tool.',
+ emptyStateHeading: 'No MCP tool calls in this period',
+ extraDataTableQueryFeatures: [QueryFeature.showCount],
+ insightProps: {
+ dashboardItemId: 'new-mcp-analytics-activity',
+ dataNodeCollectionId: MCP_ACTIVITY_DATA_COLLECTION_ID,
},
- {
- title: 'Duration',
- key: 'duration',
- width: 90,
- align: 'right',
- render: (_, row) => (row.durationMs == null ? '—' : formatMs(row.durationMs)),
- },
- {
- title: 'Client',
- key: 'client',
- width: 150,
- render: (_, row) =>
- row.clientName ? (
- <span className="flex items-center gap-1.5">
- <HarnessLogo category={row.clientName} className="h-3.5 w-3.5" />
- <span className="truncate">{row.clientName}</span>
- </span>
- ) : (
- <span className="text-muted">unknown</span>
- ),
- },
- ]}
+ showOpenEditorButton: false,
+ }}
/>
</div>
- </Card>
+ </section>
)
}
+function MCPActivityIntentCell({ value }: { value: unknown }): JSX.Element {
+ return <span className="block min-w-64 whitespace-normal">{value ? String(value) : '—'}</span>
+}
+
// `total` is every intent analysed, so the bar reads as this theme's share of them. The backend
// assigns each intent to at most one theme, which is what keeps the shares adding up.
//
diff --git a/products/mcp_analytics/frontend/earlyData/earlyData.test.ts b/products/mcp_analytics/frontend/earlyData/earlyData.test.ts
index 669df24025ee..d15afa7981fd 100644
--- a/products/mcp_analytics/frontend/earlyData/earlyData.test.ts
+++ b/products/mcp_analytics/frontend/earlyData/earlyData.test.ts
@@ -1,5 +1,11 @@
import { buildActivitySummary } from './activitySummary'
import { buildChecklist, EarlyStats } from './earlyDataChecklist'
+import {
+ DEFAULT_MCP_ACTIVITY_QUERY,
+ MCP_ACTIVITY_COLUMNS,
+ MCP_ACTIVITY_MAX_ROWS,
+ MCP_ACTIVITY_PAGE_SIZE,
+} from './mcpActivityQuery'
const stats = (overrides: Partial<EarlyStats>): EarlyStats => ({
totalCalls: 0,
@@ -13,6 +19,25 @@ const stats = (overrides: Partial<EarlyStats>): EarlyStats => ({
})
describe('early data derivations', () => {
+ it('starts the expandable MCP activity feed at 100 rows with room to load more', () => {
+ expect(DEFAULT_MCP_ACTIVITY_QUERY).toMatchObject({
+ embedded: false,
+ expandable: true,
+ showCount: true,
+ showDateRange: true,
+ showPropertyFilter: expect.any(Array),
+ source: {
+ events: ['$mcp_tool_call'],
+ limit: 100,
+ orderBy: ['timestamp DESC'],
+ },
+ })
+ expect(MCP_ACTIVITY_PAGE_SIZE).toBe(100)
+ expect(MCP_ACTIVITY_MAX_ROWS).toBeGreaterThan(MCP_ACTIVITY_PAGE_SIZE)
+ expect(MCP_ACTIVITY_COLUMNS).toContain('*')
+ expect(MCP_ACTIVITY_COLUMNS.find((column) => column.endsWith('-- Tool'))).toContain('$mcp_exec_tool_call_name')
+ })
+
it.each([
// First calls get the celebratory copy, not a stats sentence.
[{ totalCalls: 1, distinctClients: 1, errorCalls: 0, topTool: null }, /first tool call arrived/],
diff --git a/products/mcp_analytics/frontend/earlyData/mcpActivityQuery.ts b/products/mcp_analytics/frontend/earlyData/mcpActivityQuery.ts
new file mode 100644
index 000000000000..4752e0a270d7
--- /dev/null
+++ b/products/mcp_analytics/frontend/earlyData/mcpActivityQuery.ts
@@ -0,0 +1,38 @@
+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+import { MCP_TOOL_CALL_EVENT } from 'lib/components/TaxonomicFilter/utils/mcpProperties'
+
+import { DataTableNode, NodeKind } from '~/queries/schema/schema-general'
+
+export const MCP_ACTIVITY_DATA_COLLECTION_ID = 'mcp-analytics-activity'
+export const MCP_ACTIVITY_PAGE_SIZE = 100
+export const MCP_ACTIVITY_MAX_ROWS = 1000
+export const MCP_ACTIVITY_INTENT_COLUMN = 'properties.$mcp_intent -- Agent intent'
+
+export const MCP_ACTIVITY_COLUMNS = [
+ '*',
+ "coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) -- Tool",
+ MCP_ACTIVITY_INTENT_COLUMN,
+ 'properties.$mcp_is_error -- Error',
+ 'properties.$mcp_duration_ms -- Duration (ms)',
+ 'properties.$mcp_client_name -- Client',
+ 'timestamp',
+]
+
+export const DEFAULT_MCP_ACTIVITY_QUERY: DataTableNode = {
+ kind: NodeKind.DataTableNode,
+ source: {
+ kind: NodeKind.EventsQuery,
+ select: MCP_ACTIVITY_COLUMNS,
+ events: [MCP_TOOL_CALL_EVENT],
+ after: '-30d',
+ orderBy: ['timestamp DESC'],
+ limit: MCP_ACTIVITY_PAGE_SIZE,
+ },
+ embedded: false,
+ expandable: true,
+ showActions: true,
+ showCount: true,
+ showDateRange: true,
+ showPropertyFilter: [TaxonomicFilterGroupType.MCPProperties, TaxonomicFilterGroupType.EventProperties],
+ showReload: true,
+}
diff --git a/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts b/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts
index 241c1727bbf1..9eb835d6f647 100644
--- a/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts
+++ b/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts
@@ -1,14 +1,29 @@
-import { MakeLogicType, actions, afterMount, connect, isBreakpoint, kea, listeners, path, selectors } from 'kea'
+import {
+ MakeLogicType,
+ actions,
+ afterMount,
+ connect,
+ isBreakpoint,
+ kea,
+ listeners,
+ path,
+ reducers,
+ selectors,
+} from 'kea'
import { loaders } from 'kea-loaders'
import { teamLogic } from 'scenes/teamLogic'
+import { dataNodeCollectionLogic } from '~/queries/nodes/DataNode/dataNodeCollectionLogic'
+import { DataTableNode } from '~/queries/schema/schema-general'
+
import { mcpAnalyticsSessionsActivityOverview, mcpAnalyticsSessionsIntentDigest } from '../generated/api'
import type { MCPActivityOverviewApi, MCPIntentThemeApi } from '../generated/api.schemas'
import { mcpAnalyticsOnboardingLogic } from '../mcpAnalyticsOnboardingLogic'
import type { MCPOnboardingSignals } from '../mcpAnalyticsOnboardingLogic'
import { buildActivitySummary } from './activitySummary'
import { ChecklistItem, EarlyStats, buildChecklist } from './earlyDataChecklist'
+import { DEFAULT_MCP_ACTIVITY_QUERY, MCP_ACTIVITY_DATA_COLLECTION_ID } from './mcpActivityQuery'
export type { ChecklistItem, EarlyStats } from './earlyDataChecklist'
@@ -65,12 +80,12 @@ const REFRESH_INTERVAL_MS = 60000
export interface mcpEarlyDataLogicValues {
signals: MCPOnboardingSignals | null // mcpAnalyticsOnboardingLogic
currentProjectId: number | string // teamLogic
+ activityQuery: DataTableNode
checklist: ChecklistItem[]
clients: EarlyClientRow[]
intentDigest: IntentDigest | null
intentDigestLoading: boolean
intentFrequencies: IntentFrequency[]
- isRefreshing: boolean
overview: MCPActivityOverviewApi | null
overviewLoading: boolean
recentCalls: EarlyRecentCall[]
@@ -82,6 +97,7 @@ export interface mcpEarlyDataLogicValues {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface mcpEarlyDataLogicActions {
+ reloadActivityQuery: () => {} // dataNodeCollectionLogic
loadSignals: (_?: void | undefined) => void // mcpAnalyticsOnboardingLogic
loadIntentDigest: (_: void) => void
loadIntentDigestFailure: (
@@ -116,6 +132,9 @@ export interface mcpEarlyDataLogicActions {
refreshAll: () => {
value: true
}
+ setActivityQuery: (query: DataTableNode) => {
+ query: DataTableNode
+ }
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -129,7 +148,6 @@ export interface mcpEarlyDataLogicMeta {
summary: (totalCalls: number, stats: EarlyStats, topTools: EarlyToolRow[]) => string
intentFrequencies: (recentCalls: EarlyRecentCall[]) => IntentFrequency[]
checklist: (stats: EarlyStats) => ChecklistItem[]
- isRefreshing: (overviewLoading: boolean, intentDigestLoading: boolean) => boolean
}
}
@@ -148,8 +166,18 @@ export const mcpEarlyDataLogic = kea<mcpEarlyDataLogicType>([
// (max of both sources) advances together with the overview.
actions: [mcpAnalyticsOnboardingLogic, ['loadSignals']],
})),
+ connect(() => ({
+ actions: [
+ dataNodeCollectionLogic({ key: MCP_ACTIVITY_DATA_COLLECTION_ID }),
+ ['reloadAll as reloadActivityQuery'],
+ ],
+ })),
actions({
refreshAll: true,
+ setActivityQuery: (query: DataTableNode) => ({ query }),
+ }),
+ reducers({
+ activityQuery: [DEFAULT_MCP_ACTIVITY_QUERY, { setActivityQuery: (_, { query }) => query }],
}),
loaders(({ values }) => ({
intentDigest: {
@@ -268,15 +296,12 @@ export const mcpEarlyDataLogic = kea<mcpEarlyDataLogicType>([
},
],
checklist: [(s) => [s.stats], (stats: EarlyStats): ChecklistItem[] => buildChecklist(stats)],
- isRefreshing: [
- (s) => [s.overviewLoading, s.intentDigestLoading],
- (overviewLoading: boolean, intentDigestLoading: boolean): boolean => overviewLoading || intentDigestLoading,
- ],
}),
listeners(({ actions }) => ({
refreshAll: () => {
actions.loadSignals()
actions.loadOverview()
+ actions.reloadActivityQuery()
// Server-side the digest is content-addressed, so this only reaches the
// LLM when new intents have actually arrived.
actions.loadIntentDigest()