Repository navigation
Description
Summary
#108 wired Sentry into reportInternalError (src/lib/report.ts), so production failures now produce telemetry. They produce far less actionable telemetry than the issue list makes it look: vite.config.ts sets no build.sourcemap, so Vite's default (false) applies and the build emits no maps at all — every production stack frame points into a minified, content-hashed chunk. Triage today rests on the free-form message plus two tags (atlas.kind, atlas.context). This ticket closes that gap. It splits cleanly into two halves that must not be conflated: what the repo can do (generate maps, upload them at build time, guarantee they are never deployed) and what is a Cloudflare Pages dashboard action (the auth token and org/project variables), because this repo controls no Pages build configuration — build command and output directory live in the dashboard, and the only repo-level deploy files are public/_redirects and public/_headers.
Proposed changes
Repo-side
- Emit source maps, and do not advertise them. Add
build.sourcemaptovite.config.ts. Prefer'hidden': maps are written, but no//# sourceMappingURL=comment is appended to the shipped JS, so nothing points a stranger's devtools at them even in the window before they are removed. - Upload at build time, then delete — do not deploy the maps. This is the explicit decision the ticket asks for and the answer is upload-then-delete. The widget is a public bundle embedded in third-party pages;
public/_headersserves/assets/*withAccess-Control-Allow-Origin: *and a one-year immutable cache, so a.mapthat reachesdist/is a permanently cached, CORS-open copy of our unminified source on somebody else's page load.@sentry/vite-pluginsupports exactly this (sourcemaps.filesToDeleteAfterUpload); a post-build script is the alternative if the plugin is declined. - The plugin must be inert without credentials.
pnpm dev,pnpm buildlocally, CI's build job,pnpm ladle:buildand forked PRs all run without a token and must behave exactly as today — no upload attempt, no warning-as-error, no build failure. Gate the plugin on the token's presence. - Guard the deletion with an assertion, not an intention.
pnpm buildalready ends inpnpm assert:css(scripts/assert-css-scoped.mjs) — the precedent for a build-output invariant. Add the equivalent: fail the build if any.mapsurvives indist/. Without it, a plugin-option rename in a future major silently starts publishing source. - Decide the release/artifact identity explicitly, and write down why.
src/lib/report.ts:325setsrelease: undefineddeliberately — the SDK's default readswindow.SENTRY_RELEASE?.id, a global belonging to the host page, which would stamp our events with a stranger's deploy version. Debug IDs injected by the bundler plugin into both the chunk and its map resolve frames without any release at all, which keeps that hazard closed; if a release string is wanted anyway (for regression tracking), it must be an explicit build-time value, never the inherited default.environmentis alreadyimport.meta.env.MODE(report.ts:305). - Keep the token out of the bundle, and prove it.
SENTRY_AUTH_TOKENmust not carry aVITE_prefix — onlyVITE_-prefixed vars reach the bundle — and the built output must be grepped to confirm the value appears nowhere indist/. - Re-measure the size budget. Debug-ID injection adds a small per-chunk payload and
sourcemapchanges the emitted JS.pnpm sizegates both graphs againstBUDGET_KIBinscripts/check-bundle-size.mjs; feat(widget): wire sentry into the error-reporting seam #108 left ~13.9 KiB (standalone) / ~12.3 KiB (embed) of headroom. Report the before/after and do not raise the budget silently. Note the gate walks the JS import graph only, so.mapfiles never enter it — the size check is not a substitute for the deletion assertion. - Document it.
.claude/docs/environment.mdandREADME.md— the new build-time variables, that they are build-time only, and the dashboard steps below.
Dashboard actions (cannot be done from this repo — list them in the report as a runbook)
- Provision the Sentry project and an auth token scoped to release/source-map upload only.
- Add
SENTRY_AUTH_TOKEN,SENTRY_ORG,SENTRY_PROJECTto thesahajatlasCloudflare Pages project's environment variables (production, and preview if preview builds should also upload — state the choice). Thesahajatlas-designLadle project does not need them; say so explicitly rather than leaving it open. VITE_SENTRY_DSNis a precondition for end-to-end verification. It is deliberately absent from.env(see the comment at.env:6-12) and set per-environment in the dashboard. If no DSN is provisioned yet, source-map upload can still be implemented and verified locally against the built output, but the "frames resolve in Sentry" criterion cannot pass — say which state the PR shipped in rather than implying the loop is closed.- The two operational settings feat(widget): wire sentry into the error-reporting seam #108 flagged and this ticket does not change: enable "Prevent Storing of IP Addresses", and set a short retention.
Acceptance criteria
- A production build with credentials present uploads maps and leaves zero
.mapfiles indist/— asserted by a build step that fails otherwise, not by inspection. - A production build without credentials succeeds and is byte-comparable to today's apart from the sourcemap-related emit; nothing is uploaded and no error or warning is raised. Verified for local
pnpm build, the CI build job, andpnpm ladle:build. -
SENTRY_AUTH_TOKENis notVITE_-prefixed and its value appears nowhere indist/(grep the built output and state the command used). -
pnpm sizereported before and after for both graphs;BUDGET_KIBunchanged, or the new value and its justification stated in the report. - The release/debug-id decision is implemented and explained, and
release: undefinedinsrc/lib/report.tseither stays with its reasoning intact or is replaced by an explicit build-time value that cannot fall back to the host's global. - Given a provisioned DSN, a real error thrown on the deployed preview resolves to original file and line in Sentry. If no DSN exists yet, the report states this is deferred and gives the exact steps to verify once one does.
- The dashboard runbook (variables, which project, which environments) is written into
.claude/docs/environment.mdand the implementation report. -
pnpm lint && pnpm typecheck && pnpm test:run && pnpm buildpass; CI green including the Dependency Audit gate for any new dev dependency. - Write an implementation report to
.claude/reports/<issue-number>-<short-slug>.md— in the MAIN checkout at/Users/devindra/Documents/Projects/SahajAtlasWebeven when implementing from a worktree (the folder is gitignored) — covering what changed, what was deliberately NOT changed, and exactly which steps remain manual.
Files affected
vite.config.ts—build.sourcemapand the upload pluginpackage.json/pnpm-lock.yaml— the build-time plugin as a dev dependency; possibly a newscriptsentryscripts/assert-no-sourcemaps.mjs(new, or folded into an existing post-build assertion).claude/docs/environment.md,README.md,.env(comment only, alongside the existingVITE_SENTRY_DSNnote)src/lib/report.ts— only if a release identifier is adopted; leave the rest of the file alone
Parallel implementation: this ticket OWNS the files listed above. Sibling tickets may run concurrently — avoid edits outside owned files except strictly additive ones. src/lib/report.ts in particular is a shared surface; touch only the release option if the decision requires it.
References
- feat(widget): wire sentry into the error-reporting seam #108 (
feat(widget): wire sentry into the error-reporting seam) / PR feat(widget): wire sentry into the error-reporting seam #123 —.claude/reports/108-sentry-reporting.md, "Deliberately NOT changed": "No source-map upload… Without it, production stack frames point into minified chunks… Highest-value follow-up." .claude/reports/RELEASE_READINESS.md§9 (Monitoring & support, grade D)src/lib/report.ts:305, :318-326—environment, and whyreleaseis pinned toundefinedpublic/_headers—/assets/*CORS*+ one-year immutable cache, the reason a shipped.mapis not recoverablescripts/check-bundle-size.mjs(BUDGET_KIB) andscripts/assert-css-scoped.mjs(the build-invariant precedent)- chore(build): version the embed bundle and add a changelog #94 (
chore(build): version the embed bundle and add a changelog) — where a real release identifier would come from, if one is wanted CLAUDE.md→ Deployment — Pages build config lives in the dashboard, not the repo
Metadata
Metadata
Assignees
Labels
Type
Fields
Hold Until
Activity
fix(build): stop the sentry config guard from bricking dev and preview
fix(build): gate the ladle output too, and grep it for the auth token
docs(report): describe the event scrub as the delete-list it is
ci(build): prove the credentialed map chain offline, and ignore the t…
docs: correct the token scopes and name the budget ratchet hazard
chore(build): upload sentry source maps from the pages build (#145)