feat(sentry): add error monitoring, tracing, session replay, and structured logging

Integrates @sentry/sveltekit 10.49.0 via the modern SvelteKit path
(instrumentation.server.ts + experimental.instrumentation.server).

- instrumentation.server.ts: server-side init with tracing, logging,
  and console capture (log/warn/error forwarded to Sentry)
- hooks.client.ts: client-side init with browserTracingIntegration,
  replayIntegration (maskAllText/blockAllMedia), consoleLoggingIntegration,
  and handleErrorWithSentry
- hooks.server.ts: adds handleErrorWithSentry export, composes existing
  appHandle with sentryHandle() via sequence(), and sets isolation scope
  attributes (user_id, username, permission_level) per request for
  log/trace correlation
- svelte.config.js: enables experimental.instrumentation.server and
  experimental.tracing.server
- vite.config.ts: adds sentrySvelteKit() plugin for source map uploads
- .env.example: documents VITE_SENTRY_DSN, SENTRY_DSN, SENTRY_ORG,
  SENTRY_PROJECT, SENTRY_AUTH_TOKEN

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-18 16:10:36 +08:00
parent 4de2112a11
commit e55dfbe4ee
8 changed files with 1467 additions and 22 deletions

View File

@@ -3,3 +3,12 @@
# No API_BASE_URL override needed.
PUBLIC_TURNSTILE_SITE_KEY=0x4AAAAAACI5pu-lNWFc6Wu1
TURNSTILE_SECRET_KEY=
# Sentry — error monitoring, tracing, session replay, logging
# VITE_SENTRY_DSN is public (bundled into the browser build)
VITE_SENTRY_DSN=
SENTRY_DSN=
SENTRY_ORG=
SENTRY_PROJECT=
# SENTRY_AUTH_TOKEN is secret; never commit it — use CI secrets or .env.local
SENTRY_AUTH_TOKEN=