From 6335be14e17c7bf1a36e9103148277717e3a7a90 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 6 Dec 2023 20:04:05 +0000 Subject: Move analytics out of init (#2115) * Remove listenSessionLoaded from analytics * Move analytics init call to navigation ready * Remove zod dependency from analytics * Mirror changes on the web * Delete listenSessionLoaded * Only set up listeners once --- src/lib/analytics/analytics.web.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/lib/analytics/analytics.web.tsx') diff --git a/src/lib/analytics/analytics.web.tsx b/src/lib/analytics/analytics.web.tsx index 0a5d5d689..df03ee13c 100644 --- a/src/lib/analytics/analytics.web.tsx +++ b/src/lib/analytics/analytics.web.tsx @@ -6,9 +6,8 @@ import { } from '@segment/analytics-react' import {sha256} from 'js-sha256' -import {useSession} from '#/state/session' +import {useSession, SessionAccount} from '#/state/session' import {logger} from '#/logger' -import {listenSessionLoaded} from '#/state/events' const segmentClient = createClient( { @@ -44,8 +43,8 @@ export function useAnalytics() { }, [hasSession, methods]) } -export function init() { - listenSessionLoaded(account => { +export function init(account: SessionAccount | undefined) { + if (account) { if (account.did) { if (account.did) { const did_hashed = sha256(account.did) @@ -56,7 +55,7 @@ export function init() { segmentClient.identify() } } - }) + } } export function Provider({children}: React.PropsWithChildren<{}>) { -- cgit 1.4.1