|
23 | 23 | # service verifies them with the same key. Keep it in sync across both. |
24 | 24 | JWT_SIGNING_KEY = config("JWT_SIGNING_KEY", default=SECRET_KEY) |
25 | 25 |
|
| 26 | +# --- Error monitoring (Sentry) -------------------------------------------- |
| 27 | +# Streams unhandled exceptions + a sampled slice of performance traces to |
| 28 | +# Sentry (project: unc-a4/moodify-app). Entirely opt-in: with no SENTRY_DSN |
| 29 | +# the SDK never initializes, so local dev and CI stay fully offline. The |
| 30 | +# [django] extra auto-wires request/exception capture -- no middleware edits. |
| 31 | +_SENTRY_DSN = config("SENTRY_DSN", default="") |
| 32 | +if _SENTRY_DSN: |
| 33 | + import sentry_sdk |
| 34 | + |
| 35 | + sentry_sdk.init( |
| 36 | + dsn=_SENTRY_DSN, |
| 37 | + # Label events by deploy stage; falls back to DEBUG when unset. |
| 38 | + environment=config( |
| 39 | + "SENTRY_ENVIRONMENT", |
| 40 | + default="development" if DEBUG else "production", |
| 41 | + ), |
| 42 | + # Git SHA / version tag for regression tracking (auto-detected if unset). |
| 43 | + release=config("SENTRY_RELEASE", default=None), |
| 44 | + # Fraction of requests captured as performance transactions. 10% keeps |
| 45 | + # trace volume (and quota) sane under real traffic; raise for debugging. |
| 46 | + traces_sample_rate=config("SENTRY_TRACES_SAMPLE_RATE", default=0.1, cast=float), |
| 47 | + # Do NOT attach user id / IP / cookies unless explicitly opted in -- |
| 48 | + # this API handles auth material, so default to privacy-preserving. |
| 49 | + send_default_pii=config("SENTRY_SEND_PII", default=False, cast=bool), |
| 50 | + ) |
| 51 | + |
26 | 52 | # --- MongoDB (the only datastore) ----------------------------------------- |
27 | 53 | # connect() is lazy -- it does not open a socket until the first query. |
28 | 54 | # maxPoolSize is kept small: on a serverless host each instance keeps its |
|
0 commit comments