Skip to content

Commit

Permalink
QC CCPA support (prebid#4557)
Browse files Browse the repository at this point in the history
* Pass uspConsent parameter from bidder request to QC endpoint.

* Added uspSignal to indicate if uspConsent has been passed in request.
  • Loading branch information
dpapworth-qc authored and Isaac A. Dettman committed Dec 11, 2019
1 parent 11e8113 commit 8593acc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
6 changes: 4 additions & 2 deletions modules/quantcastBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export const spec = {
*/
buildRequests(bidRequests, bidderRequest) {
const bids = bidRequests || [];
const gdprConsent = (bidderRequest && bidderRequest.gdprConsent) ? bidderRequest.gdprConsent : {};

const gdprConsent = utils.deepAccess(bidderRequest, 'gdprConsent') || {};
const uspConsent = utils.deepAccess(bidderRequest, 'uspConsent');
const referrer = utils.deepAccess(bidderRequest, 'refererInfo.referer');
const page = utils.deepAccess(bidderRequest, 'refererInfo.canonicalUrl') || config.getConfig('pageUrl') || utils.deepAccess(window, 'location.href');
const domain = getDomain(page);
Expand Down Expand Up @@ -139,6 +139,8 @@ export const spec = {
bidId: bid.bidId,
gdprSignal: gdprConsent.gdprApplies ? 1 : 0,
gdprConsent: gdprConsent.consentString,
uspSignal: uspConsent ? 1 : 0,
uspConsent,
prebidJsVersion: '$prebid.version$'
};

Expand Down
21 changes: 17 additions & 4 deletions test/spec/modules/quantcastBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ describe('Quantcast adapter', function () {
},
bidId: '2f7b179d443f14',
gdprSignal: 0,
uspSignal: 0,
prebidJsVersion: '$prebid.version$'
};

Expand Down Expand Up @@ -203,6 +204,7 @@ describe('Quantcast adapter', function () {
},
bidId: '2f7b179d443f14',
gdprSignal: 0,
uspSignal: 0,
prebidJsVersion: '$prebid.version$'
};

Expand Down Expand Up @@ -237,6 +239,7 @@ describe('Quantcast adapter', function () {
},
bidId: '2f7b179d443f14',
gdprSignal: 0,
uspSignal: 0,
prebidJsVersion: '$prebid.version$'
};

Expand Down Expand Up @@ -267,6 +270,7 @@ describe('Quantcast adapter', function () {
},
bidId: '2f7b179d443f14',
gdprSignal: 0,
uspSignal: 0,
prebidJsVersion: '$prebid.version$'
};

Expand Down Expand Up @@ -329,6 +333,7 @@ describe('Quantcast adapter', function () {
},
bidId: '2f7b179d443f14',
gdprSignal: 0,
uspSignal: 0,
prebidJsVersion: '$prebid.version$'
};

Expand All @@ -337,11 +342,19 @@ describe('Quantcast adapter', function () {
});

it('propagates GDPR consent string and signal', function () {
const gdprConsent = { gdprApplies: true, consentString: 'consentString' }
const requests = qcSpec.buildRequests([bidRequest], { gdprConsent });
const parsed = JSON.parse(requests[0].data)
const bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentString' } }
const requests = qcSpec.buildRequests([bidRequest], bidderRequest);
const parsed = JSON.parse(requests[0].data);
expect(parsed.gdprSignal).to.equal(1);
expect(parsed.gdprConsent).to.equal(gdprConsent.consentString);
expect(parsed.gdprConsent).to.equal('consentString');
});

it('propagates US Privacy/CCPA consent information', function () {
const bidderRequest = { uspConsent: 'consentString' }
const requests = qcSpec.buildRequests([bidRequest], bidderRequest);
const parsed = JSON.parse(requests[0].data);
expect(parsed.uspSignal).to.equal(1);
expect(parsed.uspConsent).to.equal('consentString');
});

describe('`interpretResponse`', function () {
Expand Down

0 comments on commit 8593acc

Please sign in to comment.