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): let people hide dashboard cards (#110427)

Lucas Faria2235b594016d
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index b031f3212e37..e2d0323d5938 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -11307,9 +11307,9 @@ snapshots:
scenes-app-mcp-analytics--dashboard--wide--light:
hash: v1.k794b7964.71306f5f516e8afadf50181f2181e50c9883b5aae53d247fbb03e3bf803c4c86.16C5ajh9Fsnr259tCPZBpPSTQUDQlI1tlI-9URo6-1s
scenes-app-mcp-analytics--dashboard-narrow--dark:
- hash: v1.k794b7964.17b7e7cf74eb7ec1bd1bea739619996e159434f9dfa81630f7b33c43ef188c39.dhon4cNqo5oUtVuAFeNMG-j1N4B5_NeGZFBQnFKqLLQ
+ hash: v1.k794b7964.adf40bdb6db463f5f7f57dfc8ac1c177d3527787114b2ea15e1947bb2a7ea9bf.sBunrdrDv-SV516FPaHBw8a201Hp5xf3EKwOSAO6kZA
scenes-app-mcp-analytics--dashboard-narrow--light:
- hash: v1.k794b7964.30f5ea819c73eb87a98eed7aae79b6474bdca9b55df215170d33fa99987b86a8.gdcMWct53OtYXNlUuaPOqMDf366gxIogCWCqWjPqvQY
+ hash: v1.k794b7964.406ecc65c92f7566c421bc4fa8c04f111b18f0ca84c60235f35a9b1d117841ef.D1riE01uvjdLdmAAazx5mwWkyslF9cVjKP0-oyFXPKM
scenes-app-mcp-analytics--dashboard-with-menu-bar--dark:
hash: v1.k794b7964.163a86a3433b4ab5d7ce6ed1ddf1bac516dc1e9dab85b1ac4e00b02d378def62.2XWbhANHdbphP5MiRxSvppMkY3mR4wCNFDqiiaBFNok
scenes-app-mcp-analytics--dashboard-with-menu-bar--light:
@@ -11355,9 +11355,9 @@ 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--overview-unknown-models--dark:
- hash: v1.k794b7964.42627bcb672d30fc8743cc51d12ebb3c6afa706c34b823142fe046dfabf7da14.qgWmPYfrlGq2nC0pUkRH7gBufEAaZwylWaiJ7pQvDss
+ hash: v1.k794b7964.dc5f7d6ca7eb82011ed168e5d72ea0f2348b53e7eef24b102884e7875a6f762d.G_6ZF2ZGql8CFTKg4ivVU1yRjztywX2VRlrH60e0xhc
scenes-app-mcp-analytics-dashboard-cards--overview-unknown-models--light:
- hash: v1.k794b7964.14c81038ec52ea73ced39268d1074e90bca406ce789ea38bcccd392e04391e33.hsUugUYunh71q6Wl1qMxXT3nFMKlMp22LblYQ8ENSS4
+ hash: v1.k794b7964.3ee62e06b593ee359eb3ea142303700038c5e0d557449bb68800a0523a0dc955.BCzpZC0o8K4S390I6KEELrQVWsMioM4U4QEjA6hWKpU
scenes-app-mcp-analytics-dashboard-cards--share-by-harness--dark:
hash: v1.k794b7964.fde18be0efabaa2cf352bb9fb0a666d8093559da70e0aae8c810eacc1e729eb4.ZVHWg1s6g2RxLBy2o-N7DQE84oHBJ6a0krFomsu7Vlw
scenes-app-mcp-analytics-dashboard-cards--share-by-harness--light:
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx b/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
index eecd3c0079dc..45af29dffcc5 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
@@ -1,4 +1,7 @@
import { useActions, useValues } from 'kea'
+import { Children, type ReactNode } from 'react'
+
+import { LemonButton } from '@posthog/lemon-ui'
import { useChartTheme } from 'lib/charts/hooks'
import { FEATURE_FLAGS } from 'lib/constants'
@@ -9,8 +12,11 @@ import { teamLogic } from 'scenes/teamLogic'
import { McpDateFilter } from './components/McpDateFilter'
import { McpSharedFilters } from './components/McpSharedFilters'
import { ActivityChart } from './dashboard/ActivityChart'
+import { MCP_DASHBOARD_CARDS } from './dashboard/dashboardCards'
+import { DashboardCardsMenu } from './dashboard/DashboardCardsMenu'
import { HarnessBarChart } from './dashboard/HarnessBarChart'
import { KpiTiles } from './dashboard/KpiTiles'
+import { mcpDashboardCardsLogic } from './dashboard/mcpDashboardCardsLogic'
import { ModelBarChart } from './dashboard/ModelBarChart'
import { NotableSessionsTable } from './dashboard/NotableSessionsTable'
import { ProtocolVersionStrip } from './dashboard/ProtocolVersionStrip'
@@ -54,11 +60,26 @@ export function MCPAnalyticsDashboardOverview(): JSX.Element {
feedbackContextKey,
} = useValues(mcpDashboardOverviewLogic)
const { setDateFilter, reloadAll, markFilterInteraction } = useActions(mcpDashboardOverviewLogic)
+ const { hiddenCards, isCardVisible } = useValues(mcpDashboardCardsLogic)
+ const { showAllCards } = useActions(mcpDashboardCardsLogic)
const { timezone } = useValues(teamLogic)
const { featureFlags } = useValues(featureFlagLogic)
const theme = useChartTheme()
+ const showKpis = isCardVisible('kpis')
+ const showActivity = isCardVisible('activity')
+ const showToolUsage = isCardVisible('tool-usage')
+ const showHarness = isCardVisible('harness')
+ const showModel = isCardVisible('model') && hasModelData
+ const showProtocolVersion = isCardVisible('protocol-version') && hasProtocolVersionData
+ const showToolErrors = isCardVisible('tool-errors')
+ const showNotableSessions = isCardVisible('notable-sessions')
+ const showRecentActivity = isCardVisible('recent-activity')
+ const showUsage = showActivity || showToolUsage || showHarness || showModel || showProtocolVersion
+ const showReliability = showToolErrors || showNotableSessions
+ const showsNoCards = !(showKpis || showUsage || showReliability || showRecentActivity)
+
return (
<div className="@container/mcp-overview flex min-w-0 flex-col gap-6">
<McpSharedFilters
@@ -86,6 +107,12 @@ export function MCPAnalyticsDashboardOverview(): JSX.Element {
}}
dataAttr="mcp-dashboard-date-filter"
/>
+ <DashboardCardsMenu
+ cardsWithoutData={[
+ ...(hasModelData ? [] : ['model' as const]),
+ ...(hasProtocolVersionData ? [] : ['protocol-version' as const]),
+ ]}
+ />
</McpSharedFilters>
<MCPAnalyticsFeedbackPrompt
contextKey={feedbackContextKey}
@@ -93,60 +120,104 @@ export function MCPAnalyticsDashboardOverview(): JSX.Element {
prompt={MCP_ANALYTICS_DASHBOARD_FEEDBACK_PROMPT}
/>
<MCPAnalyticsFirstLook />
- <section className="flex min-w-0 flex-col gap-4" data-quill>
- <h2 className="mb-4 text-xl font-semibold text-primary">Key metrics</h2>
- <KpiTiles
- kpis={kpis}
- users={users}
- intentClusterCount={intentClusterCount}
- kpisLoading={kpisLoading}
- usersLoading={usersLoading}
- showIntentClusters={!!featureFlags[FEATURE_FLAGS.MCP_ANALYTICS_INTENT_ROUTING]}
- theme={theme}
- interval={interval}
- incompleteTail={kpiIncompleteTail}
- />
- </section>
- <section className="flex min-w-0 flex-col gap-4" data-quill>
- <h2 className="mb-4 text-xl font-semibold text-primary">Usage</h2>
- <div className="flex min-w-0 flex-col gap-4">
- <div className="grid min-w-0 grid-cols-1 gap-4 @min-[64rem]/mcp-overview:grid-cols-2">
- <ActivityChart
- daily={dailyActivity}
- loading={activityRowsLoading}
- theme={theme}
- timezone={timezone}
- interval={interval}
- incompleteTail={activityIncompleteTail}
- />
- <ToolUsageChart
- data={toolDailySeries}
- loading={toolDailyRowsLoading}
- theme={theme}
- timezone={timezone}
- interval={interval}
- />
+ {showsNoCards &&
+ (hiddenCards.length === MCP_DASHBOARD_CARDS.length ? (
+ <div className="flex flex-col items-start gap-2" data-attr="mcp-dashboard-all-cards-hidden">
+ <p className="mb-0">All cards are hidden.</p>
+ <LemonButton
+ type="secondary"
+ size="small"
+ onClick={showAllCards}
+ data-attr="mcp-dashboard-empty-show-all-cards"
+ >
+ Show all cards
+ </LemonButton>
</div>
- <div
- className={cn(
- 'grid min-w-0 grid-cols-1 gap-4',
- hasModelData && '@min-[48rem]/mcp-overview:grid-cols-2'
- )}
- >
- <HarnessBarChart rows={harnessRows} loading={harnessRowsLoading} theme={theme} />
- {hasModelData ? <ModelBarChart rows={modelRows} theme={theme} filters={queryFilters} /> : null}
+ ) : (
+ <p className="mb-0" data-attr="mcp-dashboard-visible-cards-no-data">
+ The cards you kept have no data in this date range.
+ </p>
+ ))}
+ {showKpis && (
+ <section className="flex min-w-0 flex-col gap-4" data-quill>
+ <h2 className="mb-4 text-xl font-semibold text-primary">Key metrics</h2>
+ <KpiTiles
+ kpis={kpis}
+ users={users}
+ intentClusterCount={intentClusterCount}
+ kpisLoading={kpisLoading}
+ usersLoading={usersLoading}
+ showIntentClusters={!!featureFlags[FEATURE_FLAGS.MCP_ANALYTICS_INTENT_ROUTING]}
+ theme={theme}
+ interval={interval}
+ incompleteTail={kpiIncompleteTail}
+ />
+ </section>
+ )}
+ {showUsage && (
+ <section className="flex min-w-0 flex-col gap-4" data-quill>
+ <h2 className="mb-4 text-xl font-semibold text-primary">Usage</h2>
+ <div className="flex min-w-0 flex-col gap-4">
+ <CardRow twoColumnsClassName="@min-[64rem]/mcp-overview:grid-cols-2">
+ {showActivity && (
+ <ActivityChart
+ daily={dailyActivity}
+ loading={activityRowsLoading}
+ theme={theme}
+ timezone={timezone}
+ interval={interval}
+ incompleteTail={activityIncompleteTail}
+ />
+ )}
+ {showToolUsage && (
+ <ToolUsageChart
+ data={toolDailySeries}
+ loading={toolDailyRowsLoading}
+ theme={theme}
+ timezone={timezone}
+ interval={interval}
+ />
+ )}
+ </CardRow>
+ <CardRow twoColumnsClassName="@min-[48rem]/mcp-overview:grid-cols-2">
+ {showHarness && (
+ <HarnessBarChart rows={harnessRows} loading={harnessRowsLoading} theme={theme} />
+ )}
+ {showModel && <ModelBarChart rows={modelRows} theme={theme} filters={queryFilters} />}
+ </CardRow>
+ {showProtocolVersion && <ProtocolVersionStrip rows={protocolVersionRows} theme={theme} />}
</div>
- {hasProtocolVersionData ? <ProtocolVersionStrip rows={protocolVersionRows} theme={theme} /> : null}
- </div>
- </section>
- <section className="flex min-w-0 flex-col gap-4" data-quill>
- <h2 className="mb-0 text-xl font-semibold text-primary">Reliability</h2>
- <div className="grid min-w-0 grid-cols-1 gap-4 @min-[64rem]/mcp-overview:grid-cols-2">
- <ToolErrorRateChart rows={toolRows} loading={toolRowsLoading} theme={theme} />
- <NotableSessionsTable sessions={notableSessions} loading={sessionRowsLoading} />
- </div>
- </section>
- <RecentToolCallsCard filters={queryFilters} />
+ </section>
+ )}
+ {showReliability && (
+ <section className="flex min-w-0 flex-col gap-4" data-quill>
+ <h2 className="mb-0 text-xl font-semibold text-primary">Reliability</h2>
+ <CardRow twoColumnsClassName="@min-[64rem]/mcp-overview:grid-cols-2">
+ {showToolErrors && (
+ <ToolErrorRateChart rows={toolRows} loading={toolRowsLoading} theme={theme} />
+ )}
+ {showNotableSessions && (
+ <NotableSessionsTable sessions={notableSessions} loading={sessionRowsLoading} />
+ )}
+ </CardRow>
+ </section>
+ )}
+ {showRecentActivity && <RecentToolCallsCard filters={queryFilters} />}
</div>
)
}
+
+// Pairs cards side by side, falling back to one column when a card in the pair is hidden.
+function CardRow({
+ twoColumnsClassName,
+ children,
+}: {
+ twoColumnsClassName: string
+ children: ReactNode
+}): JSX.Element | null {
+ const cards = Children.toArray(children)
+ if (cards.length === 0) {
+ return null
+ }
+ return <div className={cn('grid min-w-0 grid-cols-1 gap-4', cards.length > 1 && twoColumnsClassName)}>{cards}</div>
+}
diff --git a/products/mcp_analytics/frontend/dashboard/DashboardCardsMenu.tsx b/products/mcp_analytics/frontend/dashboard/DashboardCardsMenu.tsx
new file mode 100644
index 000000000000..ef5f914a178d
--- /dev/null
+++ b/products/mcp_analytics/frontend/dashboard/DashboardCardsMenu.tsx
@@ -0,0 +1,45 @@
+import { useActions, useValues } from 'kea'
+
+import { IconCheck } from '@posthog/icons'
+import { LemonButton, LemonMenu } from '@posthog/lemon-ui'
+
+import { IconBlank } from 'lib/lemon-ui/icons'
+
+import { MCP_DASHBOARD_CARDS, McpDashboardCardId } from './dashboardCards'
+import { mcpDashboardCardsLogic } from './mcpDashboardCardsLogic'
+
+export function DashboardCardsMenu({ cardsWithoutData }: { cardsWithoutData: McpDashboardCardId[] }): JSX.Element {
+ const { hiddenCards, isCardVisible } = useValues(mcpDashboardCardsLogic)
+ const { toggleCard, showAllCards } = useActions(mcpDashboardCardsLogic)
+
+ return (
+ <LemonMenu
+ closeOnClickInside={false}
+ items={[
+ {
+ items: MCP_DASHBOARD_CARDS.map(({ id, label }) => ({
+ label,
+ onClick: () => toggleCard(id),
+ icon: isCardVisible(id) ? <IconCheck /> : <IconBlank />,
+ tooltip: cardsWithoutData.includes(id) ? 'No data in this date range' : undefined,
+ 'data-attr': `mcp-dashboard-card-${id}`,
+ })),
+ },
+ hiddenCards.length > 0 && {
+ items: [
+ { label: 'Show all cards', onClick: showAllCards, 'data-attr': 'mcp-dashboard-show-all-cards' },
+ ],
+ },
+ ]}
+ >
+ <LemonButton
+ type="secondary"
+ size="small"
+ className="whitespace-nowrap"
+ data-attr="mcp-dashboard-customize"
+ >
+ {hiddenCards.length > 0 ? `${hiddenCards.length} hidden` : 'Customize'}
+ </LemonButton>
+ </LemonMenu>
+ )
+}
diff --git a/products/mcp_analytics/frontend/dashboard/dashboardCards.ts b/products/mcp_analytics/frontend/dashboard/dashboardCards.ts
new file mode 100644
index 000000000000..6988176a6ce0
--- /dev/null
+++ b/products/mcp_analytics/frontend/dashboard/dashboardCards.ts
@@ -0,0 +1,28 @@
+export type McpDashboardCardId =
+ | 'kpis'
+ | 'activity'
+ | 'tool-usage'
+ | 'harness'
+ | 'model'
+ | 'protocol-version'
+ | 'tool-errors'
+ | 'notable-sessions'
+ | 'recent-activity'
+
+// A Record so a new card id fails to compile until it has a label. Key order is menu order.
+const CARD_LABELS: Record<McpDashboardCardId, string> = {
+ kpis: 'Key metrics',
+ activity: 'Tool calls and errors',
+ 'tool-usage': 'Tool call breakdown',
+ harness: 'Share of calls by harness',
+ model: 'Share of calls by model',
+ 'protocol-version': 'Calls by MCP protocol version',
+ 'tool-errors': 'Tools with the highest error rate',
+ 'notable-sessions': 'Sessions flagged for review',
+ 'recent-activity': 'Recent activity',
+}
+
+export const MCP_DASHBOARD_CARDS = (Object.keys(CARD_LABELS) as McpDashboardCardId[]).map((id) => ({
+ id,
+ label: CARD_LABELS[id],
+}))
diff --git a/products/mcp_analytics/frontend/dashboard/mcpDashboardCardsLogic.test.ts b/products/mcp_analytics/frontend/dashboard/mcpDashboardCardsLogic.test.ts
new file mode 100644
index 000000000000..528d1f614818
--- /dev/null
+++ b/products/mcp_analytics/frontend/dashboard/mcpDashboardCardsLogic.test.ts
@@ -0,0 +1,89 @@
+import { expectLogic } from 'kea-test-utils'
+import posthog from 'posthog-js'
+
+import { initKeaTests } from '~/test/init'
+
+import { McpDashboardCardId } from './dashboardCards'
+import { mcpDashboardCardsLogic } from './mcpDashboardCardsLogic'
+
+describe('mcpDashboardCardsLogic', () => {
+ let logic: ReturnType<typeof mcpDashboardCardsLogic.build>
+
+ beforeEach(() => {
+ jest.clearAllMocks()
+ localStorage.clear()
+ initKeaTests()
+ })
+
+ function mountLogic(): void {
+ logic = mcpDashboardCardsLogic()
+ logic.mount()
+ }
+
+ it('shows every card by default', () => {
+ mountLogic()
+
+ expectLogic(logic).toMatchValues({ hiddenCards: [] })
+ })
+
+ it.each<{ toggles: McpDashboardCardId[]; hidden: McpDashboardCardId[] }>([
+ { toggles: ['model'], hidden: ['model'] },
+ { toggles: ['model', 'model'], hidden: [] },
+ { toggles: ['recent-activity', 'kpis'], hidden: ['kpis', 'recent-activity'] },
+ ])('toggling $toggles leaves $hidden hidden', ({ toggles, hidden }) => {
+ mountLogic()
+
+ toggles.forEach((id) => logic.actions.toggleCard(id))
+
+ expectLogic(logic).toMatchValues({ hiddenCards: hidden })
+ expect(logic.values.isCardVisible('kpis')).toBe(!hidden.includes('kpis'))
+ expect(logic.values.isCardVisible('model')).toBe(!hidden.includes('model'))
+ })
+
+ it('showAllCards clears every hidden card', () => {
+ mountLogic()
+ logic.actions.toggleCard('harness')
+ logic.actions.toggleCard('tool-errors')
+
+ logic.actions.showAllCards()
+
+ expectLogic(logic).toMatchValues({ hiddenCards: [] })
+ expect(posthog.capture).toHaveBeenLastCalledWith('mcp analytics dashboard cards reset', { hidden_count: 2 })
+ })
+
+ it('reports each toggle with the resulting hidden state', () => {
+ mountLogic()
+ jest.mocked(posthog.capture).mockClear()
+
+ logic.actions.toggleCard('harness')
+ logic.actions.toggleCard('harness')
+
+ expect(posthog.capture).toHaveBeenNthCalledWith(1, 'mcp analytics dashboard card toggled', {
+ card: 'harness',
+ hidden: true,
+ })
+ expect(posthog.capture).toHaveBeenNthCalledWith(2, 'mcp analytics dashboard card toggled', {
+ card: 'harness',
+ hidden: false,
+ })
+ })
+
+ it('restores hidden cards from storage, ignores ids of removed cards, and reports them on view', () => {
+ mountLogic()
+ logic.actions.toggleCard('model')
+ const storageKey = Object.keys(localStorage).find((key) => key.endsWith('.hiddenCardIds'))!
+ expect(JSON.parse(localStorage.getItem(storageKey)!)).toEqual(['model'])
+ localStorage.setItem(storageKey, JSON.stringify(['model', 'retired-card']))
+ initKeaTests()
+
+ mountLogic()
+
+ expectLogic(logic).toMatchValues({ hiddenCards: ['model'] })
+ expect(logic.values.isCardVisible('model')).toBe(false)
+ expect(logic.values.isCardVisible('harness')).toBe(true)
+ expect(posthog.capture).toHaveBeenLastCalledWith('mcp analytics dashboard viewed', {
+ hidden_cards: ['model'],
+ hidden_count: 1,
+ })
+ })
+})
diff --git a/products/mcp_analytics/frontend/dashboard/mcpDashboardCardsLogic.ts b/products/mcp_analytics/frontend/dashboard/mcpDashboardCardsLogic.ts
new file mode 100644
index 000000000000..f8b6f5c0a419
--- /dev/null
+++ b/products/mcp_analytics/frontend/dashboard/mcpDashboardCardsLogic.ts
@@ -0,0 +1,89 @@
+import { MakeLogicType, actions, afterMount, kea, listeners, path, reducers, selectors } from 'kea'
+import posthog from 'posthog-js'
+
+import { MCP_DASHBOARD_CARDS, McpDashboardCardId } from './dashboardCards'
+
+const teamId = window.POSTHOG_APP_CONTEXT?.current_team?.id
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface mcpDashboardCardsLogicValues {
+ hiddenCardIds: McpDashboardCardId[]
+ hiddenCards: McpDashboardCardId[]
+ isCardVisible: (id: McpDashboardCardId) => boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface mcpDashboardCardsLogicActions {
+ showAllCards: () => {
+ value: true
+ }
+ toggleCard: (id: McpDashboardCardId) => {
+ id: McpDashboardCardId
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface mcpDashboardCardsLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ hiddenCards: (hiddenCardIds: McpDashboardCardId[]) => McpDashboardCardId[]
+ isCardVisible: (hiddenCardIds: McpDashboardCardId[]) => (id: McpDashboardCardId) => boolean
+ }
+}
+
+export type mcpDashboardCardsLogicType = MakeLogicType<
+ mcpDashboardCardsLogicValues,
+ mcpDashboardCardsLogicActions,
+ Record<string, any>,
+ mcpDashboardCardsLogicMeta
+>
+
+export const mcpDashboardCardsLogic = kea<mcpDashboardCardsLogicType>([
+ path(['products', 'mcp_analytics', 'frontend', 'dashboard', 'mcpDashboardCardsLogic']),
+ actions({
+ toggleCard: (id: McpDashboardCardId) => ({ id }),
+ showAllCards: true,
+ }),
+ reducers({
+ // Stores hidden ids, so a card shipped later shows by default.
+ hiddenCardIds: [
+ [] as McpDashboardCardId[],
+ { persist: true, prefix: `${teamId}__` },
+ {
+ toggleCard: (hidden, { id }) =>
+ hidden.includes(id) ? hidden.filter((h) => h !== id) : [...hidden, id],
+ showAllCards: () => [],
+ },
+ ],
+ }),
+ selectors({
+ // Persisted ids can outlive the card they named, so read them against the live list.
+ hiddenCards: [
+ (s) => [s.hiddenCardIds],
+ (hiddenCardIds: McpDashboardCardId[]): McpDashboardCardId[] =>
+ MCP_DASHBOARD_CARDS.map(({ id }) => id).filter((id) => hiddenCardIds.includes(id)),
+ ],
+ isCardVisible: [
+ (s) => [s.hiddenCardIds],
+ (hiddenCardIds: McpDashboardCardId[]) =>
+ (id: McpDashboardCardId): boolean =>
+ !hiddenCardIds.includes(id),
+ ],
+ }),
+ listeners(({ values, selectors }) => ({
+ toggleCard: ({ id }) => {
+ posthog.capture('mcp analytics dashboard card toggled', { card: id, hidden: !values.isCardVisible(id) })
+ },
+ showAllCards: (_, __, ___, previousState) => {
+ posthog.capture('mcp analytics dashboard cards reset', {
+ hidden_count: selectors.hiddenCards(previousState).length,
+ })
+ },
+ })),
+ afterMount(({ values }) => {
+ // Toggles only record changes; this records what each visit actually shows.
+ posthog.capture('mcp analytics dashboard viewed', {
+ hidden_cards: values.hiddenCards,
+ hidden_count: values.hiddenCards.length,
+ })
+ }),
+])