From 88132b8f8422714abdc1371e06e00b88e9df5fa3 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Fri, 17 Jul 2026 15:19:27 +0200 Subject: [PATCH] fix: lazy initialize client services to bootstrap sentry --- components/analytics/AnalyticsShell.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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); } }, []);