Skip to content

fix(report): detect a missing Sentry DSN, and tag the deploy - #245

Merged
Ardnived merged 9 commits into
mainfrom
claude/fix-232-sentry-dsn
Oct 6, 2026
Merged

Ardnived merged 9 commits into
mainfrom
claude/fix-232-sentry-dsn

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • A deploy with no VITE_SENTRY_DSN now fails the smoke lane. The ingest host joins
    boot-origins.smoke.test.ts's REQUEST_ORIGINS, which already fails on an origin it cannot
    find in the deployed bundle. Nothing watched that project for silence, which is how it took zero
    events for seven weeks.
  • Reported events name the deploy they came from. import.meta.env.MODE is production for
    every vite build, previews included, so a DSN on Preview would have been indistinguishable
    from the real thing.
  • docs/environment.md's Sentry row loses three wrong facts — a README.md CSP pointer, a
    us region, 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 — but
sahajatlas.com and sahajatlas.pages.dev each serve six eager chunks naming the API origin
and 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

  • Lean gate: ✓ pnpm lint, pnpm typecheck, pnpm test:run (1678 passed)
  • Targeted specs: report.sentry.test.ts 20 passed; boot origins verified both ways
    against the live preview — green as shipped, red once the ingest pattern was narrowed so it
    misses, with the failure naming the variable
  • Build: ✓ with and without a DSN. pnpm size green either way — standalone 301.9/308 KiB,
    embed 303.7/308 KiB. With the DSN the literal lands in assets/Spinner-*.js, which sits in
    both eager graphs, so one read covers both; without it, grep -rlF ingest dist/assets names
    nothing in the eager graph

Manual verification

  1. Outstanding: set VITE_SENTRY_DSN on the sahajatlas Pages Production environment, in
    the https://<key>@o<n>.ingest.de.sentry.io/<project> form. DE region, not US. Preview
    already carries one.
  2. Set VITE_SENTRY_ENVIRONMENT=preview on Preview only. Production defaults to
    production.
  3. ✓ Done — this PR's Smoke check is green on the ingest origin.
  4. Throw a widget-root error on a deploy and confirm it arrives in sahajatlas-web with its
    ErrorKind tag. It must classify to server, config or unknown — offline,
    not-found and captcha-blocked are never reported.
  5. After the next production deploy, confirm the production bundle names the ingest host. No
    check does this
    — see chore(ci): nothing automated observes the production deploy, only a preview #244.

Notes for reviewer

  • Scope: the title is not the issue's. fix(report): nothing has ever reached the widget's Sentry project #232's title states the problem; only its Phase 2 is
    implementable from this repo, so the title names what the diff does.
  • No ## Phases checklist on purpose. Phase 1 is a human dashboard step, and an unticked box
    would have the dispatcher firing implement sessions that can do nothing. All repo-side work is
    here.
  • No contract surface moved. docs/embedding.md's connect-src row has carried
    *.sentry.io since feat(widget): wire sentry into the error-reporting seam #123 — wide on purpose so a regional host matches — so no host or in-tree
    consumer edit is implied. The CHANGELOG entry is informational: that row stops describing a
    build nobody had configured.
  • Filed on the way: chore(ci): nothing automated observes the production deploy, only a preview #244. Every check in this repo reads a preview; get-cloudflare-preview-url.mjs
    refuses 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_BRANCH rather than a second hand-set variable.
  • Review findings dismissed, with reasons: widening PRIVATE_HOST to skip a DSN's userinfo
    was 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()'s
    double scan of the graph and its new Set over fresh objects are pre-existing and were left
    alone rather than widening this PR.
  • Second review round, two findings left open. The DEV branch in reportingEnvironment()
    stays: .env.local is this repo's documented home for machine-specific overrides
    (docs/environment.md:13), and before this diff MODE already tagged a local DSN's events
    development, so dropping it would move them into production. A dedicated test naming the
    smoke 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 shape
finds 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.md asks for the
loud 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 value
and a failure prints an origin rather than a bare host.

DEV in the environment fallback. MODE used to give development on pnpm dev, and a 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 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 goes
red 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 on
sentry\.io/\d+ — and three review lenses independently flagged that a maintainer would read it
as the thing guarding the DSN while the real gate was requestOrigins() all along. It is gone.

Security review: no findings. Triggered by src/lib/report and .env. The new variable is a
public 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 its assert:maps grep gate.

Reviewed with /simplify (four lenses) plus /code-review high; pr-review-toolkit is not
installed here. comment-lint.mjs clean.

Closes #232

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

claude added 5 commits October 2, 2026 01:45
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]>
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 2, 2026
@sydevs-bot

sydevs-bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running
CI fix 3

recent dispatches
  • 19:11Z address-review · attempt 1 · session · done
  • 19:11Z address-review · attempt 1 · session
  • 19:05Z address-review · attempt 1 · session · done
  • 19:05Z address-review · attempt 1 · session
  • 18:55Z adversarial-review · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Not fixable from this repo. Smoke is red on the one assertion #232 Phase 1 unblocks.

boot-origins.smoke.test.ts found no Sentry ingest host in the preview's eager graph. Discovery succeeded, the preview deployed, and the other 15 smoke assertions passed. VITE_SENTRY_DSN is still unset on the sahajatlas Pages Preview environment.

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 fix-ci forbids.

Nothing pushed. Re-run Smoke once Preview carries the DSN.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 2, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

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 pushed a commit that referenced this pull request Oct 3, 2026
`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]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

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

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas-design with  Cloudflare Pages  Cloudflare Pages

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

View logs

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

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 sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 6, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 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

  • blocker CHANGELOG.md:74 — "Crash reporting is switched on" is false for the production build.
  • should-fix docs/testing.md:128 — the two caveats are now told three times, in a file every session loads.
  • should-fix src/lib/report.ts:269 — the DEV branch is inert for every build.
  • consider tests/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

Comment thread CHANGELOG.md Resolved
Comment thread docs/testing.md Resolved
Comment thread src/lib/report.ts Resolved
Comment thread tests/smoke/boot-origins.smoke.test.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 6, 2026
claude added 2 commits October 6, 2026 19:10
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
@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 6, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

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

@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed awaiting labels Oct 6, 2026
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
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Pushed 559e2f7 — two adopted, two left open.

Adopted:

  • CHANGELOG.md:74 — 7234801. The entry names the condition, not a deploy state. Production carries no DSN, read again just now.
  • docs/testing.md:128 — bcd54ac. Nineteen session-loaded lines become four.

Left open for you:

  • report.ts:269 — the DEV branch stays. Dropping it moves a local DSN's events into production, which MODE did not.
  • boot-origins.smoke.test.ts:76 — half adopted: the capture is a full origin now. No second test for the presence check.

Lean gate green (1678). Smoke run against the live preview both ways. Body refreshed — the [!IMPORTANT] block was stale.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 6, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 6, 2026 19:19
@sydevs-bot
sydevs-bot requested a review from Ardnived October 6, 2026 19:19
@sydevs-bot
sydevs-bot enabled auto-merge October 6, 2026 19:19
@Ardnived
Ardnived disabled auto-merge October 6, 2026 20:14
@Ardnived
Ardnived added this pull request to the merge queue Oct 6, 2026
Merged via the queue into main with commit 9a921b3 Oct 6, 2026
65 of 70 checks passed
@Ardnived
Ardnived deleted the claude/fix-232-sentry-dsn branch October 6, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix(report): nothing has ever reached the widget's Sentry project

3 participants