Skip to content

Commit

Permalink
Add GDPR support for Quantcast adapter (prebid#2733)
Browse files Browse the repository at this point in the history
* Add GDPR support for Quantcast adapter

* Fix lint error
  • Loading branch information
soarez authored and StefanWallin committed Sep 28, 2018
1 parent 35d7cb0 commit 48c485c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
9 changes: 7 additions & 2 deletions modules/quantcastBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ export const spec = {
* `BidRequests`.
*
* @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be send to Quantcast server
* @param bidderRequest
* @return ServerRequest information describing the request to the server.
*/
buildRequests(bidRequests) {
buildRequests(bidRequests, bidderRequest) {
const bids = bidRequests || [];

const referrer = utils.getTopWindowUrl();
Expand Down Expand Up @@ -75,6 +76,8 @@ export const spec = {
});
});

const gdprConsent = bidderRequest ? bidderRequest.gdprConsent : {};

// Request Data Format can be found at https://wiki.corp.qc/display/adinf/QCX
const requestData = {
publisherId: bid.params.publisherId,
Expand All @@ -94,7 +97,9 @@ export const spec = {
referrer,
domain
},
bidId: bid.bidId
bidId: bid.bidId,
gdprSignal: gdprConsent.gdprApplies ? 1 : 0,
gdprConsent: gdprConsent.consentString
};

const data = JSON.stringify(requestData);
Expand Down
4 changes: 2 additions & 2 deletions modules/quantcastBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
```
Module Name: Quantcast Bidder Adapter
Module Type: Bidder Adapter
Maintainer: xli@quantcast.com
Maintainer: igor.soarez@quantcast.com
```

# Description
Expand All @@ -28,4 +28,4 @@ const adUnits = [{
}
]
}];
```
```
11 changes: 10 additions & 1 deletion test/spec/modules/quantcastBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,22 @@ describe('Quantcast adapter', () => {
referrer,
domain
},
bidId: '2f7b179d443f14'
bidId: '2f7b179d443f14',
gdprSignal: 0
};

expect(requests[0].data).to.equal(JSON.stringify(expectedBidRequest));
});
});

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

describe('`interpretResponse`', () => {
// The sample response is from https://wiki.corp.qc/display/adinf/QCX
const body = {
Expand Down

0 comments on commit 48c485c

Please sign in to comment.