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

Adds support for additional consent #5600

Merged
merged 6 commits into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion modules/consentManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ function cmpFailed(errMsg, hookConfig, extraArgs) {
}

/**
* Stores CMP data locally in module and then invokes gdprDataHandler.setConsentData() to make information available in adaptermanger.js for later in the auction
* Stores CMP data locally in module and then invokes gdprDataHandler.setConsentData() to make information available in adaptermanager.js for later in the auction
* @param {object} cmpConsentObject required; an object representing user's consent choices (can be undefined in certain use-cases for this function only)
*/
function storeConsentData(cmpConsentObject) {
Expand All @@ -385,6 +385,9 @@ function storeConsentData(cmpConsentObject) {
vendorData: (cmpConsentObject) || undefined,
gdprApplies: cmpConsentObject && typeof cmpConsentObject.gdprApplies === 'boolean' ? cmpConsentObject.gdprApplies : gdprScope
};
if (cmpConsentObject.addtlConsent && utils.isStr(cmpConsentObject.addtlConsent)) {
consentData.addtlConsent = cmpConsentObject.addtlConsent;
};
}
consentData.apiVersion = cmpVersion;
gdprDataHandler.setConsentData(consentData);
Expand Down
3 changes: 3 additions & 0 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,9 @@ const OPEN_RTB_PROTOCOL = {
}
utils.deepSetValue(request, 'regs.ext.gdpr', gdprApplies);
utils.deepSetValue(request, 'user.ext.consent', firstBidRequest.gdprConsent.consentString);
if (firstBidRequest.gdprConsent.addtlConsent && typeof firstBidRequest.gdprConsent.addtlConsent === 'string') {
utils.deepSetValue(request, 'user.ext.ConsentedProvidersSettings.consented_providers', firstBidRequest.gdprConsent.addtlConsent);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to confirm - are we sure that this field is supported by PBS?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that was the field @bretg proposed on #5389 (comment) bullet point 2

}
}

// US Privacy (CCPA) support
Expand Down
26 changes: 26 additions & 0 deletions test/spec/modules/consentManagement_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,32 @@ describe('consentManagement', function () {
expect(consent.apiVersion).to.equal(2);
});

it('performs lookup check and stores consentData for a valid existing user with additional consent', function () {
let testConsentData = {
tcString: 'abc12345234',
addtlConsent: 'superduperstring',
gdprApplies: true,
purposeOneTreatment: false,
eventStatus: 'tcloaded'
};
cmpStub = sinon.stub(window, '__tcfapi').callsFake((...args) => {
args[2](testConsentData, true);
});

setConsentConfig(goodConfigWithAllowAuction);

requestBidsHook(() => {
didHookReturn = true;
}, {});
let consent = gdprDataHandler.getConsentData();
sinon.assert.notCalled(utils.logError);
expect(didHookReturn).to.be.true;
expect(consent.consentString).to.equal(testConsentData.tcString);
expect(consent.addtlConsent).to.equal(testConsentData.addtlConsent);
expect(consent.gdprApplies).to.be.true;
expect(consent.apiVersion).to.equal(2);
});

it('throws an error when processCmpData check fails + does not call requestBids callbcack even when allowAuction is true', function () {
let testConsentData = {};
let bidsBackHandlerReturn = false;
Expand Down
31 changes: 31 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,37 @@ describe('S2S Adapter', function () {
expect(requestBid.user).to.not.exist;
});

it('adds additional consent information to ortb2 request depending on presence of module', function () {
let ortb2Config = utils.deepClone(CONFIG);
ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction';

let consentConfig = { consentManagement: { cmpApi: 'iab' }, s2sConfig: ortb2Config };
config.setConfig(consentConfig);

let gdprBidRequest = utils.deepClone(BID_REQUESTS);
gdprBidRequest[0].gdprConsent = {
consentString: 'abc123',
addtlConsent: 'superduperconsent',
gdprApplies: true
};

adapter.callBids(REQUEST, gdprBidRequest, addBidResponse, done, ajax);
let requestBid = JSON.parse(server.requests[0].requestBody);

expect(requestBid.regs.ext.gdpr).is.equal(1);
expect(requestBid.user.ext.consent).is.equal('abc123');
expect(requestBid.user.ext.ConsentedProvidersSettings.consented_providers).is.equal('superduperconsent');

config.resetConfig();
config.setConfig({ s2sConfig: CONFIG });

adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax);
requestBid = JSON.parse(server.requests[1].requestBody);

expect(requestBid.regs).to.not.exist;
expect(requestBid.user).to.not.exist;
});

it('check gdpr info gets added into cookie_sync request: have consent data', function () {
let cookieSyncConfig = utils.deepClone(CONFIG);
cookieSyncConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync';
Expand Down