From 84850f4553503700eb58c39649b7a8df0dfa46ed Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Fri, 14 Apr 2023 15:14:58 +0200 Subject: [PATCH] [v9.5.x] Dashboards: Fix broken internal data links (#66581) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dashboards: Fix broken internal data links (#66567) * In dashboards splitOpenFn is not passed, instead "href" link is used. When we added tracking we changed the behaviour so onClickFn is always passed when generating the model. To bring back the previous behaviour we skip the onClickFn if the split function is not provided. * Fix test and add a task to re-check the logic (cherry picked from commit 4f5b80095edebc95ba99c53e2cb00e32bf464873) Co-authored-by: Piotr Jamróz --- public/app/features/explore/utils/links.test.ts | 6 +----- public/app/features/explore/utils/links.ts | 4 +++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/public/app/features/explore/utils/links.test.ts b/public/app/features/explore/utils/links.test.ts index b161153a2ca..2c5a5843739 100644 --- a/public/app/features/explore/utils/links.test.ts +++ b/public/app/features/explore/utils/links.test.ts @@ -315,11 +315,7 @@ describe('explore links utils', () => { links[0][0].onClick({}); } - expect(reportInteraction).toBeCalledWith('grafana_data_link_clicked', { - app: CoreApp.Explore, - internal: true, - origin: DataLinkConfigOrigin.Correlations, - }); + expect(reportInteraction).not.toBeCalled(); expect(links[1]).toHaveLength(1); expect(links[1][0].href).toBe( diff --git a/public/app/features/explore/utils/links.ts b/public/app/features/explore/utils/links.ts index 21ed0166985..497099540fc 100644 --- a/public/app/features/explore/utils/links.ts +++ b/public/app/features/explore/utils/links.ts @@ -194,7 +194,9 @@ export const getFieldLinksForExplore = (options: { scopedVars: allVars, range, field, - onClickFn: (options) => splitFnWithTracking(options), + // Don't track internal links without split view as they are used only in Dashboards + // TODO: It should be revisited in #66570 + onClickFn: options.splitOpenFn ? (options) => splitFnWithTracking(options) : undefined, replaceVariables: getTemplateSrv().replace.bind(getTemplateSrv()), }); return { ...internalLink, variables: variables };