Template
PostHog loads after the page is idle through a same-origin /ingest proxy and follows the signed-in Convex user. Plausible uses the per-site script through a /pa proxy. Sentry keeps errors and traces only. Pages load only the @gib/ui modules they import, and client code reads public env from publicEnv.ts so zod stays out of the browser.
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
// 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;
|