PanelHeader: Add analytics (#64533)

This commit is contained in:
Ivan Ortega Alba 2023-03-10 12:56:41 +01:00 committed by GitHub
parent 14251db9ba
commit f1a17d54cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,6 +43,7 @@ export function getPanelMenu(
locationService.partial({ locationService.partial({
viewPanel: panel.id, viewPanel: panel.id,
}); });
reportInteraction('dashboards_panelheader_view_clicked');
}; };
const onEditPanel = (event: React.MouseEvent<any>) => { const onEditPanel = (event: React.MouseEvent<any>) => {
@ -50,21 +51,25 @@ export function getPanelMenu(
locationService.partial({ locationService.partial({
editPanel: panel.id, editPanel: panel.id,
}); });
reportInteraction('dashboards_panelheader_edit_clicked');
}; };
const onSharePanel = (event: React.MouseEvent<any>) => { const onSharePanel = (event: React.MouseEvent<any>) => {
event.preventDefault(); event.preventDefault();
sharePanel(dashboard, panel); sharePanel(dashboard, panel);
reportInteraction('dashboards_panelheader_share_clicked');
}; };
const onAddLibraryPanel = (event: React.MouseEvent<any>) => { const onAddLibraryPanel = (event: React.MouseEvent<any>) => {
event.preventDefault(); event.preventDefault();
addLibraryPanel(dashboard, panel); addLibraryPanel(dashboard, panel);
reportInteraction('dashboards_panelheader_createlibrarypanel_clicked');
}; };
const onUnlinkLibraryPanel = (event: React.MouseEvent<any>) => { const onUnlinkLibraryPanel = (event: React.MouseEvent<any>) => {
event.preventDefault(); event.preventDefault();
unlinkLibraryPanel(panel); unlinkLibraryPanel(panel);
reportInteraction('dashboards_panelheader_unlinklibrarypanel_clicked');
}; };
const onInspectPanel = (tab?: InspectTab) => { const onInspectPanel = (tab?: InspectTab) => {
@ -72,10 +77,7 @@ export function getPanelMenu(
inspect: panel.id, inspect: panel.id,
inspectTab: tab, inspectTab: tab,
}); });
reportInteraction('dashboards_panelheader_inspect_clicked', { tab: tab ?? InspectTab.Data });
reportInteraction('grafana_panel_menu_inspect', {
tab: tab ?? InspectTab.Data,
});
}; };
const onMore = (event: React.MouseEvent<any>) => { const onMore = (event: React.MouseEvent<any>) => {
@ -85,16 +87,19 @@ export function getPanelMenu(
const onDuplicatePanel = (event: React.MouseEvent<any>) => { const onDuplicatePanel = (event: React.MouseEvent<any>) => {
event.preventDefault(); event.preventDefault();
duplicatePanel(dashboard, panel); duplicatePanel(dashboard, panel);
reportInteraction('dashboards_panelheader_duplicate_clicked');
}; };
const onCopyPanel = (event: React.MouseEvent<any>) => { const onCopyPanel = (event: React.MouseEvent<any>) => {
event.preventDefault(); event.preventDefault();
copyPanel(panel); copyPanel(panel);
reportInteraction('dashboards_panelheader_copy_clicked');
}; };
const onRemovePanel = (event: React.MouseEvent<any>) => { const onRemovePanel = (event: React.MouseEvent<any>) => {
event.preventDefault(); event.preventDefault();
removePanel(dashboard, panel, true); removePanel(dashboard, panel, true);
reportInteraction('dashboards_panelheader_remove_clicked');
}; };
const onNavigateToExplore = (event: React.MouseEvent<any>) => { const onNavigateToExplore = (event: React.MouseEvent<any>) => {
@ -102,16 +107,19 @@ export function getPanelMenu(
const openInNewWindow = const openInNewWindow =
event.ctrlKey || event.metaKey ? (url: string) => window.open(`${config.appSubUrl}${url}`) : undefined; event.ctrlKey || event.metaKey ? (url: string) => window.open(`${config.appSubUrl}${url}`) : undefined;
store.dispatch(navigateToExplore(panel, { getDataSourceSrv, getTimeSrv, getExploreUrl, openInNewWindow }) as any); store.dispatch(navigateToExplore(panel, { getDataSourceSrv, getTimeSrv, getExploreUrl, openInNewWindow }) as any);
reportInteraction('dashboards_panelheader_explore_clicked');
}; };
const onToggleLegend = (event: React.MouseEvent) => { const onToggleLegend = (event: React.MouseEvent) => {
event.preventDefault(); event.preventDefault();
toggleLegend(panel); toggleLegend(panel);
reportInteraction('dashboards_panelheader_togglelegend_clicked');
}; };
const onCancelStreaming = (event: React.MouseEvent) => { const onCancelStreaming = (event: React.MouseEvent) => {
event.preventDefault(); event.preventDefault();
panel.getQueryRunner().cancelQuery(); panel.getQueryRunner().cancelQuery();
reportInteraction('dashboards_panelheader_cancelstreaming_clicked');
}; };
const menu: PanelMenuItem[] = []; const menu: PanelMenuItem[] = [];