feat: add OneTrust cookie consent, GTM, and privacy choices footer link#121
Open
thisistonydang wants to merge 2 commits into
Open
feat: add OneTrust cookie consent, GTM, and privacy choices footer link#121thisistonydang wants to merge 2 commits into
thisistonydang wants to merge 2 commits into
Conversation
thisistonydang
force-pushed
the
thisistonydang/cookies
branch
from
July 14, 2026 21:23
2d83521 to
84fbde2
Compare
thisistonydang
marked this pull request as draft
July 14, 2026 22:44
thisistonydang
force-pushed
the
thisistonydang/cookies
branch
from
July 18, 2026 23:53
84fbde2 to
3f1adbb
Compare
📝 Changed routes:
Commit c01c4fd (https://comdatabricks-kavl3d3ki-databricks-web.vercel.app). |
Native Next.js implementation: ConsentTags renders the OneTrust tags and the GTM container as plain blocking tags at the top of <body> — the DOM order is the legal contract (AutoBlocker before GTM so non-consented cookies are gated) — gated by resolveOneTrustEnv: production variant on production deploys, test variant on previews, nothing locally unless ONETRUST_ENV is set. The CCPA "Your Privacy Choices" link opens the OneTrust preference center from both the main and perspectives footers. Co-authored-by: Isaac
thisistonydang
force-pushed
the
thisistonydang/cookies
branch
from
July 19, 2026 00:30
3f1adbb to
8d5d6a4
Compare
thisistonydang
marked this pull request as ready for review
July 20, 2026 00:51
The databricks onetrust.js defines OptanonWrapper and relies on the next page load to apply consent changes; the SPA never has one. Chain the wrapper (never replace it, its cookie deletion must keep running), register OneTrust.OnConsentChanged once the SDK is up, and reload only when OnetrustActiveGroups actually differs from the boot snapshot. Co-authored-by: Isaac
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
Adds OneTrust cookie consent, the Databricks Google Tag Manager container, and the CCPA "Your Privacy Choices" footer link, implemented natively for the Next.js App Router. This replaces the earlier Docusaurus-era implementation on this branch — the branch was rebased onto main and rewritten from scratch now that the Next.js migration has shipped.
How it works
src/lib/onetrust.tsresolves which consent variant applies: production deploys get the production OneTrust install (only works on *.databricks.com), previews get the test install (works on any domain), and local dev gets none unlessONETRUST_ENVis set explicitly (ONETRUST_ENV=test pnpm devshows the banner locally).src/components/consent-tags.tsxrenders the tags as plain blocking elements at the top of<body>, not vianext/script— the DOM order is the legal contract: the OneTrust AutoBlocker must execute before the GTM snippet so it can gate non-consented cookies, and the GTM<noscript>iframe must sit immediately after the opening<body>tag. React hoists only the banner stylesheet<link>into<head>(where the www.databricks.com install puts it too); the scripts keep their<body>source order. GTM never loads without OneTrust.onetrust.js) chains that script'sOptanonWrapper— never replaces it, since its opt-out cookie deletion must keep running — snapshotsOnetrustActiveGroupsat SDK init, registers the documentedOneTrust.OnConsentChangedcallback exactly once, and reloads the page only when the active groups actually differ from the boot snapshot. The reload re-runs the whole tag stack against the newOptanonConsentcookie, reproducing multi-page semantics in both directions (late grant: tags start collecting; revoke: trackers unload, and the post-reload init re-runs cookie deletion). The snapshot guard makes reload loops structurally impossible and ignores SDK-internal re-fires (geo resolution, implied-consent recording, preference-center saves with no change).src/components/your-privacy-choices-link.tsxrenders the "Your Privacy Choices" link with the GPC icon in both the main and perspectives footers; it opens the OneTrust preference center (no-op where consent scripts are off).Validation
tests/onetrust.test.ts) and for the rendered consent tags (tests/consent-tags.test.ts): empty render without a consent variant, the load-bearing tag order (AutoBlocker → SDK stub → onetrust.js → consent-change handler → GTM loader), and the OptanonWrapper chaining/reload markers. Footer e2e expectations updated; the broken-link crawl allowlists the JS-handled#yourprivacychoicespseudo-anchor.,C0001,), no reload loop; then Allow All via the footer link's preference center → page reloads itself, full groups restored, GTM live post-reload./_vercel/insights/script.jsis injected and fetched alongside the loaded OneTrust banner and GTM. (Analytics only renders whenVERCEL=1, so this pairing can't be exercised locally.)pnpm typecheck,pnpm exec vitest run,pnpm exec playwright test(182/183 — the one failure is a pre-existing image-load timeout on/templates/lakebase-off-platformthat reproduces identically with this branch's changes stashed),pnpm build.Verification steps before merge
This pull request and its description were written by Isaac.