mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Remove click tracking for external links (#66801)
Remove click tracking for external links
This commit is contained in:
parent
035bf29146
commit
d1a918489e
@ -57,15 +57,7 @@ describe('explore links utils', () => {
|
||||
|
||||
expect(links[0].href).toBe('http://regionalhost');
|
||||
expect(links[0].title).toBe('external');
|
||||
expect(links[0].onClick).toBeDefined();
|
||||
|
||||
links[0].onClick!({});
|
||||
|
||||
expect(reportInteraction).toBeCalledWith('grafana_data_link_clicked', {
|
||||
app: CoreApp.Explore,
|
||||
internal: false,
|
||||
origin: DataLinkConfigOrigin.Datasource,
|
||||
});
|
||||
expect(links[0].onClick).not.toBeDefined();
|
||||
});
|
||||
|
||||
it('returns generates title for external link', () => {
|
||||
|
@ -122,30 +122,6 @@ export const getFieldLinksForExplore = (options: {
|
||||
if (!linkModel.title) {
|
||||
linkModel.title = getTitleFromHref(linkModel.href);
|
||||
}
|
||||
|
||||
// Take over the onClick to report the click, then either call the original onClick or navigate to the URL
|
||||
// Note: it is likely that an external link that opens in the same tab will not be reported, as the browser redirect might cancel reporting the interaction
|
||||
const origOnClick = linkModel.onClick;
|
||||
|
||||
linkModel.onClick = (...args) => {
|
||||
reportInteraction(DATA_LINK_USAGE_KEY, {
|
||||
origin: link.origin || DataLinkConfigOrigin.Datasource,
|
||||
app: CoreApp.Explore,
|
||||
internal: false,
|
||||
});
|
||||
|
||||
if (origOnClick) {
|
||||
origOnClick?.apply(...args);
|
||||
} else {
|
||||
// for external links without an onClick, we want to duplicate default href behavior since onClick stops it
|
||||
if (linkModel.target === '_blank') {
|
||||
window.open(linkModel.href);
|
||||
} else {
|
||||
window.location.href = linkModel.href;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return linkModel;
|
||||
} else {
|
||||
let internalLinkSpecificVars: ScopedVars = {};
|
||||
|
Loading…
Reference in New Issue
Block a user