Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create REST infrastructure for Consent Mode #8271

Closed
2 tasks
aaemnnosttv opened this issue Feb 19, 2024 · 2 comments
Closed
2 tasks

Create REST infrastructure for Consent Mode #8271

aaemnnosttv opened this issue Feb 19, 2024 · 2 comments
Labels
P0 High priority PHP Type: Enhancement Improvement of an existing feature

Comments

@aaemnnosttv
Copy link
Collaborator

aaemnnosttv commented Feb 19, 2024

Feature Description

This issue is for adding REST endpoint registration, preloading, etc to read and update consent mode settings added in #8270.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • New REST endpoints should be added for reading and updating the Consent Mode settings.
  • The endpoint routes should be as follows:
    • GET core/site/data/consent-mode
    • POST core/site/data/consent-mode
  • The shape of the response and the POST payload should be that of the settings as defined in Create settings infrastructure for Consent Mode #8270.
  • The GET request should be preloaded at page load.

Implementation Brief

  • Follow the REST_Consent_Mode_Controller class from the branch hack/como.
  • Register an instance of the REST_Consent_Mode_Controller class in Consent_Mode.

Test Coverage

  • Provide PHPUnit test coverage for the above changes.

QA Brief

  • Use the following snippet to test the POST endpoint.
  • Ensure at least one of enabled or regions is set.
  • enabled should be a boolean, regions an array of strings conforming to the ISO_3166-2 region code pattern (i.e. case insensitive [A-Z]{2} or [A-Z]{2}-[A-Z]{2}).
googlesitekit.api.set(
  'core', 'site', 'consent-mode',
  {
    settings: {
      enabled: true,
      regions: ['AB','AC']
    }
  }
)
  • Use the following snippet to test the GET endpoint.
googlesitekit.api.get(
  'core', 'site', 'consent-mode',
  {},
  {
    useCache: false
  }
)

Changelog entry

  • Add REST endpoints for consent mode.
@aaemnnosttv aaemnnosttv added P0 High priority Type: Enhancement Improvement of an existing feature PHP labels Feb 19, 2024
@techanvil techanvil self-assigned this Feb 20, 2024
@techanvil techanvil assigned aaemnnosttv and unassigned techanvil Feb 20, 2024
@techanvil
Copy link
Collaborator

This seems pretty uncontentious, so I am going to move it to Execution and start work on the implementation.

@mohitwp
Copy link
Collaborator

mohitwp commented Feb 28, 2024

QA Update ✅

  • Tested on dev environment.
  • Verified both snippet when site kit is not set up.
  • Verified both snippets when site kit setup without analytics.
  • Verifed both snippets when site kit setup with analytics.
  • Verified snippets with or without setting enabled or regions value.

POST Endpoint :

image

image

Wrong enabled value:

image

Wrong regions value:

image

Without region and enabled is set.

image

image

When Regions values are not set then default 32 regions will be auto set

image

When Region value is set -

image

image

GET endpoint

image

Get endpoint with default values -

image

@mohitwp mohitwp removed their assignment Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P0 High priority PHP Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants