From e46356c4d5fec199e8dc6dab452093d8f99ae339 Mon Sep 17 00:00:00 2001 From: ashim-hq Date: Thu, 23 Apr 2026 10:08:24 +0800 Subject: [PATCH] fix: hydrate analytics store from session data on login --- apps/web/src/App.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx index d72ef6ed..ba4e839a 100644 --- a/apps/web/src/App.tsx +++ b/apps/web/src/App.tsx @@ -84,8 +84,20 @@ function AuthGuard({ children }: { children: React.ReactNode }) { analyticsConsentShownAt, } = useAuth(); const storeConsent = useAnalyticsStore((s) => s.consent); + const setStoreConsent = useAnalyticsStore((s) => s.setConsent); const location = useLocation(); + // Hydrate the analytics store from session data on initial load + useEffect(() => { + if (!loading && analyticsEnabled !== undefined) { + setStoreConsent({ + analyticsEnabled: analyticsEnabled ?? null, + analyticsConsentShownAt: analyticsConsentShownAt ?? null, + analyticsConsentRemindAt: null, + }); + } + }, [loading, analyticsEnabled, analyticsConsentShownAt, setStoreConsent]); + // Don't guard the login or change-password pages if ( location.pathname === "/login" ||