// https://docs.sentry.io/platforms/javascript/guides/nextjs/ import { startAnalytics } from '@/lib/analytics'; import { publicEnv } from '@/publicEnv'; import * as Sentry from '@sentry/nextjs'; // Session replay is left to PostHog, so Sentry carries no replay integration. Sentry.init({ dsn: publicEnv.NEXT_PUBLIC_SENTRY_DSN, // https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#sendDefaultPii sendDefaultPii: false, // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate // A tenth of page loads is plenty for performance trends and keeps the // self-hosted Sentry light. tracesSampleRate: 0.1, enableLogs: true, debug: false, }); // The feedback widget is a floating button nobody needs during the first // paint, so its code is split into its own chunk and added once the page has // loaded. const addFeedbackWidget = async () => { const { feedbackIntegration } = await import('@sentry/nextjs'); Sentry.addIntegration(feedbackIntegration({ colorScheme: 'system' })); }; if (document.readyState === 'complete') void addFeedbackWidget(); else window.addEventListener('load', () => void addFeedbackWidget(), { once: true, }); startAnalytics(); // `captureRouterTransitionStart` is available from SDK version 9.12.0 onwards export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;