grafana/public/app/features/dashboard/utils/tracking.ts
Zoltán Bedi 6fbc0b9b9c
Chore: Add tracking for dashboard load (#70057)
* Chore: Add tracking for dashboard load

* Address review comments
2023-06-23 14:14:06 +02:00

26 lines
800 B
TypeScript

import { reportInteraction } from '@grafana/runtime';
import { DashboardModel } from '../state';
export function trackDashboardLoaded(dashboard: DashboardModel, versionBeforeMigration?: number) {
// Count the different types of variables
const variables = dashboard.templating.list
.map((v) => v.type)
.reduce((r, k) => {
r[variableName(k)] = 1 + r[variableName(k)] || 1;
return r;
}, {});
reportInteraction('dashboards_init_dashboard_completed', {
uid: dashboard.uid,
title: dashboard.title,
theme: dashboard.style,
schemaVersion: dashboard.schemaVersion,
version_before_migration: versionBeforeMigration,
panels_count: dashboard.panels.length,
...variables,
});
}
const variableName = (type: string) => `variable_type_${type}_count`;