mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Panel: Description display event is reported multiple times (#85283)
This commit is contained in:
parent
649c456eab
commit
233f119037
@ -540,18 +540,6 @@ export function buildGridItemForPanel(panel: PanelModel): DashboardGridItem {
|
||||
});
|
||||
}
|
||||
|
||||
const getLimitedDescriptionReporter = () => {
|
||||
const reportedPanels: string[] = [];
|
||||
|
||||
return (key: string) => {
|
||||
if (reportedPanels.includes(key)) {
|
||||
return;
|
||||
}
|
||||
reportedPanels.push(key);
|
||||
DashboardInteractions.panelDescriptionShown();
|
||||
};
|
||||
};
|
||||
|
||||
function registerDashboardSceneTracking(model: DashboardModel) {
|
||||
return () => {
|
||||
const unsetDashboardInteractionsScenesContext = DashboardInteractions.setScenesContext();
|
||||
@ -565,15 +553,10 @@ function registerDashboardSceneTracking(model: DashboardModel) {
|
||||
}
|
||||
|
||||
function registerPanelInteractionsReporter(scene: DashboardScene) {
|
||||
const descriptionReporter = getLimitedDescriptionReporter();
|
||||
|
||||
// Subscriptions set with subscribeToEvent are automatically unsubscribed when the scene deactivated
|
||||
scene.subscribeToEvent(UserActionEvent, (e) => {
|
||||
const { interaction } = e.payload;
|
||||
switch (interaction) {
|
||||
case 'panel-description-shown':
|
||||
descriptionReporter(e.payload.origin.state.key || '');
|
||||
break;
|
||||
case 'panel-status-message-clicked':
|
||||
DashboardInteractions.panelStatusMessageClicked();
|
||||
break;
|
||||
|
@ -41,9 +41,6 @@ export const DashboardInteractions = {
|
||||
panelCancelQueryClicked: (properties?: Record<string, unknown>) => {
|
||||
reportDashboardInteraction('panelheader_cancelquery_clicked', properties);
|
||||
},
|
||||
panelDescriptionShown: (properties?: Record<string, unknown>) => {
|
||||
reportDashboardInteraction('panelheader_description_displayed', properties);
|
||||
},
|
||||
|
||||
// Sharing interactions:
|
||||
sharingTabChanged: (properties?: Record<string, unknown>) => {
|
||||
|
@ -26,8 +26,6 @@ interface CommonProps {
|
||||
}
|
||||
|
||||
export function getPanelChromeProps(props: CommonProps) {
|
||||
let descriptionInteractionReported = false;
|
||||
|
||||
function hasOverlayHeader() {
|
||||
// always show normal header if we have time override
|
||||
if (props.data.request && props.data.request.timeInfo) {
|
||||
@ -41,12 +39,6 @@ export function getPanelChromeProps(props: CommonProps) {
|
||||
const descriptionMarkdown = getTemplateSrv().replace(props.panel.description, props.panel.scopedVars);
|
||||
const interpolatedDescription = renderMarkdown(descriptionMarkdown);
|
||||
|
||||
if (!descriptionInteractionReported) {
|
||||
// Description rendering function can be called multiple times due to re-renders but we want to report the interaction once.
|
||||
DashboardInteractions.panelDescriptionShown();
|
||||
descriptionInteractionReported = true;
|
||||
}
|
||||
|
||||
return interpolatedDescription;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user