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

Replace id5 parameter with new eids parameter #5

Closed
wants to merge 2 commits into from
Closed
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
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