Skip to content

Commit

Permalink
Fix: prevent Safe Apps tracking on non-Safe App pages (#2548)
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh authored Sep 30, 2023
1 parent 0fef75e commit 8fcb5df
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/services/analytics/gtm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Pick<TagManagerArgs, 'auth' | 'preview'>>
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8fcb5df

Please sign in to comment.