Skip to content

docs(widget): publish an accurate integrator guide - #144

Merged
Ardnived merged 5 commits into
mainfrom
docs/integrator-guide
Aug 11, 2026
Merged

Ardnived merged 5 commits into
mainfrom
docs/integrator-guide

Conversation

@Ardnived

@Ardnived Ardnived commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #93.

The README's embed snippet was wrong on both of its lines, and had been for months: it named sahaj-atlas.js (the build emits embed.js) and apikey (r2wc dash-cases the prop, so the element only observes api-key). A host copy-pasting it got a 404 script tag followed by an attribute that is never read — and then the "not set up correctly" screen. README.md:183 already used api-key, so the file contradicted itself. That fix is the first commit, on its own.

The rest publishes docs/embedding.md, the host-facing reference the repo has never had.

Everything is derived from the code, not from the ticket

Six waves of hardening landed since #93 was written, so the ticket and the readiness report are both stale in places. Every claim was checked against the source, and the two values that only exist at deploy time were read out of the live production bundle: locale JSON is compiled to https://sahajatlas.com/locales/, and the API to https://cloud.sydevelopers.com/api.

That first one is the two-origin story: a host loading the script from pages.dev still fetches its strings from sahajatlas.com, so connect-src needs it either way. Blocked, every label renders as its raw dotted key — which reads like a broken translation, not a blocked request. The guide now also says that value comes from VITE_HOST at build time and carries the two curl commands to re-verify it, so the next reader knows it is a deployment fact rather than a source fact.

The CSP contract, finished

The README's table covered Turnstile, Fathom, Sentry, style-src 'unsafe-inline', self-hosted fonts and the flags CDN, and honestly said it "does not yet cover the map's own origins". It now does. Three entries were missing everywhere, and each one hard-breaks something:

Missing Consequence
connect-src https://cloud.sydevelopers.com the widget loads, styles itself, and cannot fetch a single event
worker-src blob: the map never renders — mapbox-gl 3.28.1 boots its worker from URL.createObjectURL(new Blob(…)), verified in the installed source; there is no non-blob path in this build
img-src data: the map paints with no pins — the widget ships its markers as inline SVG

Also added: script-src https://api.mapbox.com (the RTL-text plugin, loaded on demand from inside the worker — workers inherit the document's policy) and events.mapbox.com. Each row carries why and what a host sees when it's blocked.

*.tiles.mapbox.com is deliberately NOT listed, though the readiness report and older Mapbox guidance name it: nothing in the shipped map library references that host. Listing origins we can't justify is how a table stops being read.

Also in the guide

Two deliberate calls

The README's CSP section is replaced by a pointer, not duplicated. A partial table beside a complete one is exactly how the two drift. Its privacy section stays where it is and the guide links to it.

demo.html's hardcoded api-key was dead — SahajCloud answers 403 to it, identically to sending no key at all (verified against the live API), so the harness could not run and failed in a way that looked like a code fault. It is now a named placeholder pointing at VITE_SAHAJCLOUD_API_KEY. The #respond anchor added in #92 is kept.

Review: completed, five defects fixed

A correctness review ran over the whole diff after the PR was opened. It confirmed the attribute table, the sizing claims, the URL shape, the browser floor, the one-per-page rule and the storage table — and found six defects, five of them real. Every wrong claim was a bold summary sentence, not a table row; the rows underneath were right in all five cases, which is a useful thing to know about where this kind of doc rots.

Fixed Was
"Only Turnstile, ipwho.is and Sentry degrade gracefully" contradicted six of our own rows. A strict-CSP host reads that and over-allows — the exact cost for this audience. Now names the five genuinely load-bearing entries and says everything else costs only the feature in its row.
the img-src widget-origin row described a request that does not exist — icons are inline SVG, and bg-circle-pattern is defined but never used so Tailwind emits nothing. Removed from the table and the policy block.
"Mapbox and Swiper register @font-face names" they register none; we register three. Inherited verbatim from the old README, so it had been wrong as long as the broken snippet was. The true statement is stronger: they are named Sahaj Raleway rather than Raleway precisely so they cannot override a host that self-hosts Raleway.
the doubled-script troubleshooting row had the wrong symptom — the widget renders normally, so a reader with a blank widget chased it and found nothing. Now points at the console message, and notes identical URLs are deduped by the module map, so the guard fires on the sahajatlas.com vs pages.dev mismatch.
README.md:91 *.ingest.sentry.io the precise pattern the guide flags as a silent-block trap, in the section that links to the guide for the full detail. Now *.sentry.io.

