[v11.0.x] Panel: Description display event is reported multiple times (#86356)
Panel: Description display event is reported multiple times (#85283)
(cherry picked from commit 233f119037)
Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>
This commit is contained in:
co-authored by
Ivan Ortega Alba
parent
c4e057eddf
commit
2ee985abc2
@@ -545,18 +545,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) {
|
function registerDashboardSceneTracking(model: DashboardModel) {
|
||||||
return () => {
|
return () => {
|
||||||
const unsetDashboardInteractionsScenesContext = DashboardInteractions.setScenesContext();
|
const unsetDashboardInteractionsScenesContext = DashboardInteractions.setScenesContext();
|
||||||
@@ -570,15 +558,10 @@ function registerDashboardSceneTracking(model: DashboardModel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function registerPanelInteractionsReporter(scene: DashboardScene) {
|
function registerPanelInteractionsReporter(scene: DashboardScene) {
|
||||||
const descriptionReporter = getLimitedDescriptionReporter();
|
|
||||||
|
|
||||||
// Subscriptions set with subscribeToEvent are automatically unsubscribed when the scene deactivated
|
// Subscriptions set with subscribeToEvent are automatically unsubscribed when the scene deactivated
|
||||||
scene.subscribeToEvent(UserActionEvent, (e) => {
|
scene.subscribeToEvent(UserActionEvent, (e) => {
|
||||||
const { interaction } = e.payload;
|
const { interaction } = e.payload;
|
||||||
switch (interaction) {
|
switch (interaction) {
|
||||||
case 'panel-description-shown':
|
|
||||||
descriptionReporter(e.payload.origin.state.key || '');
|
|
||||||
break;
|
|
||||||
case 'panel-status-message-clicked':
|
case 'panel-status-message-clicked':
|
||||||
DashboardInteractions.panelStatusMessageClicked();
|
DashboardInteractions.panelStatusMessageClicked();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -41,9 +41,6 @@ export const DashboardInteractions = {
|
|||||||
panelCancelQueryClicked: (properties?: Record<string, unknown>) => {
|
panelCancelQueryClicked: (properties?: Record<string, unknown>) => {
|
||||||
reportDashboardInteraction('panelheader_cancelquery_clicked', properties);
|
reportDashboardInteraction('panelheader_cancelquery_clicked', properties);
|
||||||
},
|
},
|
||||||
panelDescriptionShown: (properties?: Record<string, unknown>) => {
|
|
||||||
reportDashboardInteraction('panelheader_description_displayed', properties);
|
|
||||||
},
|
|
||||||
|
|
||||||
// Sharing interactions:
|
// Sharing interactions:
|
||||||
sharingTabChanged: (properties?: Record<string, unknown>) => {
|
sharingTabChanged: (properties?: Record<string, unknown>) => {
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ interface CommonProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getPanelChromeProps(props: CommonProps) {
|
export function getPanelChromeProps(props: CommonProps) {
|
||||||
let descriptionInteractionReported = false;
|
|
||||||
|
|
||||||
function hasOverlayHeader() {
|
function hasOverlayHeader() {
|
||||||
// always show normal header if we have time override
|
// always show normal header if we have time override
|
||||||
if (props.data.request && props.data.request.timeInfo) {
|
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 descriptionMarkdown = getTemplateSrv().replace(props.panel.description, props.panel.scopedVars);
|
||||||
const interpolatedDescription = renderMarkdown(descriptionMarkdown);
|
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;
|
return interpolatedDescription;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user