Repository navigation
Description
Summary
Four production-hygiene defects in the i18n/telemetry layer, all host-visible and all from the release-readiness review (.claude/reports/RELEASE_READINESS.md §1.6, §3.5, Appendices A/B): i18next debug logging ships to every host page's console (verified live in the deployed production bundle), eight of the ten shipped locales are unreachable from the language picker, the language detector's library defaults silently read cookies and write localStorage on the host's origin (undeclared, and the one storage path not defensively wrapped), and two third-party data flows — Fathom analytics and ipwho.is IP geolocation — run consent-ungated and undocumented to integrators. The last three are a GDPR exposure surface for any EU host.
Proposed changes
1. Gate i18next debug to dev
src/config/i18n.ts:21 passes debug: true unconditionally. Change to debug: import.meta.env.DEV so production hosts get a silent console and dev keeps the missing-key warnings.
2. Expose all shipped locales in the language picker
supportedLanguages = ['en', 'fr'] (src/config/i18n.ts:8) while ten locale bundles ship in public/locales/: cs, de, en, es, fr, hu, nl, pt-BR, ru, uk. SettingsMenu builds the picker from this const (src/components/molecules/SettingsMenu/SettingsMenu.tsx:15,87), so eight locales are unreachable despite being fully bundled.
- Extend
supportedLanguagesto the shipped set. - Cross-check the locale-set-alignment policy first: SahajAtlas languages must be a subset of SahajCloud's (SahajCloud
src/lib/locales/index.tsis the source of truth). The client sends the resolved i18next language to SahajCloud 1:1 (applyRequestContext), so a locale the CMS doesn't support gets untranslated content or errors.hu+nlwere missing on the SahajCloud side → translations: add Hungarian (hu) and Dutch (nl) locales SahajCloud#578. Record in the implementation report any locale that can't be exposed yet and why. - Check
MAP_WORLDVIEWSper.claude/rules/mapbox.mdfor any newly exposed locale needing a worldview entry.
3. Make language detection explicit; stop the undeclared host-origin storage write
src/config/i18n.ts:23-25 configures i18next-browser-languagedetector with only { lookupQuerystring: 'locale' }, so the library's defaults silently apply: the detection order reads cookies and localStorage, and caches: ['localStorage'] writes i18nextLng onto the HOST page's origin. Two defects:
- Undeclared storage on someone else's origin — disclosure-relevant (report §3.5).
- It is the one storage path not try/catch-wrapped: a sandboxed-iframe embed (
sandboxwithoutallow-same-origin) throws onlocalStorageaccess. Compare the deliberate defensive wrapping insrc/hooks/use-theme.ts:124-146.
Fix: set an explicit order (querystring + navigator) and caches: []. If persistence is deliberately kept instead, it must be both declared in the README privacy section and wrapped so a sandboxed embed can't throw.
4. Disclose + gate the third-party data flows
- Fathom (
src/App.tsx:147-159; the full analytics block is ~137-159):Fathom.load(import.meta.env.VITE_FATHOM_ID)injects the tracker script into the host page whenever the env var is set and the client record carries a non-localhost primary domain — no consent gate, no host opt-out, unmentioned in any host-facing doc. Add a host-facing opt-out (e.g. ananalytics="false"attribute on<sahaj-atlas>, or document the build-time gate explicitly) and disclose the tracker + its conditions in the README. - ipwho.is (
src/hooks/use-ip-location.ts:9-32): the visitor's IP goes to a free third-party geolocation service once per session, passively. The existing mitigations are good —referrerPolicy: 'no-referrer', 5sAbortSignal.timeout, never throws, deliberately a barefetchso the SahajCloud API key can't leak — but the call is consent-ungated and undocumented, and an IP is personal data under GDPR (report §3.5). Implementer proposes the resolution in-ticket: either gate the lookup behind an explicit interaction (e.g. fire only once the nearby-search suggestion flow is actually engaged/shown) or keep it passive but document it prominently in the README privacy section. Defend the choice with the GDPR framing in the implementation report.
Acceptance criteria
- The production bundle emits no i18next debug logging; dev behaviour unchanged
- The settings language picker lists every shipped locale that SahajCloud supports; any locale still excluded is named in the implementation report with the reason (subset policy / translations: add Hungarian (hu) and Dutch (nl) locales SahajCloud#578)
- Language detection
orderandcachesare explicit insrc/config/i18n.ts; no undeclared host-origin storage write remains — or the write is declared in the README and wrapped so a sandboxed iframe cannot throw - A host can opt out of Fathom (attribute or documented build-time gate), and Fathom's presence + load conditions are disclosed in the README
- The ipwho.is decision (gate vs. document) is implemented, with the GDPR reasoning recorded in the implementation report
- README gains an additive privacy/storage disclosure section for integrators covering: Fathom (conditions + opt-out), ipwho.is, every storage key the widget touches (theme, geolocation dismissal, language cache if kept), and the corresponding
connect-src/script-srcCSP targets — updated additively alongside the existing CSP section, no rewrites of unrelated content - Unit-lane tests where expressible (e.g.
supportedLanguages⊆ shippedpublic/locales/parity; detector options shape) per.claude/rules/tests.md -
pnpm lint && pnpm typecheck && pnpm test:runpass - Write an implementation report to
.claude/reports/<issue-number>-<short-slug>.md— in the MAIN checkout at /Users/devindra/Documents/Projects/SahajAtlasWeb even when implementing from a worktree (the folder is gitignored) — covering what changed, what was deliberately NOT changed, and which readiness-report findings are resolved
Files affected
src/config/i18n.ts— debug gate,supportedLanguages, explicit detection optionssrc/config/i18n-options.ts— only if shared options move heresrc/hooks/use-ip-location.ts— gating decisionsrc/App.tsx— the Fathom/analytics block ONLY (lines ~137-159); keep the edit surgicalsrc/components/molecules/SettingsMenu/— locale-list consumerREADME.md— additive privacy-disclosure section (+ CSP table rows for any flow kept)
Parallel implementation: this ticket OWNS the files listed above; sibling release-hardening tickets run concurrently — avoid edits outside owned files except strictly additive ones (e.g. appended README sections, new locale keys). In particular, a sibling ticket owns the rest of src/App.tsx — touch only the analytics block.
References
.claude/reports/RELEASE_READINESS.md§1.6 (rec. 6), §3.5, Appendix A (i18nextdebug: trueverified in deployed bundle), Appendix B (Fathom / ipwho.is / i18next-detection rows)- translations: add Hungarian (hu) and Dutch (nl) locales SahajCloud#578 — hu + nl locale support (subset-policy blocker for exposing those two)
- feat(widget): instrument event surfaces + evaluate TelemetryDeck #51 — analytics instrumentation (related: this ticket is disclosure/opt-out only, not new tracking events)
- refactor(i18n): source translations from SahajCloud CMS #28 — CMS-sourced translations (related, not blocking)
Metadata
Metadata
Assignees
Labels
Type
Fields
Hold Until
Activity
fix(i18n): refuse cimode, stop mutating the shared detector config