mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DashboardScene: Enable scene tracking information (#79963)
* DashboardScene: Enable scene tracking information alt
* tests update
* Review
* Revert "tests update"
This reverts commit 43f894236a
.
* nit
This commit is contained in:
parent
20096259d3
commit
e93c150406
@ -29,6 +29,7 @@ import {
|
|||||||
UserActionEvent,
|
UserActionEvent,
|
||||||
} from '@grafana/scenes';
|
} from '@grafana/scenes';
|
||||||
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
||||||
|
import { trackDashboardLoaded } from 'app/features/dashboard/utils/tracking';
|
||||||
import { DashboardDTO } from 'app/types';
|
import { DashboardDTO } from 'app/types';
|
||||||
|
|
||||||
import { AlertStatesDataLayer } from '../scene/AlertStatesDataLayer';
|
import { AlertStatesDataLayer } from '../scene/AlertStatesDataLayer';
|
||||||
@ -67,7 +68,10 @@ export function transformSaveModelToScene(rsp: DashboardDTO): DashboardScene {
|
|||||||
autoMigrateOldPanels: false,
|
autoMigrateOldPanels: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
return createDashboardSceneFromDashboardModel(oldModel);
|
const scene = createDashboardSceneFromDashboardModel(oldModel);
|
||||||
|
scene.state.$behaviors?.push(registerDashboardSceneTracking(oldModel, rsp.dashboard.version));
|
||||||
|
|
||||||
|
return scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createSceneObjectsForPanels(oldPanels: PanelModel[]): SceneGridItemLike[] {
|
export function createSceneObjectsForPanels(oldPanels: PanelModel[]): SceneGridItemLike[] {
|
||||||
@ -480,6 +484,18 @@ const getLimitedDescriptionReporter = () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function registerDashboardSceneTracking(model: DashboardModel, version?: number) {
|
||||||
|
return () => {
|
||||||
|
const unsetDashboardInteractionsScenesContext = DashboardInteractions.setScenesContext();
|
||||||
|
|
||||||
|
trackDashboardLoaded(model, version);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsetDashboardInteractionsScenesContext();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function registerPanelInteractionsReporter(scene: DashboardScene) {
|
function registerPanelInteractionsReporter(scene: DashboardScene) {
|
||||||
const descriptionReporter = getLimitedDescriptionReporter();
|
const descriptionReporter = getLimitedDescriptionReporter();
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { reportInteraction } from '@grafana/runtime';
|
import { reportInteraction } from '@grafana/runtime';
|
||||||
import { InspectTab } from 'app/features/inspector/types';
|
import { InspectTab } from 'app/features/inspector/types';
|
||||||
|
|
||||||
|
let isScenesContextSet = false;
|
||||||
|
|
||||||
export const DashboardInteractions = {
|
export const DashboardInteractions = {
|
||||||
// Dashboard interactions:
|
// Dashboard interactions:
|
||||||
dashboardInitialized: (properties?: Record<string, unknown>) => {
|
dashboardInitialized: (properties?: Record<string, unknown>) => {
|
||||||
@ -137,11 +139,21 @@ export const DashboardInteractions = {
|
|||||||
toolbarAddClick: () => {
|
toolbarAddClick: () => {
|
||||||
reportDashboardInteraction('toolbar_actions_clicked', { item: 'add' });
|
reportDashboardInteraction('toolbar_actions_clicked', { item: 'add' });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setScenesContext: () => {
|
||||||
|
isScenesContextSet = true;
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
isScenesContextSet = false;
|
||||||
|
};
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const reportDashboardInteraction: typeof reportInteraction = (name, properties) => {
|
const reportDashboardInteraction: typeof reportInteraction = (name, properties) => {
|
||||||
|
const meta = isScenesContextSet ? { scenesView: true } : {};
|
||||||
|
|
||||||
if (properties) {
|
if (properties) {
|
||||||
reportInteraction(`dashboards_${name}`, properties);
|
reportInteraction(`dashboards_${name}`, { ...properties, ...meta });
|
||||||
} else {
|
} else {
|
||||||
reportInteraction(`dashboards_${name}`);
|
reportInteraction(`dashboards_${name}`);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user