Skip to content

Commit

Permalink
updated adxcg bidAdapter for gdpr (prebid#2713)
Browse files Browse the repository at this point in the history
  • Loading branch information
adxcgcom authored and AlessandroDG committed Sep 13, 2018
1 parent b47359b commit 8fde604
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 12 deletions.
31 changes: 20 additions & 11 deletions modules/adxcgBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {BANNER, NATIVE, VIDEO} from 'src/mediaTypes';
/**
* Adapter for requesting bids from adxcg.net
* updated to latest prebid repo on 2017.10.20
* updated for gdpr compliance on 2018.05.22 -requires gdpr compliance module
*/

const BIDDER_CODE = 'adxcg';
Expand Down Expand Up @@ -51,21 +52,28 @@ export const spec = {
requestUrl.search = null;
requestUrl.hash = null;

let beaconParams = {
renderformat: 'javascript',
ver: 'r20180522PB10',
adzoneid: adZoneIds.join(','),
format: sizes.join(','),
prebidBidIds: prebidBidIds.join(','),
url: encodeURIComponent(url.format(requestUrl)),
secure: secure ? '1' : '0',
source: SOURCE,
pbjs: '$prebid.version$'
};

if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) {
beaconParams.gdpr = bidderRequest.gdprConsent.gdprApplies ? '1' : '0';
beaconParams.gdpr_consent = bidderRequest.gdprConsent.consentString;
}

let adxcgRequestUrl = url.format({
protocol: secure ? 'https' : 'http',
hostname: secure ? 'hbps.adxcg.net' : 'hbp.adxcg.net',
pathname: '/get/adi',
search: {
renderformat: 'javascript',
ver: 'r20171102PB10',
adzoneid: adZoneIds.join(','),
format: sizes.join(','),
prebidBidIds: prebidBidIds.join(','),
url: encodeURIComponent(url.format(requestUrl)),
secure: secure ? '1' : '0',
source: SOURCE,
pbjs: '$prebid.version$'
}
search: beaconParams
});

return {
Expand Down Expand Up @@ -151,4 +159,5 @@ export const spec = {
}
}
};

registerBidder(spec);
34 changes: 33 additions & 1 deletion test/spec/modules/adxcgBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('AdxcgAdapter', () => {

let query = parsedRequestUrl.search;
expect(query.renderformat).to.equal('javascript');
expect(query.ver).to.equal('r20171102PB10');
expect(query.ver).to.equal('r20180522PB10');
expect(query.source).to.equal('pbjs10');
expect(query.pbjs).to.equal('$prebid.version$');
expect(query.adzoneid).to.equal('1');
Expand All @@ -64,6 +64,38 @@ describe('AdxcgAdapter', () => {
});
});

describe('gdpr compliance', () => {
let bid = {
'bidder': 'adxcg',
'params': {
'adzoneid': '1'
},
'adUnitCode': 'adunit-code',
'sizes': [[300, 250], [640, 360], [1, 1]],
'bidId': '84ab500420319d',
'bidderRequestId': '7101db09af0db2',
'auctionId': '1d1a030790a475',
};

it('should send GDPR Consent data if gdprApplies', () => {
let request = spec.buildRequests([bid], {gdprConsent: {gdprApplies: true, consentString: 'consentDataString'}});
let parsedRequestUrl = url.parse(request.url);
let query = parsedRequestUrl.search;

expect(query.gdpr).to.equal('1');
expect(query.gdpr_consent).to.equal('consentDataString');
});

it('should not send GDPR Consent data if gdprApplies is false or undefined', () => {
let request = spec.buildRequests([bid], {gdprConsent: {gdprApplies: false, consentString: 'consentDataString'}});
let parsedRequestUrl = url.parse(request.url);
let query = parsedRequestUrl.search;

expect(query.gdpr).to.be.empty;
expect(query.gdpr_consent).to.be.empty;
});
});

describe('response handler', () => {
let BIDDER_REQUEST = {
'bidder': 'adxcg',
Expand Down

0 comments on commit 8fde604

Please sign in to comment.