mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 12:14:08 -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,
|
||||
} from '@grafana/scenes';
|
||||
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
||||
import { trackDashboardLoaded } from 'app/features/dashboard/utils/tracking';
|
||||
import { DashboardDTO } from 'app/types';
|
||||
|
||||
import { AlertStatesDataLayer } from '../scene/AlertStatesDataLayer';
|
||||
@ -67,7 +68,10 @@ export function transformSaveModelToScene(rsp: DashboardDTO): DashboardScene {
|
||||
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[] {
|
||||
@ -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) {
|
||||
const descriptionReporter = getLimitedDescriptionReporter();
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { reportInteraction } from '@grafana/runtime';
|
||||
import { InspectTab } from 'app/features/inspector/types';
|
||||
|
||||
let isScenesContextSet = false;
|
||||
|
||||
export const DashboardInteractions = {
|
||||
// Dashboard interactions:
|
||||
dashboardInitialized: (properties?: Record<string, unknown>) => {
|
||||
@ -137,11 +139,21 @@ export const DashboardInteractions = {
|
||||
toolbarAddClick: () => {
|
||||
reportDashboardInteraction('toolbar_actions_clicked', { item: 'add' });
|
||||
},
|
||||
|
||||
setScenesContext: () => {
|
||||
isScenesContextSet = true;
|
||||
|
||||
return () => {
|
||||
isScenesContextSet = false;
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
const reportDashboardInteraction: typeof reportInteraction = (name, properties) => {
|
||||
const meta = isScenesContextSet ? { scenesView: true } : {};
|
||||
|
||||
if (properties) {
|
||||
reportInteraction(`dashboards_${name}`, properties);
|
||||
reportInteraction(`dashboards_${name}`, { ...properties, ...meta });
|
||||
} else {
|
||||
reportInteraction(`dashboards_${name}`);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user