Panel: Description display event is reported multiple times (#85283)

This commit is contained in:
Ivan Ortega Alba 2024-03-28 16:39:18 +01:00 committed by GitHub
parent 649c456eab
commit 233f119037
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 0 additions and 28 deletions

View File

@ -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;

View File

@ -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>) => {

View File

@ -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;
};