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

Prebid 7: Allow USP module to work without explicit configuration #8229

Merged
merged 12 commits into from
Jun 2, 2022

Conversation

patmmccann
Copy link
Collaborator

Part of #7796

@patmmccann patmmccann linked an issue Mar 28, 2022 that may be closed by this pull request
@@ -289,6 +289,7 @@ function exitModule(errMsg, hookConfig, extraArgs) {
export function resetConsentData() {
consentData = undefined;
consentAPI = undefined;
consentTimeout = undefined;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this one stumped me, hat tip to @dgirardi for diagnosing why my 'should disable' test was failing.

@@ -298,18 +299,21 @@ export function resetConsentData() {
*/
export function setConsentConfig(config) {
config = config && config.usp;
if (!config || typeof config !== 'object') {
logWarn('consentManagement.usp config not defined, exiting usp consent manager');
if (config && config.disable === true) {
Copy link
Collaborator Author

@patmmccann patmmccann Mar 28, 2022

Choose a reason for hiding this comment

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

this allows a publisher to restore the old behavior (exit immediately) with configuration.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is equivalent - it does not mean "disable" but "ignore". Let's say I do

pbjs.setConfig({
   consentManagement: {
      gpdr: {...}
   }
});
pbjs.setConfig({
  consentManagement: {
    usp: {
       disable: true
    }
  }
});

the first call would activate USP with the default values, the second would log a warning but otherwise do nothing - USP would still be enabled.

You could resetConsentData (and remove the requestBidsHook), but I can't think of another example where we ask for explicit deactivation. To me it seems cleaner if we either require explicit activation (maybe that means accepting usp: {} to indicate the default), or just make it clear that if you install the module, it's always active.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if what you say is true, how is this test passing

it('should not run if disable is true', function () {
setConsentConfig({usp: {disable: true}});
expect(consentAPI).to.be.undefined;
expect(consentTimeout).to.be.undefined;
sinon.assert.callCount(utils.logWarn, 1);
});

Copy link
Collaborator

Choose a reason for hiding this comment

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

That test should be called "should not change settings if disable is true". Add a setConsentConfig({}) in the beginning and it should fail.

@jsnellbaker jsnellbaker requested a review from Fawke March 30, 2022 14:15
@patmmccann patmmccann added the needs 2nd review Core module updates require two approvals from the core team label Apr 2, 2022
Copy link
Contributor

@Fawke Fawke left a comment

Choose a reason for hiding this comment

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

LGTM

@Fawke Fawke requested a review from ChrisHuie April 5, 2022 10:12
@patmmccann patmmccann requested a review from dgirardi May 6, 2022 16:22
@patmmccann patmmccann removed needs 2nd review Core module updates require two approvals from the core team maintenance labels Jun 2, 2022
@patmmccann
Copy link
Collaborator Author

Thanks for your review and changes @dgirardi ; I added docs PR as well

@patmmccann patmmccann merged commit da54a9c into prebid-7 Jun 2, 2022
@patmmccann patmmccann deleted the change-usp-noconfig-behavior branch June 2, 2022 20:27
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.

Default usp consent framework to 'iab'?
3 participants