Something went wrong. Try again.
Bluesky app fork with some witchin' additions 💫 forked from jollywhoppers.com/witchsky.app
Something went wrong. Try again.
1.3 kB · 46 lines
TSX
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import {useEffect, useRef} from 'react'
import {getCurrentState, onAppStateChange} from '#/lib/appState'import {useAnalytics} from '#/analytics'
/** * Tracks passive analytics like app foreground/background time. */export function PassiveAnalytics() { const ax = useAnalytics() const lastActive = useRef( getCurrentState() === 'active' ? performance.now() : null, )
useEffect(() => { const sub = onAppStateChange(state => { if (state === 'active') { lastActive.current = performance.now() ax.metric('state:foreground', {}) } else if (lastActive.current !== null) { ax.metric('state:background', { secondsActive: Math.round( (performance.now() - lastActive.current) / 1e3, ), }) }
// if (IS_DEV || IS_TESTFLIGHT) { // const feats = Object.values(Features).reduce( // (acc, feat) => { // acc[feat] = features.evalFeature(feat) // return acc // }, // {} as Record<Features, any>, // ) // ax.logger.info('FEATURES', { // features: feats, // definitions: features.getFeatures(), // }) // } }) return () => sub.remove() }, [ax])
return null}