feat(legal): allow partners to customise Terms of Use and Privacy Policy#232
Open
wilfredeveloper wants to merge 2 commits into
Open
feat(legal): allow partners to customise Terms of Use and Privacy Policy#232wilfredeveloper wants to merge 2 commits into
wilfredeveloper wants to merge 2 commits into
Conversation
Replaces the bundled-at-build-time legal markdown imports with a runtime fetch driven by a new FRONTEND_LEGAL_DOCUMENTS env var. Partners can either replace the default markdown files in public/legal/ or point each variant at an absolute URL, matching the existing logo-asset customisation model.
irumvanselme
reviewed
Jun 8, 2026
|
|
||
| export const getLegalDocument = async (variant: LegalDocumentVariant): Promise<LegalDocument> => { | ||
| const url = getLegalDocumentsConfig()[variant]; | ||
| if (!url) { |
There was a problem hiding this comment.
If thre is no URL, I think it might be a good idea to return the default values instead of throwing an error.
for backward config compatibility.
"documents": {
"termsOfUse": "/legal/terms-of-use.md",
"privacyPolicy": "/legal/privacy-policy.md"
}
What do you think?
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.
JIRA
Summary
!!raw-loaderimports of the Terms of Use and Privacy Policy markdown with a runtime fetch driven by a new partner-customisable env varFRONTEND_LEGAL_DOCUMENTS(mirrors the existing logo / asset customisation model).frontend-new/public/legal/{terms-of-use,privacy-policy}.mdin their fork (Path A) or point each variant at an absolute URL (Path B). Schema is forward-compatible toRecord<Locale, string>for future per-locale documents.LegalDocumentVariantunion from"privacy" | "terms"to"privacyPolicy" | "termsOfUse"for consistency with the JSON config. Drops the unused{{appName}}placeholder substitution (zero usages in the bundled docs).What changed
legal.documentsnamespace inconfig/default.json; wired throughconfig/inject-config.py(env map + JSON-stringify field).iac/templates/env.template), reader (iac/frontend/prepare_frontend.py), andno_cache_pathsentries (iac/frontend/deploy_frontend.py).legalDocumentsConfig.tsparser (modelled onbranding/seoConfig.ts).legalDocumentLoader.tsto fetch from the configured URL with a per-variant default title fallback.LegalDocumentPagenow async-loads with<Backdrop>while loading and<ErrorPage showRefreshButton />on failure (mirrorsKnowledgeHubDocument).legal.documentUnavailabletranslation key added to all 7 locales.src/legal/documents/topublic/legal/.config/CUSTOMIZATION.md(Path A/B, frontmatter contract, non-goal callout for re-consent, forward-compat callout for per-locale).legalDocumentsConfig.test.ts,legalDocumentLoader.test.ts, andLegalDocumentPage.test.tsxcovering success, loading, fetch failure, missing config, malformed JSON, and frontmatter fallback.Non-goals
accepted_tc: datetimesemantics preserved. Updates affect only future consents.Test plan
yarn compilecleanyarn lintcleanyarn format:checkcleanyarn test --testPathPattern='src/legal/'— 13/13 pass (full suite not run locally due to OOM risk; CI will cover)python3 inject-config.py --config default.jsonruns clean and writes the expectedFRONTEND_LEGAL_DOCUMENTS: btoa(JSON.stringify({...}))intoenv.js/terms-of-useand/privacy-policy, confirm rendering with defaultspublic/legal/terms-of-use.md, hard-refresh, confirm the change is visible<ErrorPage>shows with refresh button