diff --git a/components/analytics/AnalyticsShell.tsx b/components/analytics/AnalyticsShell.tsx index 696cc8815..c12db51b3 100644 --- a/components/analytics/AnalyticsShell.tsx +++ b/components/analytics/AnalyticsShell.tsx @@ -22,11 +22,18 @@ export default function AnalyticsShell() { return; } + const initServices = () => { + import('@/lib/services/create-services').then(({ getAppServices }) => { + getAppServices(); + setShouldLoad(true); + }).catch(console.error); + }; + // Wait until browser is completely idle before loading heavy analytics/logger/sentry SDKs if (typeof window !== 'undefined' && 'requestIdleCallback' in window) { - window.requestIdleCallback(() => setShouldLoad(true), { timeout: 3000 }); + window.requestIdleCallback(initServices, { timeout: 3000 }); } else { - const timer = setTimeout(() => setShouldLoad(true), 2500); + const timer = setTimeout(initServices, 2500); return () => clearTimeout(timer); } }, []);