diff options
author | Hailey <me@haileyok.com> | 2024-09-07 04:13:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-07 13:13:51 +0200 |
commit | c8be9b78c6abb1ca98a2e4c9342e314b19d2cb7c (patch) | |
tree | 91b36de19a2e3def4fcb64aeec9cd2b8470ced78 /src/lib/statsig/statsig.tsx | |
parent | adef9cff10eb8cbd5227c1fde0f94068fb6987f6 (diff) | |
download | voidsky-c8be9b78c6abb1ca98a2e4c9342e314b19d2cb7c.tar.zst |
[Statsig] Add more events to downsample, increase downsample rate (#5198)
* add some events for sampling * include downsample rate in metadata * fix metadata logic * uncomment debug
Diffstat (limited to 'src/lib/statsig/statsig.tsx')
-rw-r--r-- | src/lib/statsig/statsig.tsx | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/lib/statsig/statsig.tsx b/src/lib/statsig/statsig.tsx index 7d86f4078..c50bfeb86 100644 --- a/src/lib/statsig/statsig.tsx +++ b/src/lib/statsig/statsig.tsx @@ -89,8 +89,9 @@ export function toClout(n: number | null | undefined): number | undefined { } } +const DOWNSAMPLE_RATE = 0.95 // 95% likely const DOWNSAMPLED_EVENTS: Set<keyof LogEvents> = new Set([ - 'router:navigate:sampled', + 'router:navigate:notifications:sampled', 'state:background:sampled', 'state:foreground:sampled', 'home:feedDisplayed:sampled', @@ -99,8 +100,14 @@ const DOWNSAMPLED_EVENTS: Set<keyof LogEvents> = new Set([ 'discover:clickthrough:sampled', 'discover:engaged:sampled', 'discover:seen:sampled', + 'post:like:sampled', + 'post:unlike:sampled', + 'post:repost:sampled', + 'post:unrepost:sampled', + 'profile:follow:sampled', + 'profile:unfollow:sampled', ]) -const isDownsampledSession = Math.random() < 0.9 // 90% likely +const isDownsampledSession = Math.random() < DOWNSAMPLE_RATE export function logEvent<E extends keyof LogEvents>( eventName: E & string, @@ -117,12 +124,16 @@ export function logEvent<E extends keyof LogEvents>( ) } - if (isDownsampledSession && DOWNSAMPLED_EVENTS.has(eventName)) { + const isDownsampledEvent = DOWNSAMPLED_EVENTS.has(eventName) + if (isDownsampledSession && isDownsampledEvent) { return } const fullMetadata = { ...rawMetadata, } as Record<string, string> // Statsig typings are unnecessarily strict here. + if (isDownsampledEvent) { + fullMetadata.downsampleRate = DOWNSAMPLE_RATE.toString() + } fullMetadata.routeName = getCurrentRouteName() ?? '(Uninitialized)' if (Statsig.initializeCalled()) { Statsig.logEvent(eventName, null, fullMetadata) |