Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

Fixes analytics init on web (#1923)

authored by

Eric Bailey and committed by
GitHub
952f5033 610eeecd

+11 -11
+11 -11
src/lib/analytics/analytics.web.tsx
··· 4 4 AnalyticsProvider, 5 5 useAnalytics as useAnalyticsOrig, 6 6 } from '@segment/analytics-react' 7 - import {RootStoreModel} from 'state/models/root-store' 8 - import {useStores} from 'state/models/root-store' 9 7 import {sha256} from 'js-sha256' 8 + 9 + import {useSession} from '#/state/session' 10 10 import {logger} from '#/logger' 11 + import {listenSessionLoaded} from '#/state/events' 11 12 12 13 const segmentClient = createClient( 13 14 { ··· 24 25 export const track = segmentClient?.track?.bind?.(segmentClient) 25 26 26 27 export function useAnalytics() { 27 - const store = useStores() 28 + const {hasSession} = useSession() 28 29 const methods = useAnalyticsOrig() 29 30 return React.useMemo(() => { 30 - if (store.session.hasSession) { 31 + if (hasSession) { 31 32 return methods 32 33 } 33 34 // dont send analytics pings for anonymous users ··· 40 41 alias: () => {}, 41 42 reset: () => {}, 42 43 } 43 - }, [store, methods]) 44 + }, [hasSession, methods]) 44 45 } 45 46 46 - export function init(store: RootStoreModel) { 47 - store.onSessionLoaded(() => { 48 - const sess = store.session.currentSession 49 - if (sess) { 50 - if (sess.did) { 51 - const did_hashed = sha256(sess.did) 47 + export function init() { 48 + listenSessionLoaded(account => { 49 + if (account.did) { 50 + if (account.did) { 51 + const did_hashed = sha256(account.did) 52 52 segmentClient.identify(did_hashed, {did_hashed}) 53 53 logger.debug('Ping w/hash') 54 54 } else {