Repository navigation
fix(report): detect a missing Sentry DSN, and tag the deploy - #245
Conversation
The `sahajatlas-web` Sentry project had taken zero events in the seven weeks since the seam shipped. Nothing was broken: `reportingDsn()` returns `null` on an empty `VITE_SENTRY_DSN` and the SDK is then never fetched, exactly as designed, and the variable was set on neither Pages environment. A widget running inside other people's pages has no logs of any kind, so that project is the only production signal there is, and nothing was watching it for silence. `boot-origins.smoke.test.ts` already reads the eager graph back off the deploy and fails on an origin it cannot find, so the ingest host goes in as a sibling `REQUEST_ORIGINS` entry rather than as a new shape. Verified both directions against a real deploy: red against `sahajatlas.pages.dev` today, naming the missing origin, and green against a build carrying a DSN, which lands the literal in `assets/Spinner-*.js` — a chunk in both the standalone and the embed eager graphs, so one read covers both. The pattern is anchored on `sentry.io` rather than on the generic `<key>@<host>/<digits>` DSN shape. The looser form finds nothing in today's graph either, but a lookalike literal from some future dependency would then stand in for the DSN and turn this green while reporting stayed dead — the failure this is for. Anchored, a move onto a self-hosted ingest goes red instead, which is the direction `docs/testing.md` asks for. The ingest case gets its own `test`, because `requestOrigins()` throws on a missing origin and a dead DSN would otherwise be reported under a heading about private hosts. ⚠ This can only ever observe a PREVIEW. `get-cloudflare-preview-url.mjs` refuses the bare project host, so a green run says Preview carries a DSN and says nothing about Production. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`environment` read `import.meta.env.MODE`, which is `production` for every `vite build`. Preview is one of those builds, so once Preview carries a DSN — which it must, since the smoke lane can observe nothing else — its noise would be indistinguishable from the production events that matter. `VITE_SENTRY_ENVIRONMENT` is a per-environment Pages variable instead, and the default is `production`: the deploy whose events matter is the one an unset or blank variable cannot mislabel. Only Preview needs to set it. Both new cases fail against the version this replaces — under vitest `MODE` is `test`, so neither the override nor the default could have passed. This is also half of a cross-repo inconsistency worth naming: `wemeditate-web` reports under `production-frontend` while `sahajcloud` uses `production`, so a sweep filtered on `environment=production` silently skips WeMeditateWeb. The other two repos are out of scope here. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The `VITE_SENTRY_DSN` row carried three wrong facts in one line, and the runbook step above it read "skip if already set" for seven weeks while it was set on neither environment. - The CSP pointer sent a reader to `README.md`. That table lives in `docs/embedding.md`, and it has carried `*.sentry.io` since #123 — wide on purpose so a regional host matches. There is nothing to add. - The regional host was given as `o….ingest.us.sentry.io`. This org is in Sentry's DE region, which is also what the whole ticket turned on. - It said hosts can decline reporting with `error-reporting="false"`. That veto went in #149. The DSN is the only gate now. The row now records which environments hold the DSN and why Preview is load-bearing rather than optional: the smoke lane is the only automated observer and `get-cloudflare-preview-url.mjs` refuses the production host. Runbook step 1 asks for a read-back instead of an unchecked branch. The changelog entry is for the hosts: that `connect-src` row has described a DSN-configured build since #123, and no deploy had ever been one. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The /simplify pass found the same thing from three angles. The dedicated ingest test was a tautology: its capture group is anchored on `sentry\.io/\d+`, so `toMatch(/\.sentry\.io$/)` could not fail, and the real gate was always `requestOrigins()`'s own per-entry `expect`. A maintainer would have read it as the thing guarding the DSN, which is how a loosened pattern later goes unnoticed — the vacuous pass that file's own docblock warns about. It also swept the whole eager graph a second time for one label. The entry's 23-line comment told the story three times over. The story now sits once, in `docs/testing.md`, with the two caveats a reader of the code needs left inline: preview-only, and why the pattern is anchored. `reportingEnvironment()` loses the `typeof` dance copied from `reportingDsn()` — Vite inlines a string or nothing, and `||` covers both. The two spec cases become one `it.each`, as the file's other paired cases already are. Both rows still fail against `import.meta.env.MODE`. Verified after the cut: red against `sahajatlas.pages.dev`, which carries no DSN, green against a local build that does. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`import.meta.env.MODE` gave `development` on `pnpm dev`, and the replacement's bare `production` fallback took that away: a DSN placed in `.env.local` to exercise the seam would have reported into the production bucket. `DEV` is false for every `vite build`, so the preview/production split this is for is untouched. The spec table now carries `DEV` as a column. The unit lane runs with it true, which a build never does, so the production default needed stubbing to be assertable at all. All three rows still fail against `import.meta.env.MODE`. `requestOrigins()`'s shared failure message also stops blaming the regex. For the ingest entry the likely cause is the variable being unset on that environment, which is the whole of #232. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
|
Not fixable from this repo. Smoke is red on the one assertion #232 Phase 1 unblocks.
The fix is this PR's Manual verification steps 1 and 2 — a Cloudflare dashboard action a session cannot take. The only code-side alternative is weakening the new assertion, which the ticket rejected and Nothing pushed. Re-run Smoke once Preview carries the DSN. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
CI is still red after 3 fix attempts (failing: Smoke). I have stopped retrying. A comment or a push from you starts me again. 🤖 sydevs dispatcher |
`boot-origins.smoke.test.ts`'s `REQUEST_ORIGINS` holds one entry, the SahajCloud API. No ingest origin exists until #232 (PR #245) adds one, so `Production Smoke` checks nothing about the DSN today. A reader following the runbook would have skipped the only check there is. The rewording above it existed to make room for the bullet, so both hunks go and `docs/environment.md` leaves the diff. The bullet lands with #245, where the origin it names is real. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0185rnixqGMn3BApUyF34Ka2
Resolve CHANGELOG.md: keep #236/#246 entries from main alongside #232. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deploying sahajatlas with
|
| Latest commit: |
559e2f7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://bce0f8f4.sahajatlas.pages.dev |
| Branch Preview URL: | https://claude-fix-232-sentry-dsn.sahajatlas.pages.dev |
Deploying sahajatlas-design with
|
| Latest commit: |
559e2f7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://072dc18b.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://claude-fix-232-sentry-dsn.sahajatlas-design.pages.dev |
|
CI is still red after 3 fix attempts (failing: Smoke). I have stopped retrying. A comment or a push from you starts me again. 🤖 sydevs dispatcher |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is the right size and the right shape. Three ticket steps, 92 lines, no refactor smuggled in. The presence check rides the existing REQUEST_ORIGINS list instead of a new one, and reportingEnvironment() mirrors reportingDsn() beside it.
The body is stale, and the reviewer reads it first. Its [!IMPORTANT] block says Smoke will be red until Preview carries a DSN. Smoke went green on 739876e at 18:55Z today. "Preview: preview pending" is stale too.
Production still carries no DSN. Read just now: sahajatlas.com and sahajatlas.pages.dev each serve six eager chunks naming no ingest.*sentry.io host, while both name https://cloud.sydevelopers.com/api — so the read is not vacuous. The preview does name it. Ticket AC 1 is open, this PR's check cannot see that by design, and CHANGELOG.md:74 claims otherwise.
Findings
blockerCHANGELOG.md:74— "Crash reporting is switched on" is false for the production build.should-fixdocs/testing.md:128— the two caveats are now told three times, in a file every session loads.should-fixsrc/lib/report.ts:269— theDEVbranch is inert for every build.considertests/smoke/boot-origins.smoke.test.ts:76— the new entry's capture is not an origin.
What was checked
Ticket #232 and its acceptance criteria. The whole diff against origin/main. report.ts:230-290 and boot-origins.smoke.test.ts entire. The consumer side of the CSP claim: docs/embedding.md:794,825,834 and README.md:87, which confirm the body's "no CSP edit needed". Smoke job log 112445496766 — boot origins passed against 69a92542.sahajatlas.pages.dev. Production and preview graphs fetched and grepped, as above. Reviewer profile applied.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The entry claimed crash reporting was switched on. Nothing in the diff switches it on: the DSN is a Cloudflare Pages variable, and production carries none, so a host observes no Sentry request from it. This file records what a host can observe, so the entry now names the condition under which the connect-src row applies. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_016bZ8DucQjL4uFUMbynvQkD
CLAUDE.md imports this file, so the 19 lines loaded in every session forever while telling the same two caveats the spec's comment and docs/environment.md already carry. Four lines keep the one fact a reader here cannot re-derive. The move also reconnects the bullet list below to the paragraph it belongs to. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_016bZ8DucQjL4uFUMbynvQkD
|
The session for this item did not finish after 3 attempts. I have stopped retrying. A comment, a verb, or a push from you starts me again. 🤖 sydevs dispatcher |
The entry sat in REQUEST_ORIGINS and fed PRIVATE_HOST, which is anchored on a scheme, so a bare host could never be what either name says it is. Capturing the scheme alongside the host makes both entries yield the same kind of value, and a failure message print an origin. The entry's two caveats move into the comment beside it, their only home now. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_016bZ8DucQjL4uFUMbynvQkD
|
Pushed Adopted:
Left open for you:
Lean gate green (1678). Smoke run against the live preview both ways. Body refreshed — the 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
VITE_SENTRY_DSNnow fails the smoke lane. The ingest host joinsboot-origins.smoke.test.ts'sREQUEST_ORIGINS, which already fails on an origin it cannotfind in the deployed bundle. Nothing watched that project for silence, which is how it took zero
events for seven weeks.
import.meta.env.MODEisproductionforevery
vite build, previews included, so a DSN on Preview would have been indistinguishablefrom the real thing.
docs/environment.md's Sentry row loses three wrong facts — aREADME.mdCSP pointer, ausregion, and an embed veto deleted in feat(widget): split the embed into a smart loader and an element bundle #149 — and records which environments hold the DSN.Important
#232 Phase 1 is a dashboard action, and Production still has not had it. Read on
2026-10-06: Preview now carries a
VITE_SENTRY_DSN, so this PR's Smoke check is green — butsahajatlas.comandsahajatlas.pages.deveach serve six eager chunks naming the API originand no ingest host. So merging lights nothing up in production until that variable is set
there, and no check in this repo can say so (#244). Ticket AC 1 stays open.
Preview
Test results
pnpm lint,pnpm typecheck,pnpm test:run(1678 passed)report.sentry.test.ts20 passed;boot originsverified both waysagainst the live preview — green as shipped, red once the ingest pattern was narrowed so it
misses, with the failure naming the variable
pnpm sizegreen either way — standalone 301.9/308 KiB,embed 303.7/308 KiB. With the DSN the literal lands in
assets/Spinner-*.js, which sits inboth eager graphs, so one read covers both; without it,
grep -rlF ingest dist/assetsnamesnothing in the eager graph
Manual verification
VITE_SENTRY_DSNon thesahajatlasPages Production environment, inthe
https://<key>@o<n>.ingest.de.sentry.io/<project>form. DE region, not US. Previewalready carries one.
VITE_SENTRY_ENVIRONMENT=previewon Preview only. Production defaults toproduction.sahajatlas-webwith itsErrorKindtag. It must classify toserver,configorunknown—offline,not-foundandcaptcha-blockedare never reported.check does this — see chore(ci): nothing automated observes the production deploy, only a preview #244.
Notes for reviewer
implementable from this repo, so the title names what the diff does.
## Phaseschecklist on purpose. Phase 1 is a human dashboard step, and an unticked boxwould have the dispatcher firing implement sessions that can do nothing. All repo-side work is
here.
docs/embedding.md'sconnect-srcrow has carried*.sentry.iosince feat(widget): wire sentry into the error-reporting seam #123 — wide on purpose so a regional host matches — so no host or in-treeconsumer edit is implied. The
CHANGELOGentry is informational: that row stops describing abuild nobody had configured.
get-cloudflare-preview-url.mjsrefuses the production host by design, so the recurrence of this very bug in Production stays
silent behind a green Smoke check. It also carries the case for deriving the environment tag
from
CF_PAGES_BRANCHrather than a second hand-set variable.PRIVATE_HOSTto skip a DSN's userinfowas tried and reverted — the pattern requires
sentry.io, so no private host can ever match it,and the change would have read as a check while matching nothing.
requestOrigins()'sdouble scan of the graph and its
new Setover fresh objects are pre-existing and were leftalone rather than widening this PR.
DEVbranch inreportingEnvironment()stays:
.env.localis this repo's documented home for machine-specific overrides(
docs/environment.md:13), and before this diffMODEalready tagged a local DSN's eventsdevelopment, so dropping it would move them intoproduction. A dedicated test naming thesmoke presence check also stays out — it is the tautology removed below, and
requestOrigins()'s own failure message carries the name a reader sees.Detail
Why the pattern is anchored on
sentry.io. The generic<key>@<host>/<digits>DSN shapefinds nothing in today's production graph either (measured over all six eager chunks, ~1 MB of
minified JS), and it would make the private-host half of the spec real. It was rejected anyway: a
lookalike literal from some future dependency would then stand in for the DSN and turn the check
green while reporting stayed dead — the exact failure it exists for. Anchored, a move onto a
self-hosted ingest goes red instead, and someone has to say so.
docs/testing.mdasks for theloud failure over the vacuous pass.
The capture is the full origin, in two groups, because the DSN's public key sits between the
scheme and the host.
requestOrigins()joins them, so both entries yield the same kind of valueand a failure prints an origin rather than a bare host.
DEVin the environment fallback.MODEused to givedevelopmentonpnpm dev, and a bareproductionfallback took that away — a DSN placed in.env.localto exercise the seam wouldhave reported into the production bucket.
DEVis false for everyvite build, so thepreview/production split is untouched. The spec table carries it as a column because the unit
lane runs with it true.
The regression specs were watched failing, at the site that caused them: all three
environment rows go red against
environment: import.meta.env.MODE, and the smoke assertion goesred against the live DSN-less production deploy with the message naming the missing origin.
The first draft of the smoke change also added a dedicated test asserting the ingest origin
matched
/\.sentry\.io$/. It was a tautology — the capture group is already anchored onsentry\.io/\d+— and three review lenses independently flagged that a maintainer would read itas the thing guarding the DSN while the real gate was
requestOrigins()all along. It is gone.Security review: no findings. Triggered by
src/lib/reportand.env. The new variable is apublic deploy label, inlined by Vite, used only as a Sentry tag; the real secret in this area
(
SENTRY_AUTH_TOKEN) keeps its non-VITE_prefix and itsassert:mapsgrep gate.Reviewed with
/simplify(four lenses) plus/code-review high;pr-review-toolkitis notinstalled here.
comment-lint.mjsclean.Closes #232
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code