Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

[Statsig] Include OS and track app state changes (#3273)

* Include platform in identify

* Track back/foregrounding

authored by

dan and committed by
GitHub
5bec5877 e9222a9d

+21 -1
+2
src/lib/statsig/events.ts
··· 2 2 init: { 3 3 initMs: number 4 4 } 5 + 'state:background': {} 6 + 'state:foreground': {} 5 7 'feed:endReached': { 6 8 feedType: string 7 9 itemCount: number
+19 -1
src/lib/statsig/statsig.tsx
··· 1 1 import React from 'react' 2 + import {Platform} from 'react-native' 2 3 import { 3 4 Statsig, 4 5 StatsigProvider, 5 6 useGate as useStatsigGate, 6 7 } from 'statsig-react-native-expo' 8 + import {AppState, AppStateStatus} from 'react-native' 7 9 import {useSession} from '../../state/session' 8 10 import {sha256} from 'js-sha256' 9 11 import {LogEvents} from './events' ··· 58 60 if (did) { 59 61 userID = sha256(did) 60 62 } 61 - return {userID} 63 + return { 64 + userID, 65 + platform: Platform.OS, 66 + } 62 67 } 68 + 69 + let lastState: AppStateStatus = AppState.currentState 70 + AppState.addEventListener('change', (state: AppStateStatus) => { 71 + if (state === lastState) { 72 + return 73 + } 74 + lastState = state 75 + if (state === 'active') { 76 + logEvent('state:foreground', {}) 77 + } else { 78 + logEvent('state:background', {}) 79 + } 80 + }) 63 81 64 82 export function Provider({children}: {children: React.ReactNode}) { 65 83 const {currentAccount} = useSession()