Skip to content

Commit

Permalink
Adhese Bid Adapter: replace id5 with eid (#6339)
Browse files Browse the repository at this point in the history
  • Loading branch information
mefjush committed Feb 23, 2021
1 parent 13230f0 commit f2e0b38
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
18 changes: 11 additions & 7 deletions modules/adheseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export const spec = {

const gdprParams = (gdprConsent && gdprConsent.consentString) ? { xt: [gdprConsent.consentString] } : {};
const refererParams = (refererInfo && refererInfo.referer) ? { xf: [base64urlEncode(refererInfo.referer)] } : {};
const id5Params = (getId5Id(validBidRequests)) ? { x5: [getId5Id(validBidRequests)] } : {};
const commonParams = { ...gdprParams, ...refererParams, ...id5Params };
const commonParams = { ...gdprParams, ...refererParams };

const slots = validBidRequests.map(bid => ({
slotname: bidToSlotName(bid),
Expand All @@ -34,8 +33,13 @@ export const spec = {

const payload = {
slots: slots,
parameters: commonParams
}
parameters: commonParams,
user: {
ext: {
eids: getEids(validBidRequests),
}
}
};

const account = getAccount(validBidRequests);
const uri = 'https://ads-' + account + '.adhese.com/json';
Expand Down Expand Up @@ -154,9 +158,9 @@ function getAccount(validBidRequests) {
return validBidRequests[0].params.account;
}

function getId5Id(validBidRequests) {
if (validBidRequests[0] && validBidRequests[0].userId && validBidRequests[0].userId.id5id && validBidRequests[0].userId.id5id.uid) {
return validBidRequests[0].userId.id5id.uid;
function getEids(validBidRequests) {
if (validBidRequests[0] && validBidRequests[0].userIdAsEids) {
return validBidRequests[0].userIdAsEids;
}
}

Expand Down
18 changes: 13 additions & 5 deletions test/spec/modules/adheseBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ let minimalBid = function() {
}
};

let bidWithParams = function(data, userId) {
let bidWithParams = function(data) {
let bid = minimalBid();
bid.params.data = data;
bid.userId = userId;
return bid;
};

Expand Down Expand Up @@ -117,10 +116,19 @@ describe('AdheseAdapter', function () {
expect(JSON.parse(req.data).parameters).to.deep.include({ 'xf': [ 'aHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc3ViamVjdHM_X2Q9MQ' ] });
});

it('should include id5 id as /x5 param', function () {
let req = spec.buildRequests([ bidWithParams({}, { 'id5id': { 'uid': 'ID5-1234567890' } }) ], bidderRequest);
it('should include eids', function () {
let bid = minimalBid();
bid.userIdAsEids = [{ source: 'id5-sync.com', uids: [{ id: 'ID5@59sigaS-...' }] }];

let req = spec.buildRequests([ bid ], bidderRequest);

expect(JSON.parse(req.data).user.ext.eids).to.deep.equal(bid.userIdAsEids);
});

it('should not include eids field when userid module disabled', function () {
let req = spec.buildRequests([ minimalBid() ], bidderRequest);

expect(JSON.parse(req.data).parameters).to.deep.include({ 'x5': [ 'ID5-1234567890' ] });
expect(JSON.parse(req.data)).to.not.have.key('eids');
});

it('should include bids', function () {
Expand Down

0 comments on commit f2e0b38

Please sign in to comment.