Sentry
Overzicht
Section titled “Overzicht”Sentry vangt runtime errors en performance data op in alle drie Beam apps. Elke app gebruikt een eigen Sentry library afgestemd op het runtime-environment.
| App | Library | Runtime |
|---|---|---|
| Dashboard | @sentry/react | Browser (React 19) |
| API | toucan-js | Cloudflare Workers (V8 isolate) |
| Public Site | @sentry/astro | Cloudflare Pages (Astro SSR) |
Dashboard (@sentry/react)
Section titled “Dashboard (@sentry/react)”- Initialisatie: In
main.tsx, vóór React render - Source maps: Upload bij build via Vite plugin (
@sentry/vite-plugin) - React 19: Compatible via
@sentry/reactv8+ - Context: User ID wordt gezet na auth
API (toucan-js)
Section titled “API (toucan-js)”- Initialisatie: Als Hono middleware (eerste in de stack)
- Request context: Request ID, user ID, method, path worden meegestuurd
- Error boundaries: Alle uncaught exceptions in route handlers worden gevangen
- Performance: Request duration tracking
Waarom toucan-js?
Section titled “Waarom toucan-js?”De standaard @sentry/node SDK werkt niet in Cloudflare Workers (geen Node.js runtime). toucan-js is specifiek gebouwd voor de Workers V8 isolate omgeving.
Public Site (@sentry/astro)
Section titled “Public Site (@sentry/astro)”- Initialisatie: Via Astro integratie
- SSR errors: Server-side rendering fouten worden gevangen
- Source maps: Upload bij build
Environment Variables
Section titled “Environment Variables”| Variabele | Waar | Type |
|---|---|---|
VITE_SENTRY_DSN | Dashboard | Build-time |
SENTRY_DSN | API Worker | Secret |
SENTRY_DSN | Public Site | Build-time |
Alle drie apps gebruiken hetzelfde Sentry project maar verschillende DSN’s voor environment scheiding.
Logging vs Sentry
Section titled “Logging vs Sentry”| Type | Waar | Doel |
|---|---|---|
| Structured JSON logs | API Worker console | Request tracing, performance |
| Sentry events | Sentry dashboard | Errors, crashes, exceptions |
Sentry vangt alleen errors — structured logging (via de API logger middleware) logt alle requests met timing en status.
Troubleshooting
Section titled “Troubleshooting”| Probleem | Oorzaak | Oplossing |
|---|---|---|
| Source maps niet resolved | Upload mislukt bij build | Check SENTRY_AUTH_TOKEN in CI/CD |
| Workers errors niet zichtbaar | toucan-js niet als eerste middleware | Verplaats naar boven in middleware stack |
| Duplicate events | Zowel catch als middleware vangen | Gebruik captureException alleen in catch |