Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[Statsig] Sample router events (#4143)

authored by

dan and committed by
GitHub
d6625c29 8cec1679

+9 -3
+2 -2
src/Navigation.tsx
··· 611 611 linking={LINKING} 612 612 theme={theme} 613 613 onStateChange={() => { 614 - logEvent('router:navigate', { 614 + logEvent('router:navigate:sampled', { 615 615 from: prevLoggedRouteName.current, 616 616 }) 617 617 prevLoggedRouteName.current = getCurrentRouteName() ··· 620 620 attachRouteToLogEvents(getCurrentRouteName) 621 621 logModuleInitTime() 622 622 onReady() 623 - logEvent('router:navigate', {}) 623 + logEvent('router:navigate:sampled', {}) 624 624 }}> 625 625 {children} 626 626 </NavigationContainer>
+1 -1
src/lib/statsig/events.ts
··· 24 24 secondsActive: number 25 25 } 26 26 'state:foreground': {} 27 - 'router:navigate': {} 27 + 'router:navigate:sampled': {} 28 28 29 29 // Screen events 30 30 'splash:signInPressed': {}
+6
src/lib/statsig/statsig.tsx
··· 85 85 } 86 86 } 87 87 88 + const DOWNSAMPLED_EVENTS = new Set(['router:navigate:sampled']) 89 + const isDownsampledSession = Math.random() < 0.9 // 90% likely 90 + 88 91 export function logEvent<E extends keyof LogEvents>( 89 92 eventName: E & string, 90 93 rawMetadata: LogEvents[E] & FlatJSONRecord, 91 94 ) { 92 95 try { 96 + if (isDownsampledSession && DOWNSAMPLED_EVENTS.has(eventName)) { 97 + return 98 + } 93 99 const fullMetadata = { 94 100 ...rawMetadata, 95 101 } as Record<string, string> // Statsig typings are unnecessarily strict here.