From dce941c5dc165695baf799248f09be8a04af9cbc Mon Sep 17 00:00:00 2001 From: katspaugh Date: Tue, 26 Sep 2023 11:43:26 +0200 Subject: [PATCH] Fix: prevent Safe Apps tracking on non-Safe App pages --- src/services/analytics/gtm.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/services/analytics/gtm.ts b/src/services/analytics/gtm.ts index cbd4029111..fe77d3b26c 100644 --- a/src/services/analytics/gtm.ts +++ b/src/services/analytics/gtm.ts @@ -21,6 +21,7 @@ import { EventType, DeviceType } from './types' import { SAFE_APPS_SDK_CATEGORY } from './events' import { getAbTest } from '../tracking/abTesting' import type { AbTest } from '../tracking/abTesting' +import { AppRoutes } from '@/config/routes' type GTMEnvironment = 'LIVE' | 'LATEST' | 'DEVELOPMENT' type GTMEnvironmentArgs = Required> @@ -155,6 +156,10 @@ export const normalizeAppName = (appName?: string): string => { } export const gtmTrackSafeApp = (eventData: AnalyticsEvent, appName?: string, sdkEventData?: SafeAppSDKEvent): void => { + if (!location.pathname.startsWith(AppRoutes.apps.index)) { + return + } + const safeAppGtmEvent: SafeAppGtmEvent = { ...commonEventParams, event: EventType.SAFE_APP,