Skip to content

Keep pad addresses and titles out of Google Analytics on in-app navigation #741

Open

Description

@HMarzban

Summary

A tab that opens on Home sends Google Analytics (GA) the real pad address and title. It happens when the reader moves to a pad inside the app. GA's own history listener sends that page_view. Our redaction runs only in the first gtag('config') call, and only when the first page is a pad.

This issue does three things:

  1. It stops most of the leak today in GA Admin, with no deploy.
  2. It records the GA ruling of 2026-11-11 (ruling): GA is off until [Idea]: Launch-legal and listing compliance backlog #241 ships the cookie notice and opt-out.
  3. It ships the GA-off rebuild (Step 3B).

Benchmark

Field Value
Metric (1) page_view hits whose dl holds a pad path, per Home-to-/demo move, count. (2) gtag/js and collect requests on Home and /demo after Step 3B, count.
Before (1) 1, live test on 2026-11-08, n = 1. The maintainer takes the 5-trial Step 1 before trace for (1) only, before the GA Admin change. (2) Both load today: GA is on (live site, 2026-11-11).
After Not measured yet.
Condition A Chrome Guest window with no extensions, DevTools "Preserve log" and "Disable cache", against https://docs.plus at the deployed SHA.
How to run Step 1 items 1-3, 5 trials per side, page_view count. DevTools Network, filters gtag/js and collect.
Pass rule (1) 0 in 5 of 5 trials. (2) 0 gtag/js and 0 collect requests on Home and /demo.
Guard Step 1b runs after the Step 1 before trace (approved 2026-11-11).
Owner Maintainer: Steps 1, 1b and 3B, the traces and GA Admin. Agent in the repo: the privacy.tsx edit.
Claim "docs.plus sends Google no pad address or title: <x> leaking page views per Home-to-pad move → 0." <x> is the Step 1 5-trial before.

Rows

Metric Before After Method
page_view hits whose dl holds a pad path, per Home-to-/demo move 1 (live test, 2026-11-08) Not measured yet Step 1 trace, 5 trials
Stored pad paths in GA Full history Not measured yet: deletion request filed, retention 2 months GA Admin, request date recorded (Step 1b)
gtag/js and collect requests on Home and /demo Both load (GA on) Not measured yet: 0 and 0 after Step 3B DevTools Network

Evidence

All code reads are at 0b302b222, the commit production runs.

  • Read from code, 2026-11-11. apps/webapp/src/components/GoogleAnalytics.tsx:14 defines the redacted page fields. :34 passes them to gtag('config') only when documentShell is true at first render. The file has no route-change handler. Its last change is 355d640e6 (2026-08-25).
  • Read from code, 2026-11-11. apps/webapp/src/pages/_app.tsx:195-201 holds the only router.events handler, and it only preloads styles. No code sends a manual page_view.
  • Read from code, 2026-11-11. apps/webapp/src/utils/analytics.ts:8-13: trackEvent sends no page fields. So GA reads page_location and page_title from the live URL and document.title. Callers: useSendMessage.ts:119, useInitializeNewDocument.ts:55, pwaInstallStore.ts:73, _app.tsx:143-151 (web vitals) and trackSignUpOnce in analytics.ts.
  • Live browser test, 2026-11-08. Load https://docs.plus/, then run window.next.router.push('/house-london') in the console. GA received one page_view with dl=https://docs.plus/house-london. On a direct pad load, a history.pushState to ?h=… sent no hit.
  • GA reports, 28 days to 2026-11-08. 3,207 page_view, 2,452 scroll, 1,088 user_engagement, 198 form_start and 29 click. GA sends link_url with click, and form_destination with form events (GA help, answer 9216061).
  • GA Admin, read 2026-11-08. The property change history showed no change in the 30 days before. No change is recorded since.
  • Live site, 2026-11-11. The production _app chunk loads GA with the same config shape. So GA is on.
  • Rule on [Idea]: Launch-legal and listing compliance backlog #241. Phase 4 says: do not switch on GA in a production build before the cookie notice and the opt-out control exist. GA is on, and neither exists.

Risk

  • Pad titles and ?h= heading trails are text that users wrote. Every Home-to-pad move sends them to Google, under the GA property's retention.
  • click and form events can also carry link targets and form URLs from inside pads.
  • privacy.tsx:46-49 tells readers that GA counts page views only. The data GA receives is wider than that.

