Repository navigation
fix(i18n): production hygiene for logging, locales, storage and third-party flows - #120
Merged
Merged
Conversation
…e host-origin write i18next shipped `debug: true` to every host page's console (verified in the deployed bundle), the picker offered 2 of the 10 locale bundles that ship, and the language detector ran on library defaults — reading cookies/localStorage and writing `i18nextLng` onto the HOST's origin, the one storage path not wrapped against a sandboxed-iframe throw. `supportedLanguages` + the detection options move to the side-effect-free `i18n-options.ts` so the node lane can assert them without booting the HTTP backend, and a test pins the picker to `public/locales/` in both directions. All ten shipped locales are SahajCloud-supported (hu + nl since #578). Refs #95 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Fathom loaded our tracker into the host's page and ipwho.is received the visitor's IP with no way for the site operator — the controller, under GDPR — to decline either. Two attributes now do: `analytics="false"` and `geolocation="false"`, both defaulting on, so an existing embed is unchanged. The flags are a boot singleton read where they're needed (mirroring config/api/auth.ts and config/preview.ts) rather than a context threaded through App, so the analytics block and useIpLocation are the only call sites touched. The IP lookup stays passive by default: it is purpose-limited to the nearby suggestion and localized online-event times, already skipped when neither can show, and gating it behind an interaction would remove the suggestion rather than protect anyone. Refs #95 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
An integrator's privacy notice has to describe what the widget makes their visitors' browsers do, and nothing said what that was. Adds the two storage keys, the two third-party hosts with the conditions and the attribute that stops each, and the CSP lines they need — appended to the existing embedding section, which issue #93 rewrites wholesale later. Writing it surfaced a defect: Fathom was loaded with auto-tracking on, so its script recorded the HOST page's real URL and query string on load — a page that may carry a reset token — on top of the route the effect below reports. Loaded with `auto: false` now, plus `honorDNT`. Refs #95 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…locale gaps
Three findings from the simplify pass and a browser check of main, all the same
drift: the picker's list was never wired to i18next.
- `supportedLngs` was unset, so i18next resolved the browser's full tag and the
backend fetched it: `/locales/en-US/*` 404s on every page load of the deployed
widget, and `/locales/pt/*` for the pt-BR bundle this branch just exposed. Set
from the same constant. NOT `load: 'languageOnly'`, which would strip pt-BR to
a `pt` we don't ship — the new round-trip spec asserts that against i18next
rather than trusting the option's name.
- `theme.{light,dark,auto}` were en-only in all nine other locales, sitting in
the same menu as the picker being widened, and `hu` had no `widget.label` at
all — the accessible name of the widget root's region landmark (#92), which
WebKit drops entirely when it resolves empty.
- The common namespace is now at full parity and a per-locale test keeps it
there; the events namespace carries seven untranslated keys as a named,
ratcheted list rather than silent fallback.
Also folds `map`'s hand-rolled "false"/"0" reading into the shared
`attributeEnabled`, so all three boolean attributes share one spelling.
Refs #95
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Three corrections the reviews raised, plus the parity test they broke. `?locale=` is read off the HOST page's URL, so anyone who can link to someone's embed controls it. `cimode` is i18next's translator-debug pseudo-language — appended to supportedLngs internally, skips resource loading, and makes every t() return its raw key — so a link ending `?locale=cimode` renders a customer's embed as a list of dotted key names. convertDetectedLanguage now refuses it and `dev`. The detector merges its defaults into whatever options object it is handed, which was mutating the module's exported config in place; it is now spread per init. The events-parity assertion becomes a superset check: translations land one language at a time, and an equality check would turn CI red the moment German filled in one of the seven known gaps — punishing the fix. Shrinking the list stays the ratchet's job. Also corrects the storage rationale: the reason to drop the host-origin write is that it was never declared to integrators, not a crash risk — the library does guard the access. Closes #95 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
4 of 5 tasks
Ardnived
added a commit
that referenced
this pull request
Aug 7, 2026
…#122) Cloudflare posts neither commit statuses nor GitHub deployments on this repo, so smoke preview-discovery rested entirely on the Cloudflare bot's PR comment — which is best-effort and simply never appeared on #120, whose deploy was healthy. Since #99 made a missing preview hard-fail a same-repo PR, that flake presented as a red check blocking a good merge. Now reads the check run's output summary, which exists exactly when the deploy does, restricted to Cloudflare's app. Unblocks #120.
One conflict, in README.md's CSP block, and it was load-bearing: this branch added `https://cdn.usefathom.com` to script-src plus a warning that CSP ignores every repeat of a directive name after the first, while #121 added the widget's own origin as a SECOND `script-src` line — the exact mistake the warning describes. Merged onto one line carrying all three sources, so a host pasting the block actually gets Turnstile and Fathom rather than silently losing them, and kept both explanations. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas with
|
| Latest commit: |
5be5439
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://faa7fcb3.sahajatlas.pages.dev |
| Branch Preview URL: | https://fix-i18n-hygiene.sahajatlas.pages.dev |
Deploying sahajatlas-design with
|
| Latest commit: |
5be5439
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fb0269a0.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://fix-i18n-hygiene.sahajatlas-design.pages.dev |
15 tasks
sydevs-bot
pushed a commit
that referenced
this pull request
Oct 3, 2026
The 27-line header repeated the section its own second line points the reader at: the #148 `max-age` measurement, the `deployment_status` deviation, and the filters-in-`if` reason each appeared in both. Two copies of one argument drift apart, and the pointer is what makes the duplicate pointless rather than merely long. What stays is what a reader of this file alone cannot get from `docs/testing.md`: the absent `concurrency` group, and — moved down to the `if:` it explains — why two conditions gate the branch rather than one. Every `#NNN` breadcrumb cut from here is live at the file it now points at: PR #120 in `docs/testing.md` and in `get-cloudflare-preview-url.mjs`'s header, #148 and #244 still named above. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0185rnixqGMn3BApUyF34Ka2
This was referenced Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four production-hygiene defects in the i18n/telemetry layer (issue #95), plus three more found while fixing them. All are host-visible: this bundle runs inside somebody else's page.
debug: trueshipped to production — verified live in the deployed bundle. Nowimport.meta.env.DEV; confirmed asdebug:!1in both entry graphs of a production build.supportedLanguagesis now all ten (cs de en es fr hu nl pt-BR ru uk), moved to the side-effect-freeconfig/i18n-options.tsso the node lane can assert it without booting the HTTP backend, and pinned topublic/locales/in both directions by a test. All ten are SahajCloud-supported — translations: add Hungarian (hu) and Dutch (nl) locales SahajCloud#578 (hu + nl) closed on 2026-07-17 and itssrc/lib/locales/index.tscarries 19 locales, so nothing had to be held back.i18nextLngonto the host's origin. Now explicit:order: ['querystring','navigator'],caches: [].analytics="false"andgeolocation="false"on<sahaj-atlas>, defaulting on, so existing embeds are unchanged.Found while fixing (not in the ticket)
Fathom was writing pageviews into a host's own tracker.
fathom-client'sloadreturns early ifwindow.fathomalready exists, but the tracking effect fired regardless — so on a host page running its own Fathom, our routes landed in their site, under our client'sprimaryDomain. The load effect now records ownership and the tracking effect checks it. Separately,Fathom.load()with no options leaves auto-tracking on, so Fathom recorded the host page's real URL and query string (which may carry a reset token or OAuth param) on every load. Now{ auto: false, honorDNT: true }.?locale=cimodedefaced the embed.?localeis read off the host's URL, so anyone who can link to their page controls it — andcimodeis i18next's translator-debug pseudo-language: it bypassessupportedLngs, skips resource loading, and makes everyt()return its raw key. A link ending?locale=cimoderendered the whole widget as dotted key names.convertDetectedLanguagenow refusescimode/dev.supportedLngswas the missing half of the locale fix. Widening the picker alone does not stop i18next resolving the browser's full tag: a US visitor fetched/locales/en-US/{common,events}.json— two 404s and two console warnings on every page load of the deployed widget. Wiring the same constant in assupportedLngsfixes it.Locale gaps that the widened picker would have exposed to eight new audiences.
theme.{light,dark,auto}were en-only in all nine non-English locales — sitting in the very menu being widened — andhuwas missingwidget.labelentirely, the accessible name of the widget root'srole="region"landmark (#92); WebKit drops the role when that name resolves empty. All filled viapnpm i18n:add. Thecommonnamespace is now at full parity, enforced per locale;eventscarries seven untranslated keys as a named, ratcheting list (a superset check, so a translator filling one in for German alone cannot turn CI red).Privacy decisions
ipwho.is: kept passive, documented, and made switchable — not gated behind an interaction. The lookup is already purpose-limited (it fires only when the nearby suggestion could show, or on an online event that needs the viewer's local time) and already skipped when dismissed or when a search is active. Gating it behind an explicit interaction would not protect anyone: a suggestion you must ask for is not a suggestion, and a viewer cannot ask for their own timezone label. Under GDPR the host is the controller, so the right primitive is a switch they own plus a disclosure they can copy into their notice —
geolocation="false", and it is never called.README gained a privacy/storage/CSP section, additive to the existing embedding docs (#93 owns the integrator guide wholesale). Reviewing it caught that my first draft claimed to be complete while omitting Mapbox: it writes
mapbox.eventData:<token>andmapbox.eventData.uuid:<token>— a persistent anonymous id — to the host's localStorage and POSTs map-load telemetry toevents.mapbox.com. Now disclosed, with the honest note that the widget's ownthemekey is unnamespaced and will collide with a host's. The CSP block also had duplicate directive names, which CSP silently drops after the first occurrence — a host pasting it would have blocked Fathom while believing they had allowed it. One line per directive now.Verification
lint,typecheck,test:run(63 files / 697 tests),build+assert-css-scoped,size(both graphs under budget),ladle:build— all green.debug:!1;order:['querystring','navigator'],lookupQuerystring:'locale',caches:[]; the ten-locale array;i18nextLngappears only inside the detector library's own dead default.supportedLngsround trip, and confirmingresolvedLanguageis unchanged at the SahajCloud boundary for locales we don't ship — soactiveLocale()still sends what it always did).MAP_WORLDVIEWSchecked per.claude/rules/mapbox.md: all eight new languages correctly fall todefault; no entry needed./locales/en-US/*404s); confirmanalytics="false"andgeolocation="false"suppress their requests in the network panel.Review passes
/simplify(4 angles),/code-reviewand/security-reviewall completed and their findings were triaged and fixed — the Mapbox omission, the duplicate CSP directives, the events-parity ratchet, the Ladle picker (all ten bundles now load), the detector-options mutation, theattributeEnabledclaim (now genuinely shared withmapin both entries), and a comment that repeated the ticket's incorrect premise that the detector's storage write was unguarded (the library does guard it — the reason to drop the write is that it is undeclared, not that it throws). Not fixed, deliberately: renaming the unnamespacedthemekey (outside this ticket's files, and it would cost every viewer their stored preference once) and theapikey/api-keycontradiction at README:9 (a known blocker owned by #93).Sessions were repeatedly killed by platform outages mid-run; the coordinator committed and pushed the final batch after verifying the gates.
Closes #95
🤖 Generated with Claude Code