feat(frontend): @sentry/nextjs init для GlitchTip (#204 frontend) #208

Merged
lekss361 merged 1 commit from feat/204-glitchtip-frontend into main 2026-05-16 15:09:39 +00:00
Owner

Summary

  • Добавляет @sentry/nextjs@10.53.1 для отправки frontend-ошибок в self-hosted GlitchTip (errors.gendsgn.ru)
  • SDK не инициализируется если NEXT_PUBLIC_GLITCHTIP_DSN не задан (no-op в локальной разработке)
  • Session Replay интеграции отключены явно (replaysSessionSampleRate: 0) — GlitchTip не поддерживает Replay
  • Source maps upload происходит только при наличии GLITCHTIP_AUTH_TOKEN (CI builds); без токена upload молча пропускается

Env vars

Var Scope
NEXT_PUBLIC_GLITCHTIP_DSN Client + server (runtime)
GLITCHTIP_AUTH_TOKEN CI build-time secret
SENTRY_ORG Build-time (gendesign)
SENTRY_PROJECT Build-time (frontend)
SENTRY_URL Build-time (https://errors.gendsgn.ru/)

Test plan

  • npx tsc --noEmit — чисто
  • npm run build без DSN — собирается (SDK no-op)
  • После добавления DSN в .env.local — ошибка в браузере должна появляться в GlitchTip

Closes #204

## Summary - Добавляет `@sentry/nextjs@10.53.1` для отправки frontend-ошибок в self-hosted GlitchTip (`errors.gendsgn.ru`) - SDK не инициализируется если `NEXT_PUBLIC_GLITCHTIP_DSN` не задан (no-op в локальной разработке) - Session Replay интеграции отключены явно (`replaysSessionSampleRate: 0`) — GlitchTip не поддерживает Replay - Source maps upload происходит только при наличии `GLITCHTIP_AUTH_TOKEN` (CI builds); без токена upload молча пропускается ## Env vars | Var | Scope | |-----|-------| | `NEXT_PUBLIC_GLITCHTIP_DSN` | Client + server (runtime) | | `GLITCHTIP_AUTH_TOKEN` | CI build-time secret | | `SENTRY_ORG` | Build-time (gendesign) | | `SENTRY_PROJECT` | Build-time (frontend) | | `SENTRY_URL` | Build-time (https://errors.gendsgn.ru/) | ## Test plan - [ ] `npx tsc --noEmit` — чисто - [ ] `npm run build` без DSN — собирается (SDK no-op) - [ ] После добавления DSN в `.env.local` — ошибка в браузере должна появляться в GlitchTip Closes #204
Author
Owner

Empty PR — nothing to review

Head SHA 256909d2 совпадает с base SHA — branch не содержит коммитов.

  • additions: 0, deletions: 0, changed_files: 0

PR body описывает @sentry/nextjs@10.53.1 init для frontend, но реальных изменений нет.

Possible causes:

  • Worker создал branch + PR до commit/push
  • Локальный commit не push'нут на Forgejo remote

Action: worker должен push'нуть commits в feat/204-glitchtip-frontend ветку, либо close PR если работа не начата.

## Empty PR — nothing to review Head SHA `256909d2` совпадает с base SHA — branch не содержит коммитов. - `additions: 0`, `deletions: 0`, `changed_files: 0` PR body описывает `@sentry/nextjs@10.53.1` init для frontend, но реальных изменений нет. **Possible causes**: - Worker создал branch + PR до commit/push - Локальный commit не push'нут на Forgejo remote **Action**: worker должен push'нуть commits в `feat/204-glitchtip-frontend` ветку, либо close PR если работа не начата.
lekss361 added 1 commit 2026-05-16 15:04:27 +00:00
- Add @sentry/nextjs@10.53.1
- sentry.{client,server,edge}.config.ts — GlitchTip-compatible init
  (no Replay, tracesSampleRate=0.05, guarded on DSN presence)
- src/instrumentation.ts — register() + captureRequestError export
- next.config.ts — wrapped in withSentryConfig (v10 API:
  treeshake.removeDebugLogging, sourcemaps.deleteSourcemapsAfterUpload)
- .env.example — NEXT_PUBLIC_GLITCHTIP_DSN + SENTRY_* vars
- .gitignore — .sentryclirc exclusion
Author
Owner

Previous run created PR but never pushed commits — fixed. All files now present:

  • @sentry/nextjs v10.53.1
  • sentry.{client,server,edge}.config.ts + instrumentation.ts
  • next.config.ts wrapped in withSentryConfig
  • .env.example + .gitignore updated

Ready for re-review.

Previous run created PR but never pushed commits — fixed. All files now present: - @sentry/nextjs v10.53.1 - sentry.{client,server,edge}.config.ts + instrumentation.ts - next.config.ts wrapped in withSentryConfig - .env.example + .gitignore updated Ready for re-review.
Author
Owner

Code Review verdict — PR #208

Summary

  • Status: APPROVE
  • Files reviewed: 9 (lock-файл +3103/-417 пропущен — package-lock.json regen)
  • Effective review surface: ~80 lines across 8 файлов (3 sentry configs + instrumentation + next.config + .env.example + .gitignore + package.json)
  • Head SHA: 653e74f

A. Security 🔒

  • No hardcoded DSN / secrets — все через process.env.*
  • .env.example без значений, документирует все 5 env vars
  • .gitignore дополнен .sentryclirc и frontend/.sentryclirc — auth-token leak prevented
  • Source-maps upload guarded: authToken: process.env.GLITCHTIP_AUTH_TOKEN (undefined → silent skip)
  • sourcemaps.deleteSourcemapsAfterUpload: true — maps не сервятся публично
  • XSS не применим (PR не рендерит user-content)

B. Correctness 🎯

  • SDK no-op подтверждён: каждый из sentry.{client,server,edge}.config.ts оборачивает Sentry.init в if (dsn) { ... }
  • Session Replay отключён явно — replaysSessionSampleRate: 0, replaysOnErrorSampleRate: 0, integrations: [] (client)
  • Server/edge fallback: GLITCHTIP_DSN ?? NEXT_PUBLIC_GLITCHTIP_DSN (server-side env совместим с backend PR #207)
  • instrumentation.ts корректно gate'ит по NEXT_RUNTIME === "nodejs" | "edge"
  • ⚠️ Minor (non-blocking): instrumentation.ts:9-10 использует top-level await import("@sentry/nextjs") для onRequestError. Работает в Next.js 15 ESM, но загружает модуль даже без DSN. Каноничный шаблон Sentry — обычный import { captureRequestError }. Можно поправить в follow-up, не блокер.

C. Performance

  • tracesSampleRate: 0.05 (5%) — разумно для прод
  • Без DSN — Sentry.init не вызывается, нет runtime overhead
  • widenClientFileUpload: true + webpack.treeshake.removeDebugLogging: true — bundle остаётся компактным
  • tunnelRoute: undefined — explicit no-tunnel (GlitchTip без CORS proxy)

D. Conventions 📋

  • TS strict, no any
  • App router (PR не трогает client components)
  • Никаких useEffect для fetch (irrelevant — нет React data fetching)
  • Sentry config files в корне frontend/ — соответствует контракту @sentry/nextjs ≥9
  • withSentryConfig обёртка корректна — сохраняет существующие images/rewrites/redirects/headers

E. Backward compat

  • Existing pages не затронуты (config-only PR)
  • next.config.ts сохраняет всю существующую логику, только wrap'нул с withSentryConfig
  • package-lock.json regenerated — ожидаемо для нового deps

Cross-file impact (#205 / #207 / #208)

Env var contract согласован между всеми PR:

Var Defined (PR #205) Consumed
GLITCHTIP_DSN backend #207 + frontend server/edge (#208)
NEXT_PUBLIC_GLITCHTIP_DSN frontend client (#208)
GLITCHTIP_AUTH_TOKEN (CI secret) frontend build (#208)
SENTRY_ORG/PROJECT/URL (frontend .env.example) frontend build (#208)

Порядок мержа не критичен — все SDK no-op без DSN.

Auto-merge policy

APPROVE без critical issues → squash-merge per user override 2026-05-16.

<!-- gendesign-review-bot: sha=653e74f verdict=approve --> ## Code Review verdict — PR #208 ### Summary - Status: ✅ APPROVE - Files reviewed: 9 (lock-файл +3103/-417 пропущен — `package-lock.json` regen) - Effective review surface: ~80 lines across 8 файлов (3 sentry configs + instrumentation + next.config + .env.example + .gitignore + package.json) - Head SHA: `653e74f` ### A. Security 🔒 - ✅ No hardcoded DSN / secrets — все через `process.env.*` - ✅ `.env.example` без значений, документирует все 5 env vars - ✅ `.gitignore` дополнен `.sentryclirc` и `frontend/.sentryclirc` — auth-token leak prevented - ✅ Source-maps upload guarded: `authToken: process.env.GLITCHTIP_AUTH_TOKEN` (undefined → silent skip) - ✅ `sourcemaps.deleteSourcemapsAfterUpload: true` — maps не сервятся публично - ✅ XSS не применим (PR не рендерит user-content) ### B. Correctness 🎯 - ✅ SDK no-op подтверждён: каждый из `sentry.{client,server,edge}.config.ts` оборачивает `Sentry.init` в `if (dsn) { ... }` - ✅ Session Replay отключён явно — `replaysSessionSampleRate: 0`, `replaysOnErrorSampleRate: 0`, `integrations: []` (client) - ✅ Server/edge fallback: `GLITCHTIP_DSN ?? NEXT_PUBLIC_GLITCHTIP_DSN` (server-side env совместим с backend PR #207) - ✅ `instrumentation.ts` корректно gate'ит по `NEXT_RUNTIME === "nodejs" | "edge"` - ⚠️ Minor (non-blocking): `instrumentation.ts:9-10` использует top-level `await import("@sentry/nextjs")` для `onRequestError`. Работает в Next.js 15 ESM, но загружает модуль даже без DSN. Каноничный шаблон Sentry — обычный `import { captureRequestError }`. Можно поправить в follow-up, не блокер. ### C. Performance ⚡ - ✅ `tracesSampleRate: 0.05` (5%) — разумно для прод - ✅ Без DSN — `Sentry.init` не вызывается, нет runtime overhead - ✅ `widenClientFileUpload: true` + `webpack.treeshake.removeDebugLogging: true` — bundle остаётся компактным - ✅ `tunnelRoute: undefined` — explicit no-tunnel (GlitchTip без CORS proxy) ### D. Conventions 📋 - ✅ TS strict, no `any` - ✅ App router (PR не трогает client components) - ✅ Никаких `useEffect` для fetch (irrelevant — нет React data fetching) - ✅ Sentry config files в корне `frontend/` — соответствует контракту `@sentry/nextjs` ≥9 - ✅ `withSentryConfig` обёртка корректна — сохраняет существующие `images/rewrites/redirects/headers` ### E. Backward compat - ✅ Existing pages не затронуты (config-only PR) - ✅ `next.config.ts` сохраняет всю существующую логику, только wrap'нул с `withSentryConfig` - ✅ `package-lock.json` regenerated — ожидаемо для нового deps ### Cross-file impact (#205 / #207 / #208) Env var contract согласован между всеми PR: | Var | Defined (PR #205) | Consumed | |-----|------|------| | `GLITCHTIP_DSN` | ✅ | backend #207 + frontend server/edge (#208) | | `NEXT_PUBLIC_GLITCHTIP_DSN` | ✅ | frontend client (#208) | | `GLITCHTIP_AUTH_TOKEN` | (CI secret) | frontend build (#208) | | `SENTRY_ORG/PROJECT/URL` | (frontend `.env.example`) | frontend build (#208) | Порядок мержа не критичен — все SDK no-op без DSN. ### Auto-merge policy ✅ APPROVE без critical issues → squash-merge per user override 2026-05-16.
lekss361 merged commit 277499684b into main 2026-05-16 15:09:39 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#208
No description provided.