feat: Sentry in the API, the worker, the Site and the Kanban (off until the DSNs are set)

app/observability.py starts sentry-sdk for the API and the worker when
SENTRY_DSN_API is set, with send_default_pii off and a scrub that strips
cookies, tokens, bodies, CPF/CNPJ and e-mails. The browser loads the
official Sentry bundle from our own origin (web/vendor, provenance in its
README) and starts with SENTRY_DSN_WEB from /api/session or
/api/operator/me; every failed API answer the customer or the team gets is
reported with its path, status and message, never the request body. The
CSP allows Blyzer's Sentry ingest host.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-11 14:48:01 -03:00
parent 07515abbd8
commit 457ed4cbdf
23 changed files with 457 additions and 10 deletions

View File

@@ -243,6 +243,19 @@ behaviour). Set it to `on` in the stack's environment and redeploy to keep
between 1 and `DB_POOL_SIZE` connections per process (`DB_POOL_SIZE` defaults
to 20); set it back to `off` to return to one connection per block.
## 11. Sentry
Sentry is built into the API, the worker, the Site and the Kanban, and stays
off while the DSNs are empty. Set `SENTRY_DSN_API` and `SENTRY_DSN_WEB` in the
stack's environment, and optionally `SENTRY_ENVIRONMENT` (defaults to
`production`). The API and worker initialise from `SENTRY_DSN_API`; the browser
reads `SENTRY_DSN_WEB` from `/api/session` on the Site and from
`/api/operator/me` on the Kanban. When the DSNs exist, also set
`SENTRY_CSP_SOURCES` to the Sentry ingest origin, such as
`https://o123.ingest.sentry.io` (or `https://*.ingest.sentry.io`), so the CSP
`connect-src` allows the browser to send events. No image change is needed to
switch it on: update the stack variables and redeploy.
## Current blocker
This is the final deployment shape, but it is not authorized for production