From f2e855fff90f0d02985897ec342d786b81ed2256 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Thu, 9 Apr 2026 11:32:47 +0200 Subject: [PATCH] chore: fix sentry logging instrumentation and infrastructure alignment --- .env.example | 1 + .gitea/workflows/deploy.yml | 1 + instrumentation.ts | 10 ++++++++++ lib/config.ts | 5 ++--- lib/env.ts | 1 + 5 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 instrumentation.ts diff --git a/.env.example b/.env.example index 14afced..d568580 100644 --- a/.env.example +++ b/.env.example @@ -74,6 +74,7 @@ AUTH_COOKIE_NAME=mintel_gatekeeper_session # Sentry / Glitchtip (Error Tracking) SENTRY_DSN= +NEXT_PUBLIC_SENTRY_DSN= # Gotify (In-App Notifications) # GOTIFY_URL= diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index ced1945..f4a9289 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -281,6 +281,7 @@ jobs: NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL GATEKEEPER_ORIGIN=$GATEKEEPER_ORIGIN SENTRY_DSN=$SENTRY_DSN + NEXT_PUBLIC_SENTRY_DSN=$SENTRY_DSN PROJECT_COLOR=$PROJECT_COLOR LOG_LEVEL=$LOG_LEVEL diff --git a/instrumentation.ts b/instrumentation.ts new file mode 100644 index 0000000..52e61c7 --- /dev/null +++ b/instrumentation.ts @@ -0,0 +1,10 @@ + +export async function register() { + if (process.env.NEXT_RUNTIME === 'nodejs') { + await import('./sentry.server.config'); + } + + if (process.env.NEXT_RUNTIME === 'edge') { + await import('./sentry.edge.config'); + } +} diff --git a/lib/config.ts b/lib/config.ts index 6fd4b9a..fdd0918 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -36,9 +36,8 @@ function createConfig() { }, errors: { - glitchtip: { - // Use SENTRY_DSN for both server and client (proxied) - dsn: env.SENTRY_DSN, + // Use NEXT_PUBLIC_SENTRY_DSN if available (required for browser-side SDK) + dsn: env.NEXT_PUBLIC_SENTRY_DSN || (env as any).SENTRY_DSN, // The proxied origin used in the frontend proxyPath: "/errors", enabled: Boolean(env.SENTRY_DSN), diff --git a/lib/env.ts b/lib/env.ts index ff9692c..c0658c3 100644 --- a/lib/env.ts +++ b/lib/env.ts @@ -17,6 +17,7 @@ import { const envExtension = { // Project specific overrides or additions AUTH_COOKIE_NAME: z.string().default("mb_gatekeeper_session"), + NEXT_PUBLIC_SENTRY_DSN: z.string().optional(), }; /**