mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: hydrate analytics store from session data on login
This commit is contained in:
@@ -84,8 +84,20 @@ function AuthGuard({ children }: { children: React.ReactNode }) {
|
|||||||
analyticsConsentShownAt,
|
analyticsConsentShownAt,
|
||||||
} = useAuth();
|
} = useAuth();
|
||||||
const storeConsent = useAnalyticsStore((s) => s.consent);
|
const storeConsent = useAnalyticsStore((s) => s.consent);
|
||||||
|
const setStoreConsent = useAnalyticsStore((s) => s.setConsent);
|
||||||
const location = useLocation();
|
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
|
// Don't guard the login or change-password pages
|
||||||
if (
|
if (
|
||||||
location.pathname === "/login" ||
|
location.pathname === "/login" ||
|
||||||
|
|||||||
Reference in New Issue
Block a user