Skip to content

Conversation

@micajuine-ho
Copy link
Contributor

@micajuine-ho micajuine-ho commented Apr 14, 2020

Adding support for TCF v2 gdprApplies value.

  • Allows gdprApplies to be true, false or null (when checkConsentHref is not defined)
  • Stored as g:(0|1|undefined) in local storage
  • If gdprApplies is not sent through checkConsentHref, it will default to remote consentRequired values (never default to local consentRequired).

Future work: cache gdprApplies value, add macro support for gdprApplies, consolidaste src/consent.js methods (gdprApplies, consentString, and consentType, to be sent together, updated together, and retrieved together)

Closes #27190

@amp-bundle-size amp-bundle-size bot requested a review from ajwhatson April 14, 2020 20:55
src/consent.js Outdated
* @param {string} policyId
* @return {!Promise<boolean>}
*/
export function getGdprAppliesInfo(element, policyId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the plan to migrate to getConsentPolicyInfo and deprecate the method here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See comments below

Copy link
Contributor

Choose a reason for hiding this comment

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

// Return the stored gdpr applies value. doesn't tell what the future plan is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops I was unclear, the plan as discussed offline, is to consolidate the methods in src/consent to return a single consent info object, but for now we will keep this method to unblock the ads teams.

consentStateValue,
responseConsentString
responseConsentString,
responseGdprApplies
Copy link
Contributor

Choose a reason for hiding this comment

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

updating gdprApplies here won't work because it requires consentStateValue to be not null.
A typical workflow is as following

  • consentHref returns gdprApplies, but no consentStateValue.
  • Then the consentStateValue is calculated on the client side.

I'd recommend we handle the gdprApplies separate from consentState and consentString. Like what we do with the dirtyBit.
Let me know if you have better ideas.

Copy link
Contributor Author

@micajuine-ho micajuine-ho Apr 15, 2020

Choose a reason for hiding this comment

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

Ok, thanks for addressing this. It was either treat it like consentString/consentStateValue or treat it like dirtyBit. I'm good to treat it like dirtyBit.

Edit: Discussed offline, will approach gdprApplies values similar to sharedData: it will only be stored in the Consent Instance and not local storage. As a future optimization, once the value starts to get used more by vendors, we will cache the gdprApplies value in local storage and use that value instead of having to wait for another round trip.

it('uses given value', async () => {
const inlineConfig = {
'consentInstanceId': 'abc',
'consentRequired': 'remote',
Copy link
Contributor

Choose a reason for hiding this comment

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

Please also add a test to test the local consentRequired: false or consentRequired: true as well.

Copy link
Contributor

@zhouyx zhouyx Apr 16, 2020

Choose a reason for hiding this comment

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

Actually it will also work if you decide to limit the gdprApplies with checkConsentHref. But in that case, maybe we should not expose the getGdprAppliesInfo API. That it should only be retrieved with consent string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually it will also work if you decide to limit the gdprApplies with checkConsentHref.

Yes this is currently the case. In the spec, we said that it would default to consentRequired and I interpreted that to mean that we check checkConsentHref first then use consentRequired if it's not given.

That it should only be retrieved with consent string

So are you saying that we should remove getGdprAppliesInfo and getConsentPolicyInfo from src/consent and create a general API (ie: getTcfV2Info())?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ha the consentRequired defined in different places is confusing. What about the consentRequired in inline config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed offline: will save consolidation of these APIs for later work (by June), so that we can unblock ads teams that are needing the gdprApplies data.

@micajuine-ho
Copy link
Contributor Author

@zhouyx Ready for review

@micajuine-ho micajuine-ho requested a review from zhouyx April 17, 2020 20:07
src/consent.js Outdated
* @param {string} policyId
* @return {!Promise<boolean>}
*/
export function getGdprAppliesInfo(element, policyId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

// Return the stored gdpr applies value. doesn't tell what the future plan is.

@micajuine-ho
Copy link
Contributor Author

@zhouyx PTAL

Copy link
Contributor

@zhouyx zhouyx left a comment

Choose a reason for hiding this comment

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

#27759 (comment)

Can you add TODO? Thanks

it('defaults correctly when checkConsentHref is not defined', async () => {
const inlineConfig = {
'consentInstanceId': 'abc',
'consentRequired': false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the inline consentRequired value affect the gdprApplies value?
My understanding is it won't, if so do you think we should set the value true instead to make more obvious that gdprApplies value is not related to the inline consentRequired value.

(Sign.... two fields with the same name is soooo confusing)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use the inline consentRequired value when gdprApplies or checkConsentHref is not supplied. And since consentRequired will always be a valid value after consent-config.js merges it, it's a good fallback.

I've change the test name and values to reflect this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated PR description to reflect or decision (never fallback to local consentRequired)

@micajuine-ho
Copy link
Contributor Author

micajuine-ho commented Apr 23, 2020

Can you add TODO

Added

@zhouyx Ready for review :D

@micajuine-ho micajuine-ho force-pushed the gdprApplies branch 2 times, most recently from 1c03af8 to a68fac0 Compare April 27, 2020 22:04
@micajuine-ho micajuine-ho removed the request for review from ajwhatson April 27, 2020 22:17
Copy link
Contributor

@zhouyx zhouyx left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for adding the ${gdprApplies} support. cc @Leedehai

@micajuine-ho
Copy link
Contributor Author

Thanks for adding the ${gdprApplies}

Just a note, macro support is not in this PR, but can be future work if anyone requires it :)

@micajuine-ho micajuine-ho merged commit 8ca8b63 into ampproject:master Apr 28, 2020
ldoroshe pushed a commit to ldoroshe/amphtml that referenced this pull request May 8, 2020
* Sync w/ cache from amp-consent

* Tests

* no caching for now

* suggested changes

* Never use local consentRequired
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.

AMP Consent to support "gdprApplies" param

4 participants