From 3fc7aa97d695dbc6e36d9f4a9dd68dbb236c17ed Mon Sep 17 00:00:00 2001 From: Nathan Marrs Date: Mon, 18 Dec 2023 14:49:13 -0700 Subject: [PATCH] Dashboard: Track every panel type usage (count) (#79421) --- .../app/features/dashboard/utils/tracking.test.ts | 15 +++++++++++++-- public/app/features/dashboard/utils/tracking.ts | 12 +++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/public/app/features/dashboard/utils/tracking.test.ts b/public/app/features/dashboard/utils/tracking.test.ts index 7b4dfc976cd..dd9e5ce782f 100644 --- a/public/app/features/dashboard/utils/tracking.test.ts +++ b/public/app/features/dashboard/utils/tracking.test.ts @@ -11,7 +11,12 @@ describe('trackDashboardLoaded', () => { title: 'Test Dashboard', panels: [ { id: 1, type: 'row', repeat: 'dc', gridPos: { x: 0, y: 0, h: 1, w: 24 } }, - { id: 2, repeat: 'app', repeatDirection: 'h', gridPos: { x: 0, y: 1, h: 2, w: 8 } }, + { id: 2, type: 'stat', repeat: 'app', repeatDirection: 'h', gridPos: { x: 0, y: 1, h: 2, w: 8 } }, + { id: 3, type: 'graph', repeatDirection: 'h', gridPos: { x: 0, y: 1, h: 2, w: 8 } }, + { id: 4, type: 'timeseries', repeatDirection: 'h', gridPos: { x: 0, y: 1, h: 2, w: 8 } }, + { id: 5, type: 'grafana-worldmap-panel', repeatDirection: 'h', gridPos: { x: 0, y: 1, h: 2, w: 8 } }, + { id: 6, type: 'geomap', repeatDirection: 'h', gridPos: { x: 0, y: 1, h: 2, w: 8 } }, + { id: 7, type: 'graph', repeatDirection: 'h', gridPos: { x: 0, y: 1, h: 2, w: 8 } }, ], templating: { list: [ @@ -30,10 +35,16 @@ describe('trackDashboardLoaded', () => { uid: 'dashboard-123', title: 'Test Dashboard', schemaVersion: model.schemaVersion, // This value is based on public/app/features/dashboard/state/DashboardMigrator.ts#L81 - panels_count: 2, + panels_count: 7, variable_type_query_count: 2, variable_type_interval_count: 1, version_before_migration: 16, + panel_type_row_count: 1, + panel_type_stat_count: 1, + panel_type_graph_count: 2, + panel_type_timeseries_count: 1, + 'panel_type_grafana-worldmap-panel_count': 1, + panel_type_geomap_count: 1, }); }); }); diff --git a/public/app/features/dashboard/utils/tracking.ts b/public/app/features/dashboard/utils/tracking.ts index 79d0593bd7b..613a8487dd5 100644 --- a/public/app/features/dashboard/utils/tracking.ts +++ b/public/app/features/dashboard/utils/tracking.ts @@ -6,11 +6,19 @@ export function trackDashboardLoaded(dashboard: DashboardModel, versionBeforeMig // Count the different types of variables const variables = dashboard.templating.list .map((v) => v.type) - .reduce((r, k) => { + .reduce((r: Record, k) => { r[variableName(k)] = 1 + r[variableName(k)] || 1; return r; }, {}); + // Count the different types of panels + const panels = dashboard.panels + .map((p) => p.type) + .reduce((r: Record, p) => { + r[panelName(p)] = 1 + r[panelName(p)] || 1; + return r; + }, {}); + DashboardInteractions.dashboardInitialized({ uid: dashboard.uid, title: dashboard.title, @@ -18,8 +26,10 @@ export function trackDashboardLoaded(dashboard: DashboardModel, versionBeforeMig schemaVersion: dashboard.schemaVersion, version_before_migration: versionBeforeMigration, panels_count: dashboard.panels.length, + ...panels, ...variables, }); } const variableName = (type: string) => `variable_type_${type}_count`; +const panelName = (type: string) => `panel_type_${type}_count`;