Skip to content

Commit

Permalink
Arteebee adapter GDPR integration (#2643)
Browse files Browse the repository at this point in the history
* add arteebee adapter

* set log

* basic structure

* basic structure

* send caller as placeholder for ip and user agent

* send caller as placeholder for ip and user agent

* send caller as placeholder for ip and user agent

* first version of adapter

* add unit testing for arteebee bid adapter

* fix indent

* fix lint complain

* Add consent manager support

* fix requestId missing
  • Loading branch information
Old Tiger authored and jsnellbaker committed May 30, 2018
1 parent 6d071f5 commit 4bde2a1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
26 changes: 19 additions & 7 deletions modules/arteebeeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export const spec = {
return 'params' in bidRequest && bidRequest.params.pub !== undefined &&
bidRequest.params.source !== undefined;
},
buildRequests: function (validBidRequests) {
buildRequests: function (validBidRequests, bidderRequest) {
var requests = [];

for (let i = 0; i < validBidRequests.length; i++) {
let prebidReq = makePrebidRequest(validBidRequests[i]);
let prebidReq = makePrebidRequest(validBidRequests[i], bidderRequest);
if (prebidReq) {
requests.push(prebidReq);
}
Expand Down Expand Up @@ -58,20 +58,20 @@ export const spec = {
}
return bidResponses;
},
getUserSyncs: function (syncOptions, serverResponses) {
getUserSyncs: function (syncOptions, serverResponses, gdprConsent) {
return [];
}
}

registerBidder(spec);

function makePrebidRequest(req) {
function makePrebidRequest(req, bidderRequest) {
var host = req.params.host || DEFAULT_HOST;
var ssp = req.params.ssp || DEFAULT_SSP;

var url = window.location.protocol + '//' + host + '/rtb/bid/' + ssp + '?type=json&register=0';

const payload = makeRtbRequest(req);
const payload = makeRtbRequest(req, bidderRequest);
const payloadString = JSON.stringify(payload);

return {
Expand All @@ -81,8 +81,8 @@ function makePrebidRequest(req) {
};
}

function makeRtbRequest(req) {
var auctionId = req.requestId;
function makeRtbRequest(req, bidderRequest) {
var auctionId = req.bidderRequestId;

var imp = [];
imp.push(makeImp(req));
Expand All @@ -100,6 +100,18 @@ function makeRtbRequest(req) {
rtbReq.regs = {coppa: 1};
}

if (bidderRequest && bidderRequest.gdprConsent) {
if ((typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') && bidderRequest.gdprConsent.gdprApplies) {
if (!rtbReq.regs) {
rtbReq.regs = {};
}
rtbReq.regs['ext'] = {'gdpr': 1};
}
if ((typeof bidderRequest.gdprConsent.consentString === 'string') && bidderRequest.gdprConsent.consentString) {
rtbReq['user'] = {'ext': {'consent': bidderRequest.gdprConsent.consentString}};
}
}

if (req.params.test) {
rtbReq.test = 1;
}
Expand Down
28 changes: 28 additions & 0 deletions test/spec/modules/arteebeeBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,34 @@ describe('Arteebee adapater', () => {
expect(req).to.not.have.property('test');
expect(req.imp[0]).to.not.have.property('secure');
});

it('test gdpr', () => {
let bid = {
bidder: 'arteebee',
params: {
pub: 'prebidtest',
source: 'prebidtest'
},
sizes: [[300, 250]]
};
let consentString = 'ABCD';
let bidderRequest = {
'gdprConsent': {
consentString: consentString,
gdprApplies: true
}
};

const req = JSON.parse(spec.buildRequests([bid], bidderRequest)[0].data);

expect(req.regs).to.exist;
expect(req.regs.ext).to.exist;
expect(req.regs.ext).to.have.property('gdpr', 1);

expect(req.user).to.exist;
expect(req.user.ext).to.exist;
expect(req.user.ext).to.have.property('consent', consentString);
});
});

describe('Test interpret response', () => {
Expand Down

0 comments on commit 4bde2a1

Please sign in to comment.