Skip to content

Cookie Consent: Add configurable geo provider#50038

Merged
chihsuan merged 4 commits into
trunkfrom
add/wooa7s-1600-cookie-consent-geo-provider
Jun 30, 2026
Merged

Cookie Consent: Add configurable geo provider#50038
chihsuan merged 4 commits into
trunkfrom
add/wooa7s-1600-cookie-consent-geo-provider

Conversation

@chihsuan

Copy link
Copy Markdown
Member

Fixes WOOA7S-1600

This is a clean re-do of #49998, which inadvertently bundled ~37 unrelated files (babel changelog stubs and premium-analytics widgets) from a stale merge base. This PR contains only the Cookie Consent geo-provider changes.

Proposed changes

  • Abstract geo resolution behind a pluggable provider, with WPCOM as the default provider.
  • Allow custom geo endpoints, cookie names, cookie duration, GDPR countries, CCPA regions, and error behavior through nested geo.* config.
  • Keep geo resolution client-side and only add resolved geo cookies to Boost's ignored cache-cookie list when geo is enabled.
  • Preserve legacy flat geo config aliases while making explicit nested geo.* keys authoritative.
  • Document the custom geo provider contract and disabled-geo behavior.

Note: geo is always enabled; there is no features.geo flag.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No new tracking events or tracked properties. This changes Cookie Consent geo source configuration and region-selection behavior.

Testing instructions

  • Confirm the branch diff is scoped to Cookie Consent only: git diff --name-only origin/trunk...HEAD.
  • Run mise exec node@24.15.0 -- pnpm --filter @automattic/jetpack-cookie-consent test.
  • Run mise exec node@24.15.0 -- pnpm --filter @automattic/jetpack-cookie-consent typecheck.
  • Run mise exec node@24.15.0 -- pnpm --filter @automattic/jetpack-cookie-consent build.
  • Run mise exec node@24.15.0 -- pnpm --filter @automattic/jetpack-cookie-consent exec eslint src/modules/cookie-consent/utils.ts src/modules/cookie-consent/view.ts tests/utils.test.ts.
  • Run composer php:lint -- projects/packages/cookie-consent/src/class-cookie-consent.php.
  • Run composer phpcs:lint -- projects/packages/cookie-consent/src/class-cookie-consent.php.
  • Run composer phpcs:compatibility -- projects/packages/cookie-consent/src/class-cookie-consent.php.
  • Run vendor/bin/phan --allow-polyfill-parser --include-analysis-file-list projects/packages/cookie-consent/src/class-cookie-consent.php --no-progress-bar.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jun 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Cookie Consent package’s geo-resolution configuration to use a pluggable, provider-based schema (defaulting to WPCOM), while preserving legacy config aliases and adding tests/docs around normalization and behavior.

Changes:

  • Introduces a structured geo config contract (provider, endpoint, cookie settings, region lists, error behavior) and helper normalization on both PHP and JS sides.
  • Updates the frontend interactivity store to use the nested geo config and adds clearer behavior for misconfigured endpoints / error handling.
  • Adds PHPUnit + Jest coverage for geo config normalization and documents the custom provider contract.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
projects/packages/cookie-consent/tests/utils.test.ts Adds Jest coverage for getGeoConfig, legacy alias precedence, and list normalization helpers.
projects/packages/cookie-consent/tests/php/Config_Normalization_Test.php Adds PHP tests validating server-side config normalization rules for geo settings.
projects/packages/cookie-consent/src/modules/cookie-consent/view.ts Switches frontend geo resolution to use getGeoConfig and supports configurable error behavior.
projects/packages/cookie-consent/src/modules/cookie-consent/utils.ts Adds GeoConfig + getGeoConfig and routes GDPR/CCPA checks through normalized geo config.
projects/packages/cookie-consent/src/class-cookie-consent.php Refactors default config into nested geo schema and normalizes filtered config into that schema before emitting frontend config.
projects/packages/cookie-consent/README.md Documents the nested geo configuration and custom provider contract.
projects/packages/cookie-consent/changelog/add-configurable-geo-provider Adds changelog entry for configurable geo provider/region settings.

Comment thread projects/packages/cookie-consent/src/class-cookie-consent.php
@jp-launch-control

jp-launch-control Bot commented Jun 29, 2026

Copy link
Copy Markdown

Code Coverage Summary

No summary data is available for parent commit aedf21b, so cannot calculate coverage changes. 😴

If that commit is a feature branch rather than a trunk commit, this is expected. Otherwise, this should be updated once coverage for aedf21b is available.

Full summary · PHP report

chihsuan added 3 commits June 29, 2026 17:01
When geo.provider is rejected during normalization, restore the default WPCOM api_url so the normalized provider and endpoint stay consistent.

Handles review comment: 3490102891
@chihsuan chihsuan merged commit 4d25aa4 into trunk Jun 30, 2026
70 of 71 checks passed
@chihsuan chihsuan deleted the add/wooa7s-1600-cookie-consent-geo-provider branch June 30, 2026 07:42
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs [Package] Cookie Consent [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants