Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

fix(sessions): guard useGetSessionsInfinite on site (#1089)

Alex Duggleby8d736198df3c
diff --git a/client/src/api/analytics/hooks/useGetUserSessions.ts b/client/src/api/analytics/hooks/useGetUserSessions.ts
index a656abdce..5b88d7eb9 100644
--- a/client/src/api/analytics/hooks/useGetUserSessions.ts
+++ b/client/src/api/analytics/hooks/useGetUserSessions.ts
@@ -89,6 +89,10 @@ export function useGetSessionsInfinite({
},
staleTime: Infinity,
refetchInterval,
+ // Without this the hook fires while the store's site is still empty, requesting
+ // /api/sites//sessions (400). LiveUserCount renders on every [site] page, so
+ // this ran on every page load.
+ enabled: !!site,
});
}