docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

break(gtag): forbid deprecated anonymizeIP option (AI-assisted)

Open Injora opened this issue 8 months ago • 2 comments

Google Analytics 4 does not log or store IP addresses, making the anonymize_ip configuration unnecessary. This option has been a no-op since GA4's launch and was marked for deprecation since June 2023.

  • Remove anonymizeIP from PluginOptions and Options types
  • Remove anonymize_ip from the gtag config snippet
  • Mark anonymizeIP as forbidden in the Joi schema with a clear error message for existing users
  • Update tests to verify the forbidden validation

See: https://support.google.com/analytics/answer/2763052

Pre-flight checklist

  • [x] I have read the Contributing Guidelines on pull requests.
  • [x] If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • [ ] If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

The anonymizeIP option in @docusaurus/plugin-google-gtag has been a no-op since GA4 replaced Universal Analytics. GA4 does not log or store IP addresses at all, making IP anonymization unnecessary.

The codebase already had a TODO acknowledging this should be removed:

https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-plugin-google-gtag/src/options.ts#L16-L20

This PR completes that TODO by removing the dead option and providing a clear error message for existing users who still have it in their config, following the same Joi.forbidden() pattern used by homePageId in plugin-content-docs.

Test Plan

yarn test packages/docusaurus-plugin-google-gtag/src/__tests__/options.test.ts

All 14 tests pass. Full build passes with yarn build:packages.

Injora avatar Apr 02 '26 16:04 Injora

[V2]

Built without sensitive environment variables

Name Link
Latest commit 027a2f7d77a815ba193591cbb5bf706972162d61
Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/69ceb753c4aab200086885c1
Deploy Preview https://deploy-preview-11878--docusaurus-2.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify avatar Apr 02 '26 16:04 netlify

Thanks! That makes sense regarding it being a breaking change. I’ll fix the failing checks and keep this ready for v4 :)

Injora avatar Apr 02 '26 18:04 Injora