feat: Add GlitchTip error monitoring with Sentry SDK

- 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.
This commit is contained in:
2026-01-18 21:33:59 +01:00
parent 489b975911
commit ef2b9dfabf
10 changed files with 1880 additions and 17 deletions

21
sentry.edge.config.ts Normal file
View File

@@ -0,0 +1,21 @@
import * as Sentry from "@sentry/nextjs";
const GLITCHTIP_DSN = process.env.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 (lower for edge)
tracesSampleRate: 0.05,
});
console.log("[Sentry] Edge initialized with GlitchTip");
}