Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arteebee adapter GDPR integration #2643

Merged
merged 17 commits into from
May 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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