Steps

Step 1 — GA Admin: turn off the history listener and the content events

Owner: maintainer, GA Admin console (Editor role). Deploy: none. Run it before the Step 3B deploy.

  1. Open a fresh Chrome Guest window with no extensions, so no ad blocker hides GA hits. Open DevTools → Network. Tick "Preserve log" and "Disable cache". Type collect?v=2 in the filter box.
  2. Record the "before" trace, 5 times. Open https://docs.plus/. In the Console, run window.next.router.push('/demo'). Wait 10 s. Switch to another tab and back, which flushes queued hits. Close the window between trials.
  3. Open each collect request → Payload. GA batches events into one POST; each payload line is one event with its own en=. Record counts only, per trial. Count the en=page_view hits after the Home one, and the hits whose dl holds /demo. GA batches hits, so one trial can miss or merge them; 5 trials show the spread.
  4. In GA: Admin → Property → Data collection and modification → Data streams → the web stream.
  5. Under Events, click the gear on "Enhanced measurement". Take a screenshot of the panel and of Page views → "Show advanced settings". Crop out the account header. Keep it for rollback.
  6. In Page views → "Show advanced settings", untick "Page changes based on browser history events". Leave "Page views" on.
  7. Turn off Scrolls, Outbound clicks, Site search, Form interactions, Video engagement and File downloads. Click Save.
  8. On the stream page, under Events, open "Redact data". Keep email redaction on. Turn on "Redact URL query parameters". Add each key and press Enter after each: h, id, msg_id, chatroom, open_heading_chat, notification_id, act, c_id, m_id, mode, code, error, error_code, error_description. Save.
    • The pad keys come from packages/pad-url/src/padUrlCore.ts:63-86 and :170-186. notification_id comes from apps/webapp/src/hooks/useNotificationClickBridge.ts:13. The sign-in return can add code and error_code on Home.
  9. Wait 10 minutes. Run the Step 1 checks under Verify.
  10. Comment on this issue with the date and the change type from Admin → Property change history. Do not paste the account name.

This is a partial stop. In a Home-start tab, user_engagement, send_message, create_document and sign_up still carry the live URL and title. GA cannot turn off user_engagement. Step 3B closes the rest.

Step 1b — GA Admin: delete the stored pad paths

Owner: maintainer, GA Admin console. Deploy: none.

Approved 2026-11-11 (ruling). Run it after the Step 1 before trace. A data deletion request cannot be undone, and that is intended.

  1. Admin → Property → Data collection and modification → Data deletion requests. Request deletion of page_location, page_title and page_referrer for the full date range.
  2. Admin → Property → Data collection and modification → Data retention. Set event data retention to 2 months.
  3. Comment here with the request date and the retention value. Do not paste the account name.

The steps above stop new leaks. This step removes the pad paths and titles that GA already holds.

Step 3A — moved to #241

Step 3A (the code fix and its Cypress check) moved to #241. It is a precondition for turning GA back on. It does not run in v2.3.6.

Step 3B — Turn GA off until the #241 cookie notice exists (ruled B)

Owner: maintainer, SSH as the deploy user (the env file owner; no sudo needed). Deploy: one forced production deploy, outside planned events.

The host env file is the ENV_SOURCE path at .github/workflows/prod.docs.plus.yml:82. Edit that file, not .env.production: scripts/ci/prepare-deploy-env.sh:10 rebuilds .env.production on every run.

  1. Back up the file owner-only: F=/opt/projects/prod.docs.plus/.env; install -m 600 "$F" "$F.bak-ga-$(date +%F)". Delete the backup once every Step 3B check passes (Make the production env files readable by their owner only #742).
  2. Empty the ID: sed -i 's/^NEXT_PUBLIC_GA_ID=.*/NEXT_PUBLIC_GA_ID=/' "$F".
  3. Check without printing the ID: grep -c '^NEXT_PUBLIC_GA_ID=$' "$F" prints 1.
  4. From a repo checkout: gh workflow run prod.docs.plus.yml --repo docs-plus/docs.plus --ref main -f force_deploy=true. NEXT_PUBLIC_* values are build args (docker-compose.prod.yml:512, apps/webapp/docker/Dockerfile.bun:143,166), so the webapp image rebuilds.
  5. GoogleAnalytics.tsx:20 then renders nothing, and trackEvent finds no gtag.
  6. Owner: agent in the repo. Make the privacy page match: remove the GA bullet at apps/webapp/src/pages/privacy.tsx:46-49, through the tech-writer skill. Land this privacy.tsx edit first. Collect real-user Web Vitals through a first-party beacon to the REST API #731 rebases on it.
  7. Step 3A now lives in the [Idea]: Launch-legal and listing compliance backlog #241 work (maintainer comment on [Idea]: Launch-legal and listing compliance backlog #241). Its code fix and its Cypress check are preconditions for turning GA back on.

Verify

Run each browser check in the Step 1 Guest window set-up.

Step 1 (GA Admin).

Check Before After
Open https://docs.plus/, run window.next.router.push('/demo'), wait 10 s, flush One en=page_view with dl=https://docs.plus/demo No en=page_view, en=scroll, en=click or en=form_start after the Home view
Open https://docs.plus/demo directly; click a TOC heading; open and close a heading chat One page_view with dl=https://docs.plus/(document) The same: exactly one
Open https://docs.plus/?error_code=test dl holds error_code=test dl shows (redacted) or no query

Expected residue after Step 1: in the Home-start tab, en=user_engagement still carries dl=https://docs.plus/demo.

Step 3A (code fix). Its checks moved to #241 with Step 3A.

Step 3B (GA off), live after the deploy.

  • Load https://docs.plus/ and https://docs.plus/demo. Pass: the filter gtag/js shows no request, and the filter collect shows none.
  • Do not use curl … | grep googletagmanager. The Pages Router injects an afterInteractive script on the client only, so the server HTML never holds it, even with GA on.

Rollback

Acceptance criteria

  • Step 1 is done, and its date and change type are in a comment here.
  • Every Step 1 check passes, with the expected residue only.
  • Step 1b ran after the Step 1 before trace, and its request date is in a comment here.
  • The 2026-11-11 ruling is linked on [Idea]: Launch-legal and listing compliance backlog #241.
  • No gtag/js and no collect request on Home or on a pad, and the privacy page no longer names GA.
  • The .env backup copy is deleted.
  • The Benchmark After values are posted here.

Decisions

  1. Keep GA on with the code fix (A), or turn GA off until the [Idea]: Launch-legal and listing compliance backlog #241 cookie notice and opt-out exist (B)? Ruled 2026-11-11: B (ruling). GA stays off until [Idea]: Launch-legal and listing compliance backlog #241 ships the cookie notice and opt-out. The reasons recorded before the ruling:
    • B follows the rule already recorded on [Idea]: Launch-legal and listing compliance backlog #241, and it removes the leak at its source. It costs one env line and one rebuild.
    • Collect real-user Web Vitals through a first-party beacon to the REST API #731 already plans web vitals through a first-party beacon, so B loses no performance data.
    • One Lighthouse run on 2026-11-11 showed 141 ms of gtag.js script bootup on Home, with no device or throttle recorded. B removes that cost. It is not re-taken (review, 2026-11-16).
    • B loses GA visitor counts. Supabase still counts sign-ups and sessions.
    • Clients on an old cached bundle keep loading gtag.js until their service worker updates (apps/webapp/next.config.js:42 sets skipWaiting: false). Step 1 covers them meanwhile.

The test GA ID question (old Decision 2) moved to #241 with Step 3A.

Related

Activity

  1. added this to the v2.3.6 milestone on Nov 11, 2026
  2. added
    Security
    bug
    on Nov 11, 2026
  3. HMarzban commented on Nov 11, 2026

    @HMarzban
    CollaboratorAuthor

    Maintainer ruling, 2026-11-11

    • Decision 1: B. Turn Google Analytics off: empty NEXT_PUBLIC_GA_ID and rebuild. It stays off until [Idea]: Launch-legal and listing compliance backlog #241 ships the cookie notice and opt-out. This stops the pad-title leak at its source. Collect real-user Web Vitals through a first-party beacon to the REST API #731 replaces the web-vitals data.
    • Step 1b: approved. After the Step 1 before trace, the maintainer files the GA deletion request. It covers page_location, page_title and page_referrer over the full range. Then the maintainer sets data retention to 2 months. This is irreversible, and it is intended: no benchmark needs the stored paths, because every before comes from live traces.
  4. HMarzban commented on Nov 14, 2026

    @HMarzban
    CollaboratorAuthor

    Moved to v2.3.7 at the v2.3.6 release audit. The GA ruling is posted. The 5-trial before trace, the GA Admin steps and the GA-off deploy have no posted result.

  5. modified the milestones: v2.3.6, v2.3.7 on Nov 14, 2026
  6. HMarzban commented on Nov 16, 2026

    @HMarzban
    CollaboratorAuthor

    Review, 2026-11-16 (maintainer approved).

    • Kept metric (1) and its 5-trial Step 1 before trace. Added "0 gtag/js and 0 collect requests on Home and /demo" as the Step 3B check.
    • Removed metrics (2)-(4), the Lighthouse bootup and the TBT/LCP guard. Step 3B removes the script at the source, so these add no decision value.
    • Removed the Cmd-click and link-editor Verify rows. They only test GA Admin toggles that Step 3B makes moot.
    • Removed the returning-visitor reopen-cycle row. It had no pass rule.
    • Removed Step 3B step 8 (CSP hosts). That is [Idea]: Launch-legal and listing compliance backlog #241 work. Removed the house-rule Acceptance box and the "KB less" claim clause.
    • Replaced the past date "Run it by 2026-11-14" with "Run it before the Step 3B deploy".
  7. HMarzban commented on Nov 24, 2026

    @HMarzban
    CollaboratorAuthor

    Measured, 2026-11-24: Step 1 (n = 5 before & after), Step 1b, and Step 3B host prep

    Step 1 — Live Chromium traces (Playwright Chromium 159.0.8154.6, fresh context per trial)

    • Script: Notes/release-2.3.7/bench/741/ga-trace.mjs (Home https://docs.plus/ → window.next.router.push('/demo') → wait 10 s → visibility flush, n = 5 trials per side).
    • Before (2026-11-24T17:00Z):
      • en=page_view with dl=https://docs.plus/demo after push: 5 of 5 trials (1 per trial, median 1, range 1–1).
      • Direct https://docs.plus/demo: 1 page_view, redacted (dl=https://docs.plus/(document), dt=(document)).
    • GA Admin changes saved (2026-11-24):
      • Enhanced measurement: unticked "Page changes based on browser history events" (__ccd_em_page_view removed from live gtag/js); live __ccd_em_* tags at check: __ccd_em_download,__ccd_em_form,__ccd_em_outbound_click,__ccd_em_scroll,__ccd_em_site_search,__ccd_em_video.
      • Redact data: Email redaction kept ON; URL query parameter redaction turned ON with all 14 keys (h, id, msg_id, chatroom, open_heading_chat, notification_id, act, c_id, m_id, mode, code, error, error_code, error_description) — verified live in __ccd_auto_redact.
    • After Step 1 (2026-11-24T17:31Z):
      • en=page_view with dl=https://docs.plus/demo after push: 0 of 5 trials (0 per trial, afterPushEvents: [] in all 5 trials).
      • Direct https://docs.plus/demo: 1 page_view, redacted (dl=https://docs.plus/(document), dt=(document)).
      • Query-param redaction probe (?h=…): dl=https://docs.plus/?h=(redacted).

    Step 1b — GA Admin deletion & retention (2026-11-24)

    • Data deletion request: scheduled 2026-11-24 covering page_location, page_title, and page_referrer across the full date range (Jan 3, 2005 – Nov 23, 2026, all values; status Preview active — In grace period).
    • Event data retention: set to 2 months.

    Step 3B — Host prep completed (2026-11-24)

    • Backed up host .env owner-only (install -m 600, .env.bak-ga-2026-11-24), emptied NEXT_PUBLIC_GA_ID= (grep -c = 1), restarted prod.docs.plus-runner, and verified NEXT_PUBLIC_GA_ID is absent from /proc/<Runner.Listener>/environ.
    • apps/webapp/src/pages/privacy.tsx updated locally (removed GA bullet and "and Analytics"; uncommitted, pending maintainer push).
    • Remaining to close Keep pad addresses and titles out of Google Analytics on in-app navigation #741: run the 2026-11-25 05:00Z force_deploy, verify 0 gtag/js and 0 collect requests on Home and /demo, delete .env.bak-ga-2026-11-24, land privacy.tsx, and link the ruling on [Idea]: Launch-legal and listing compliance backlog #241.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Securitybug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions