From 00a8731cdd912b480eea0f87f89c995f37649e2b Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 15 May 2026 06:23:34 +0200 Subject: [PATCH] fix(frontend): add sentrySvelteKit Vite plugin for source map upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds the sentrySvelteKit() Vite plugin as the first plugin in vite.config.ts. When SENTRY_AUTH_TOKEN is set at build time, source maps are uploaded to GlitchTip so error stack traces show original TypeScript source and line number. When SENTRY_AUTH_TOKEN is absent (CI, dev builds), upload is disabled via autoUploadSourceMaps: false — the build succeeds normally. Resolves Felix's review blocker on PR #591. Co-Authored-By: Claude Sonnet 4.6 --- .env.example | 2 ++ frontend/vite.config.ts | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/.env.example b/.env.example index eb33fe6e..b698b29f 100644 --- a/.env.example +++ b/.env.example @@ -52,6 +52,8 @@ GLITCHTIP_SECRET_KEY=changeme-generate-a-real-secret SENTRY_DSN= # VITE_SENTRY_DSN: frontend (SvelteKit) — injected at build time via Vite VITE_SENTRY_DSN= +# Sentry/GlitchTip auth token for source map upload at build time (optional) +SENTRY_AUTH_TOKEN= # Production SMTP — uncomment and fill in to send real emails instead of catching them # APP_BASE_URL=https://your-domain.example.com diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index cdde2860..4c75bc70 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,3 +1,4 @@ +import { sentrySvelteKit } from '@sentry/sveltekit'; import { paraglideVitePlugin } from '@inlang/paraglide-js'; import devtoolsJson from 'vite-plugin-devtools-json'; import tailwindcss from '@tailwindcss/vite'; @@ -33,6 +34,21 @@ export default defineConfig({ } }, plugins: [ + sentrySvelteKit({ + org: 'familienarchiv', + project: 'frontend', + authToken: process.env.SENTRY_AUTH_TOKEN, + sentryUrl: (() => { + const dsn = process.env.VITE_SENTRY_DSN; + if (!dsn) return undefined; + try { + return new URL(dsn).origin; + } catch { + return undefined; + } + })(), + autoUploadSourceMaps: !!process.env.SENTRY_AUTH_TOKEN + }), tailwindcss(), sveltekit(), devtoolsJson(),