- Install @sentry/nextjs - Add sentry.client.config.ts, sentry.server.config.ts, sentry.edge.config.ts - Conditional initialization based on GLITCHTIP_DSN env variable - Add /api/glitchtip-tunnel route to bypass ad blockers - Update next.config.mjs with withSentryConfig wrapper - Integrate Sentry.captureException in error.tsx and global-error.tsx - Support env vars: GLITCHTIP_DSN, NEXT_PUBLIC_GLITCHTIP_DSN, GLITCHTIP_URL, etc.
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import * as Sentry from "@sentry/nextjs";
|
|
|
|
const GLITCHTIP_DSN = process.env.NEXT_PUBLIC_GLITCHTIP_DSN;
|
|
|
|
// Only initialize Sentry if DSN is configured
|
|
if (GLITCHTIP_DSN) {
|
|
Sentry.init({
|
|
dsn: GLITCHTIP_DSN,
|
|
|
|
// Environment
|
|
environment: process.env.NODE_ENV,
|
|
|
|
// Sample rate for error events (1.0 = 100%)
|
|
sampleRate: 1.0,
|
|
|
|
// Performance monitoring sample rate (0.1 = 10%)
|
|
tracesSampleRate: 0.1,
|
|
|
|
// Use tunnel to bypass ad blockers
|
|
tunnel: "/api/glitchtip-tunnel",
|
|
|
|
// Disable debug in production
|
|
debug: process.env.NODE_ENV === "development",
|
|
|
|
// Ignore common non-actionable errors
|
|
ignoreErrors: [
|
|
"ResizeObserver loop limit exceeded",
|
|
"ResizeObserver loop completed with undelivered notifications",
|
|
"Non-Error promise rejection captured",
|
|
],
|
|
});
|
|
|
|
console.log("[Sentry] Client initialized with GlitchTip");
|
|
} else {
|
|
console.log("[Sentry] Client disabled - no DSN configured");
|
|
}
|