mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboards: Add duration to dashboard init tracking (#81637)
* Add duration to dashboard init * remove optional chaning, performance should be there * Fix tests
This commit is contained in:
parent
89fb56bc11
commit
88feccf632
@ -174,6 +174,8 @@ const getQueriesByDatasource = (
|
||||
*/
|
||||
export function initDashboard(args: InitDashboardArgs): ThunkResult<void> {
|
||||
return async (dispatch, getState) => {
|
||||
const initStart = performance.now();
|
||||
|
||||
// set fetching state
|
||||
dispatch(dashboardInitFetching());
|
||||
|
||||
@ -283,7 +285,8 @@ export function initDashboard(args: InitDashboardArgs): ThunkResult<void> {
|
||||
})
|
||||
);
|
||||
|
||||
trackDashboardLoaded(dashboard, versionBeforeMigration);
|
||||
const duration = performance.now() - initStart;
|
||||
trackDashboardLoaded(dashboard, duration, versionBeforeMigration);
|
||||
|
||||
// yay we are done
|
||||
dispatch(dashboardInitCompleted(dashboard));
|
||||
|
@ -33,9 +33,10 @@ describe('trackDashboardLoaded', () => {
|
||||
const model = getDashboardModel(dashboardJSON);
|
||||
const reportInteractionSpy = jest.spyOn(runtime, 'reportInteraction');
|
||||
|
||||
trackDashboardLoaded(model, 16);
|
||||
trackDashboardLoaded(model, 200, 16);
|
||||
|
||||
expect(reportInteractionSpy).toHaveBeenCalledWith('dashboards_init_dashboard_completed', {
|
||||
duration: 200,
|
||||
uid: 'dashboard-123',
|
||||
title: 'Test Dashboard',
|
||||
schemaVersion: model.schemaVersion, // This value is based on public/app/features/dashboard/state/DashboardMigrator.ts#L81
|
||||
|
@ -2,7 +2,7 @@ import { DashboardInteractions } from 'app/features/dashboard-scene/utils/intera
|
||||
|
||||
import { DashboardModel } from '../state';
|
||||
|
||||
export function trackDashboardLoaded(dashboard: DashboardModel, versionBeforeMigration?: number) {
|
||||
export function trackDashboardLoaded(dashboard: DashboardModel, duration: number, versionBeforeMigration?: number) {
|
||||
// Count the different types of variables
|
||||
const variables = dashboard.templating.list
|
||||
.map((v) => v.type)
|
||||
@ -30,6 +30,7 @@ export function trackDashboardLoaded(dashboard: DashboardModel, versionBeforeMig
|
||||
...variables,
|
||||
settings_nowdelay: dashboard.timepicker.nowDelay,
|
||||
settings_livenow: !!dashboard.liveNow,
|
||||
duration,
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user