Skip to content

🧪✨ [amp-consent] Allow purposeConsentRequired inline and via endpoint response#32433

Merged
micajuine-ho merged 3 commits intoampproject:masterfrom
micajuine-ho:purposeConsentRequired
Feb 5, 2021
Merged

🧪✨ [amp-consent] Allow purposeConsentRequired inline and via endpoint response#32433
micajuine-ho merged 3 commits intoampproject:masterfrom
micajuine-ho:purposeConsentRequired

Conversation

@micajuine-ho
Copy link
Copy Markdown
Contributor

Partial for #31607

Introduce the amp-consent-granular-consent experiment for the launch of the granular consent feature.

When initializing consent (not the syncing case), if we already have a global consent stored (tcString or consentStateValue of accepted or rejected), then collect purposeConsentRequired field from inline config or from the cached remote response.

Currently we only validate that it's an array (if it's there), in the future we will compare it to our stored granular consent values to determine if we have collected the necessary consents to bypass showing the consent UI.

@micajuine-ho micajuine-ho requested a review from dmanek February 4, 2021 18:02
@amp-owners-bot amp-owners-bot bot requested a review from rsimha February 4, 2021 18:02
Copy link
Copy Markdown
Contributor

@rsimha rsimha left a comment

Choose a reason for hiding this comment

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

build-system/ change LGTM.

* @param {ConsentInfoDef} opt_consentInfo
* @return {!Promise<boolean>}
*/
checkGranularConsentRequired_(opt_consentInfo) {
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.

  1. opt_consentInfo looks unused. Assuming it will be used later?
  2. More of an AMP practice question - instead of using opt_ prefix, can we use default params?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup! Unused for now, but we're going to use it in the future to determine if the stored purpose consents match with the publisher defined purposeConsentRequired field. If all the purposes have consents, then we can unblock, otherwise we should should the consent prompt.

More of an AMP practice question - instead of using opt_ prefix, can we use default params?

Both are allowed in the codebase. There's also the unused- prefix.

/**
* Get `purposeConsentRequired` from consent config,
* or from `checkConsentHref` response.
* @return {!Promise}
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.

nit: add type like on line 691 below.

doc.body.appendChild(consentElement);
ampConsent = new AmpConsent(consentElement);
await ampConsent.buildCallback();
expect(await ampConsent.getPurposeConsentRequired_()).to.undefined;
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.

  1. test description say returns null..., please update
  2. to.be.undefined

@micajuine-ho micajuine-ho force-pushed the purposeConsentRequired branch from 66fda13 to 120ec1c Compare February 5, 2021 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants