Cookie Consent: Add configurable geo provider#50038
Conversation
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
There was a problem hiding this comment.
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
geoconfig 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
geoconfig 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. |
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
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
geo.*config.geo.*keys authoritative.Note: geo is always enabled; there is no
features.geoflag.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
git diff --name-only origin/trunk...HEAD.mise exec node@24.15.0 -- pnpm --filter @automattic/jetpack-cookie-consent test.mise exec node@24.15.0 -- pnpm --filter @automattic/jetpack-cookie-consent typecheck.mise exec node@24.15.0 -- pnpm --filter @automattic/jetpack-cookie-consent build.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.composer php:lint -- projects/packages/cookie-consent/src/class-cookie-consent.php.composer phpcs:lint -- projects/packages/cookie-consent/src/class-cookie-consent.php.composer phpcs:compatibility -- projects/packages/cookie-consent/src/class-cookie-consent.php.vendor/bin/phan --allow-polyfill-parser --include-analysis-file-list projects/packages/cookie-consent/src/class-cookie-consent.php --no-progress-bar.