Also taken from its nits: the locale precedence chain was missing ?locale=, the browser table was missing iOS Safari 16.4, and the Sentry payload also carries navigator.userAgent.

The one finding not accepted was its CRITICAL on the locale-JSON origin, which argued VITE_HOST might not be sahajatlas.com because the checked-in dist/ compiles http://localhost:5173. That is a local build carrying the committed .env; the claim was made against the deployed bundle and re-confirmed. Its secondary suggestion was taken — the guide now says where the value comes from and how to re-verify it.

Verification

  • ✅ Lean gate green — lint + typecheck + 991 unit tests (re-run after the corrections).
  • ✅ pnpm build run to confirm the emitted filename really is dist/embed.js at the root.
  • ✅ Live probes: both hosts serve an identical embed.js; the deployed chunks were grepped for their baked-in origins; the demo key was tested against the real API.
  • ✅ Source sweep of every network origin, worker and style injection in src/** and the installed mapbox-gl / r2wc.
  • ✅ All 16 in-page anchors and every relative link resolve.
  • No src/** changes — docs only, as the ticket requires.

Could not be verified without a live deploy

Stated as conditional in the guide rather than asserted:

  • whether the production build carries VITE_FATHOM_ID and VITE_SENTRY_DSN (both dashboard-set), so whether the Fathom and Sentry rows are live today
  • the exact Sentry ingest host (DSN-derived; the guide keeps the deliberately-wide *.sentry.io and explains why *.ingest.sentry.io is a trap)
  • Fathom's beacon endpoint, which lives inside the remote script.js
  • imagedelivery.net as the image origin — CMS data, not pinned by the bundle
  • style-src-attr: reasoned from source to be unnecessary, not browser-verified

🤖 Generated with Claude Code

Ardnived and others added 3 commits August 11, 2026 09:33
The build emits `embed.js` (vite.config.ts `entryFileNames`), not
`sahaj-atlas.js`, and r2wc dash-cases the `apiKey` prop to `api-key` — so
copy-pasting the README's own snippet gave a host a 404 script tag followed
by an attribute the element never observes. `README.md:183` already used
`api-key`, so the file contradicted itself.

Refs #93

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`docs/embedding.md` is now the host-facing reference: the snippet, all nine
attributes, sizing in both modes, the URL shape and the foreign-anchor case,
the complete CSP contract, the browser floor, the style-tag ids, privacy, the
evergreen-update story and a troubleshooting table.

Every claim is derived from the code it describes, and the two deploy-time
values were read out of the LIVE bundle rather than guessed: the locale JSON is
compiled to `https://sahajatlas.com/locales/` and the API to
`https://cloud.sydevelopers.com/api`. That first one is the two-origin story —
a host loading the script from `pages.dev` still fetches strings from
`sahajatlas.com`, so `connect-src` needs it either way.

Three CSP entries were missing everywhere and each one hard-breaks something:
`connect-src` for SahajCloud (no data at all), `worker-src blob:` (mapbox-gl
boots its worker from a blob: URL — verified in mapbox-gl 3.28.1), and
`img-src data:` (the map ships its pins as inline SVG). `script-src
api.mapbox.com` is added for the RTL-text plugin. `*.tiles.mapbox.com` is
deliberately NOT listed — nothing in the shipped map library references it.

The README's CSP section is replaced by a pointer rather than a second copy: a
partial table beside a complete one is how the two drift. Its privacy section
stays put and the guide links to it.

demo.html's hardcoded api-key was dead — SahajCloud answers 403 to it, exactly
as it does to no key at all, so the harness could not run and looked like a
code failure. It is now a named placeholder pointing at
VITE_SAHAJCLOUD_API_KEY.

Closes #93

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A host-visible change is not finished when the code lands — `docs/embedding.md`
and `CHANGELOG.md` are the only documentation an embedding site ever reads, and
the CSP table is the part that breaks silently: a new origin, a new `<style>`
injection or a worker means somebody's policy has to grow, and they find out by
their page going blank rather than by our build failing.

Refs #93

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: d35bb4b
Status: ✅  Deploy successful!
Preview URL: https://c3340598.sahajatlas-design.pages.dev
Branch Preview URL: https://docs-integrator-guide.sahajatlas-design.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: d35bb4b
Status: ✅  Deploy successful!
Preview URL: https://5cdfe36d.sahajatlas.pages.dev
Branch Preview URL: https://docs-integrator-guide.sahajatlas.pages.dev

View logs

Ardnived and others added 2 commits August 11, 2026 10:08
Every one of them was a **bold summary sentence**, not a table row — the
confident generalisation is the thing this ticket exists to break, and the rows
underneath were right in all five cases.

- "Only Turnstile, ipwho.is and Sentry degrade gracefully" contradicted six of
  our own rows. A strict-CSP host reads that and over-allows, which is the exact
  cost for this audience. Replaced with the five genuinely load-bearing entries
  and "everything else costs only the feature in its row".
- The `img-src` widget-origin row described a request that does not exist: the
  only images are CMS photography and the flags CDN, icons are inline SVG, and
  `bg-circle-pattern` is defined but never used so Tailwind emits nothing.
  Removed from the table and the policy block — an unjustifiable row teaches
  readers to skim the justified ones.
- Mapbox and Swiper register no `@font-face` at all; we register three. That
  sentence was inherited verbatim from the old README, so it had been wrong as
  long as the broken snippet was. The true statement is stronger: they are named
  `Sahaj Raleway` rather than `Raleway` precisely so they cannot override a host
  that self-hosts Raleway, and `@font-face` is the one rule that cannot be scoped.
- The doubled-script row had the wrong symptom. `customElements.get` makes the
  second copy a no-op and the widget renders normally, so a reader with a blank
  widget chased it and found nothing. Re-pointed at the console message, and it
  now says identical URLs are deduped by the module map — so the guard fires on
  the sahajatlas.com vs pages.dev mismatch this guide already warns about.
- README said `*.ingest.sentry.io`, the precise pattern the guide flags as a
  silent-block trap, in the section that links to the guide for the full detail.

Also: the locale precedence chain was missing `?locale=`; the browser table was
missing iOS Safari 16.4; the Sentry payload also carries `navigator.userAgent`.

The locale-JSON origin claim STANDS — it was read from the deployed bundle, not
the local one — but now says it comes from `VITE_HOST` at build time and carries
the two curl commands to re-verify it, so the next reader knows it is a
deployment fact rather than a source fact.

Refs #93

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Two conflicts, both from #146 editing the very sections this branch moved.

README.md — #146 enriched the inline sizing section with #107's
container-responsive behaviour; this branch had replaced that block with a
pointer to docs/embedding.md. Kept the pointer, and ported #146's new facts
INTO the guide's own "Sizing the element" section rather than dropping them:
map-less now adapts to the element rather than the viewport, touch
affordances deliberately follow the device instead, and map mode warns in
the console when it is given a slot it cannot use.

demo.html — #146 added the full-page-slot warning to the same comment where
this branch replaced the dead API key with a placeholder. Kept both: the
warning reads first, then the key instruction. The 1cf076ab literal stays
gone; SahajCloud answers 403 to it, so restoring it would put the harness
back to looking broken for a reason unrelated to the code under test.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Ardnived
Ardnived merged commit f7367fd into main Aug 11, 2026
5 checks passed
@Ardnived
Ardnived deleted the docs/integrator-guide branch August 11, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(widget): publish an accurate integrator guide

1 participant