Repository navigation
🍪 fix: Load Google Tag Manager Only After Analytics Consent - #16999
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 73d3840c02
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
41f82e0 to
af26db5
Compare
Google Tag Manager initialized as soon as the chat footer or the chat route mounted whenever ANALYTICS_GTM_ID was set, for signed-in users and shared-link viewers alike, with no consent check. A single useAnalytics hook now owns initialization and loads the container only after the viewer grants consent, recorded in a persisted Jotai atom. A non-modal banner asks for that consent in the signed-in layout and on shared links, and a Data controls toggle changes it later; withdrawing consent pushes a consent mode update to a loaded container and completes on reload.
af26db5 to
3708416
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37084164fb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
When
ANALYTICS_GTM_IDwas set, Google Tag Manager initialized as soon as the chat footer or chat route mounted, for signed-in users and shared-link viewers alike, with no consent check.A single
useAnalyticshook now owns initialization and loads GTM only after the viewer accepts a non-modal consent banner. The banner is a labelled region with Decline and Allow analytics at equal weight; it does not take focus and appears only when a GTM id is configured and no choice has been made. It mounts in the signed-in layout and on shared links. The choice is stored per browser and can be changed in Settings > Data controls; withdrawing consent pushes a consent-mode update to a loaded container and takes full effect after a reload. Deployments withoutANALYTICS_GTM_IDsee no change.Stacked on #16998.
Type of change
Testing
Tested environments/configuration:
ANALYTICS_GTM_ID=GTM-TEST123, Chromium, light and dark, 1280px and 390px.Automated tests:
client/src/components/System/__tests__/AnalyticsConsent.spec.tsx(8 tests) andclient/src/components/Nav/SettingsTabs/Data/__tests__/AnalyticsConsent.spec.tsx(3 tests); updated registry, sidebar, footer anduseAppStartupspecs. 17 suites, 138 tests passed.npx eslint,npx prettier --checkand sort-imports on changed files: clean.googletagmanager.combefore consent;gtm.js?id=GTM-TEST123loads right after Allow analytics and on reload, with no banner shown again.Screenshots / recordings
New surface, so there is no before.
Risk / compatibility
GTM now loads on every signed-in route once consent is granted, not only the chat route. At phone width the banner covers the composer until the viewer answers. Operators who run a consent platform inside their GTM container will now see LibreChat's banner first.
Checklist