Skip to content

Commit

Permalink
Add GDPR support to DAN Marketplace Bid Adapter (#2605)
Browse files Browse the repository at this point in the history
* Make Bid Adapter for Dentsu Aegis Network Marketplace

* Update DAN_Marketplace adapter

* Rename danmarketplaceBidAdapter into danmarketBidAdapter

* Add support of GDPR in DAN Marketplace Bid Adapter

* Add GDPR params in sync pixel
  • Loading branch information
danmarketplace authored and Rich Snapp committed May 25, 2018
1 parent 337eccf commit 8c5f129
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
24 changes: 21 additions & 3 deletions modules/danmarketBidAdapter.js
Expand Up @@ -30,7 +30,7 @@ export const spec = {
return !!bid.params.uid;
},

buildRequests: function(validBidRequests) {
buildRequests: function(validBidRequests, bidderRequest) {
const auids = [];
const bidsMap = {};
const bids = validBidRequests || [];
Expand All @@ -57,6 +57,15 @@ export const spec = {
r: reqId,
};

if (bidderRequest && bidderRequest.gdprConsent) {
if (bidderRequest.gdprConsent.consentString) {
payload.gdpr_consent = bidderRequest.gdprConsent.consentString;
}
payload.gdpr_applies =
(typeof bidderRequest.gdprConsent.gdprApplies === 'boolean')
? Number(bidderRequest.gdprConsent.gdprApplies) : 1;
}

return {
method: 'GET',
url: ENDPOINT_URL,
Expand Down Expand Up @@ -87,11 +96,20 @@ export const spec = {
return bidResponses;
},

getUserSyncs: function(syncOptions) {
getUserSyncs: function(syncOptions, serverResponses, gdprConsent) {
if (syncOptions.pixelEnabled) {
var query = [];
if (gdprConsent) {
if (gdprConsent.consentString) {
query.push('gdpr_consent=' + encodeURIComponent(gdprConsent.consentString));
}
query.push('gdpr_applies=' + encodeURIComponent(
(typeof gdprConsent.gdprApplies === 'boolean')
? Number(gdprConsent.gdprApplies) : 1));
}
return [{
type: 'image',
url: ADAPTER_SYNC_URL
url: ADAPTER_SYNC_URL + (query.length ? '?' + query.join('&') : '')
}];
}
}
Expand Down
24 changes: 24 additions & 0 deletions test/spec/modules/danmarketBidAdapter_spec.js
Expand Up @@ -114,6 +114,30 @@ describe('DAN_Marketplace Adapter', function () {
expect(payload).to.have.property('auids', '5,6');
delete bidRequests[1].params.priceType;
});

it('if gdprConsent is present payload must have gdpr params', () => {
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: true}});
const payload = request.data;
expect(payload).to.be.an('object');
expect(payload).to.have.property('gdpr_consent', 'AAA');
expect(payload).to.have.property('gdpr_applies', 1);
});

it('if gdprApplies is false gdpr_applies must be 0', () => {
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: false}});
const payload = request.data;
expect(payload).to.be.an('object');
expect(payload).to.have.property('gdpr_consent', 'AAA');
expect(payload).to.have.property('gdpr_applies', 0);
});

it('if gdprApplies is undefined gdpr_applies must be 1', () => {
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA'}});
const payload = request.data;
expect(payload).to.be.an('object');
expect(payload).to.have.property('gdpr_consent', 'AAA');
expect(payload).to.have.property('gdpr_applies', 1);
});
});

describe('interpretResponse', () => {
Expand Down

0 comments on commit 8c5f129

Please sign in to comment.