Adding consentStringType to amp-consent metadata#28028
Adding consentStringType to amp-consent metadata#28028micajuine-ho merged 11 commits intoampproject:masterfrom
Conversation
|
Thank you for the PR description. Very helpful.
Thank you |
|
@zhouyx Thanks for your questions.
consentType and consentString values are:
Yes, we've only added fields, and if the field isn't present, no values will be stored in the policy manager or local storage. Once we consolidate the API to retrieve these values will change, but since they're all inhouse APIs we can make the necessary changes. |
9e4482a to
0e09747
Compare
0e09747 to
1b6de4d
Compare
|
Thanks! Sounds good. One more question, looking at the code one could have |
@zhouyx As of now, the WDYT? |
Sounds good. I think the same rule should be applied to |
@zhouyx Applied the fix (+ test). PTAL |
|
To better address the map between consent string. What do you think about renaming the variable |
I think this will definitely help clarify the mapping. |
583fc77 to
a319a1b
Compare
|
This pull request introduces 1 alert when merging 15fe60e into f92fb89 - view on LGTM.com new alerts:
|
5f6e131 to
b11a080
Compare
|
@zhouyx I have update the PR description so it accurately reflects the PR. qq: Should src/consent getConsentMetadata() have a real closure type? And if so, do we create a new one in src/metadata-type or can we import from amp-consent/0.1/consent-info? |
b11a080 to
d2ef3d1
Compare
d2ef3d1 to
9de1aab
Compare
My understanding is the real closure type doesn't help much because we need to keep the key name of each field. (You can't minimize 'consentStringType' to 'c' during compilation). |
a54febe to
6505695
Compare
6505695 to
f1edd2c
Compare
| instance.update(CONSENT_ITEM_STATE.ACCEPTED, 'test', {}); | ||
| yield macroTask(); | ||
| expect(storageSetSpy).to.be.calledTwice; | ||
| instance.update(CONSENT_ITEM_STATE.ACCEPTED, 'test'); |
There was a problem hiding this comment.
metadata {} and undefined is different?
There was a problem hiding this comment.
Yes, consentMetadata from server response could be undefined and {} resulting in undefined or empty ConsentMetadataDef respectfully. Should we treat these as the same (akaundefined response generates an empty ConsentMetadataDef)?
There was a problem hiding this comment.
Depends on if undefined and {} will be treated differently by vendors, and in localStorage.
My understanding is that the two value (and even null) means the same thing.
There was a problem hiding this comment.
Ok do you think it's fine if I leave it as is, incase vendor does need that distinction?
| expect(requestBody.consentString).to.equal('old'); | ||
| expect(requestBody.consentMetadata).to.be.undefined; | ||
| yield instance.update(CONSENT_ITEM_STATE.ACCEPTED, 'new', {}); | ||
| yield instance.update( |
There was a problem hiding this comment.
I'm fine with this since you've already added the metadata to the test.
However I also find it unnecessary with this unit test and many tests above. The test here is to specifically cover consentString change, in the spirit of unit test consentMetadata value should not affect the test.
Ideally the optional value consentMetadata will only be added to related tests to keep the unit tests clean.
To add test coverage: It's great to add more unit tests target consentMetadata functionalities. And add the value to the integration test case.
There was a problem hiding this comment.
Good point. I will be more selective in the places where I test future metadata functionality.
It's great to add more unit tests target consentMetadata functionalities
Are there particular functionalities I am missing? I think most of the functionality is handled by test-consent-info.js
And add the value to the integration test case.
In our e2e tests, we check the blocking behavior and but not the local storage values. Should this be changed so that we can check for the correct metadata?
There was a problem hiding this comment.
The test coverage on functionalities looks good to me.
Please remind me, I think we didn't check local storage value for a reason.
We can add e2e test coverage once we expose API to get metadata. (or even use analytics variable substitution)
There was a problem hiding this comment.
Please remind me, I think we didn't check local storage value for a reason.
We felt that e2e test was not the place to access localstorage, and instead relied upon outcome of test (blocked elements vs non-blocked) as the indicator of localstorage values. We also used analytics substitutions to verify as that was an end behavior of the test.
We have now have the exposed API and once we finish all the metadata value implementations, I will create e2e cases to test (#28634)
3c753fb to
28a92e2
Compare
| expect(requestBody.consentString).to.equal('old'); | ||
| expect(requestBody.consentMetadata).to.be.undefined; | ||
| yield instance.update(CONSENT_ITEM_STATE.ACCEPTED, 'new', {}); | ||
| yield instance.update( |
There was a problem hiding this comment.
The test coverage on functionalities looks good to me.
Please remind me, I think we didn't check local storage value for a reason.
We can add e2e test coverage once we expose API to get metadata. (or even use analytics variable substitution)
| instance.update(CONSENT_ITEM_STATE.ACCEPTED, 'test', {}); | ||
| yield macroTask(); | ||
| expect(storageSetSpy).to.be.calledTwice; | ||
| instance.update(CONSENT_ITEM_STATE.ACCEPTED, 'test'); |
There was a problem hiding this comment.
Depends on if undefined and {} will be treated differently by vendors, and in localStorage.
My understanding is that the two value (and even null) means the same thing.
28a92e2 to
7fa3abb
Compare
| */ | ||
|
|
||
| import { | ||
| CONSENT_STRING_TYPE, // eslint-disable-line no-unused-vars |
There was a problem hiding this comment.
nit: You should be able to get rid of this by using {../../../src/consent-state.CONSENT_STRING_TYPE}
There was a problem hiding this comment.
hmm I don't see this anywhere in the codebase and I get an error when I do this... Anywhere I can see an example of this?
There was a problem hiding this comment.
There was a problem hiding this comment.
please remove the eslint comment. we no longer need it
I can't reply to the origin comment thread 😢 Reply here Sure if vendor does need the distinction. The tradeoff here is one need to check for the metadata value before accessing any field. I'm good with whatever vendors think works best for them. |
Ok, I will follow up, and make changes if necessary. |
7fa3abb to
5280d3b
Compare
| */ | ||
|
|
||
| import { | ||
| CONSENT_STRING_TYPE, // eslint-disable-line no-unused-vars |
There was a problem hiding this comment.
Closes #27907
After adding
consentMetadataobject in #28187, we are now allowing that object to containconsentStringTypefield.consentMetadatais accepted fromcheckConsentHrefand the external iframe consent flow's response. Accepted values ofconsentStringTypeare1, 2, and 3(mapping will be defined in theamp-consent.mdafter all changes hit prod. For now seesrc/consent-state.js).consentMetadatawill be sent as aConsentMetadataDefas part of thecheckConsentHrefandonUpdateHrefrequests, as well as part of the ClientInfo sent to external iframe flow.consentMetadatais only valid if accompanied by aconsentString,consentMetadatawill get converted to aConsentMetadataDefstored withinConsentInfoin memory, and sent to theConsent State Manager.Consent State Managerstores theConsentInfoto local storage,ConsentMetadataDefwill also get stored within it using theMETADATA_STORAGE_KEY:ConsentMetadataDefwill be accessed internally throughsrc/consent#getConsentMetadata(), via theConsent Policy Manager