Bluesky app fork with some witchin' additions 馃挮 witchsky.app
bluesky fork client
117
fork

Configure Feed

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

at d42a2808ba53a049fc38f559feeddaa5a335f93f 48 lines 1.3 kB view raw
1import {useEffect, useRef} from 'react' 2 3import {getCurrentState, onAppStateChange} from '#/lib/appState' 4import {useAnalytics} from '#/analytics' 5import {Features, features} from '#/analytics/features' 6import {IS_DEV, IS_TESTFLIGHT} from '#/env' 7 8/** 9 * Tracks passive analytics like app foreground/background time. 10 */ 11export function PassiveAnalytics() { 12 const ax = useAnalytics() 13 const lastActive = useRef( 14 getCurrentState() === 'active' ? performance.now() : null, 15 ) 16 17 useEffect(() => { 18 const sub = onAppStateChange(state => { 19 if (state === 'active') { 20 lastActive.current = performance.now() 21 ax.metric('state:foreground', {}) 22 } else if (lastActive.current !== null) { 23 ax.metric('state:background', { 24 secondsActive: Math.round( 25 (performance.now() - lastActive.current) / 1e3, 26 ), 27 }) 28 } 29 30 if (IS_DEV || IS_TESTFLIGHT) { 31 const feats = Object.values(Features).reduce( 32 (acc, feat) => { 33 acc[feat] = features.evalFeature(feat) 34 return acc 35 }, 36 {} as Record<Features, any>, 37 ) 38 ax.logger.info('FEATURES', { 39 features: feats, 40 definitions: features.getFeatures(), 41 }) 42 } 43 }) 44 return () => sub.remove() 45 }, [ax]) 46 47 return null 48}