[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:
grafana-delivery-bot[bot]
2024-04-16 16:10:41 +01:00
committed by GitHub
co-authored by Ivan Ortega Alba
parent c4e057eddf
commit 2ee985abc2
3 changed files with 0 additions and 28 deletions
@@ -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) {
return () => {
const unsetDashboardInteractionsScenesContext = DashboardInteractions.setScenesContext();
@@ -570,15 +558,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;
};