Frontend Traces: Ignore Faro tracking of Google Analytics and Rudderstack (#95322)

* Ignore Faro tracking of Google Analytics and Rudderstack

* Fix test

* Fancy it up Tom style
This commit is contained in:
Tobias Skarhed 2024-10-28 13:44:52 +01:00 committed by GitHub
parent 5a0ef46280
commit c9984cbb7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 1 deletions

View File

@ -317,6 +317,15 @@ function initEchoSrv() {
}
if (config.grafanaJavascriptAgent.enabled) {
// Ignore Rudderstack URLs
const rudderstackUrls = [
config.rudderstackConfigUrl,
config.rudderstackDataPlaneUrl,
config.rudderstackIntegrationsUrl,
]
.filter(Boolean)
.map((url) => new RegExp(`${url}.*.`));
registerEchoBackend(
new GrafanaJavascriptAgentBackend({
...config.grafanaJavascriptAgent,
@ -329,6 +338,7 @@ function initEchoSrv() {
id: String(config.bootData.user?.id),
email: config.bootData.user?.email,
},
ignoreUrls: rudderstackUrls,
})
);
}

View File

@ -76,6 +76,7 @@ describe('GrafanaJavascriptAgentEchoBackend', () => {
id: '504',
orgId: 1,
},
ignoreUrls: [],
};
it('will set up FetchTransport if customEndpoint is provided', () => {

View File

@ -34,8 +34,11 @@ export interface GrafanaJavascriptAgentBackendOptions extends BrowserConfig {
consoleInstrumentalizationEnabled: boolean;
webVitalsInstrumentalizationEnabled: boolean;
tracingInstrumentalizationEnabled: boolean;
ignoreUrls: RegExp[];
}
const TRACKING_URLS = [/.*.google-analytics.com*.*/, /.*.googletagmanager.com*.*/, /frontend-metrics/];
export class GrafanaJavascriptAgentBackend
implements EchoBackend<GrafanaJavascriptAgentEchoEvent, GrafanaJavascriptAgentBackendOptions>
{
@ -87,7 +90,7 @@ export class GrafanaJavascriptAgentBackend
'ResizeObserver loop completed',
'Non-Error exception captured with keys',
],
ignoreUrls: [new RegExp(`/*${options.customEndpoint}/`), /frontend-metrics/],
ignoreUrls: [new RegExp(`/*${options.customEndpoint}/`), ...TRACKING_URLS, ...options.ignoreUrls],
sessionTracking: {
persistent: true,
},