diff options
Diffstat (limited to 'src/lib/statsig')
-rw-r--r-- | src/lib/statsig/events.ts | 2 | ||||
-rw-r--r-- | src/lib/statsig/statsig.tsx | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/statsig/events.ts b/src/lib/statsig/events.ts index fe4c9e65a..68de52e14 100644 --- a/src/lib/statsig/events.ts +++ b/src/lib/statsig/events.ts @@ -24,7 +24,7 @@ export type LogEvents = { secondsActive: number } 'state:foreground': {} - 'router:navigate': {} + 'router:navigate:sampled': {} // Screen events 'splash:signInPressed': {} diff --git a/src/lib/statsig/statsig.tsx b/src/lib/statsig/statsig.tsx index 005027820..b7299be8c 100644 --- a/src/lib/statsig/statsig.tsx +++ b/src/lib/statsig/statsig.tsx @@ -85,11 +85,17 @@ export function toClout(n: number | null | undefined): number | undefined { } } +const DOWNSAMPLED_EVENTS = new Set(['router:navigate:sampled']) +const isDownsampledSession = Math.random() < 0.9 // 90% likely + export function logEvent<E extends keyof LogEvents>( eventName: E & string, rawMetadata: LogEvents[E] & FlatJSONRecord, ) { try { + if (isDownsampledSession && DOWNSAMPLED_EVENTS.has(eventName)) { + return + } const fullMetadata = { ...rawMetadata, } as Record<string, string> // Statsig typings are unnecessarily strict here. |