Skip to content

Commit

Permalink
No bid version 1.2.9 (#5794)
Browse files Browse the repository at this point in the history
* Enable supplyChain support

* Added support for COPPA

* rebuilt

* Added support for Extended User IDs.

Co-authored-by: Reda Guermas <reda.guermas@nobid.io>
  • Loading branch information
redaguermas and Reda Guermas authored Nov 9, 2020
1 parent 7efc333 commit 83279da
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
21 changes: 20 additions & 1 deletion modules/nobidBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getStorageManager } from '../src/storageManager.js';

const storage = getStorageManager();
const BIDDER_CODE = 'nobid';
window.nobidVersion = '1.2.8';
window.nobidVersion = '1.2.9';
window.nobid = window.nobid || {};
window.nobid.bidResponses = window.nobid.bidResponses || {};
window.nobid.timeoutTotal = 0;
Expand Down Expand Up @@ -114,6 +114,23 @@ function nobidBuildRequests(bids, bidderRequest) {
utils.logWarn('Could not parse screen dimensions, error details:', e);
}
}
var getEIDs = function(eids) {
if (utils.isArray(eids) && eids.length > 0) {
let src = [];
eids.forEach((eid) => {
let ids = [];
if (eid.uids) {
eid.uids.forEach(value => {
ids.push({'id': value.id + ''});
});
}
if (eid.source && ids.length > 0) {
src.push({source: eid.source, uids: ids});
}
});
return src;
}
}
var state = {};
state['sid'] = siteId;
state['l'] = topLocation(bidderRequest);
Expand All @@ -131,6 +148,8 @@ function nobidBuildRequests(bids, bidderRequest) {
if (sch) state['schain'] = sch;
const cop = coppa();
if (cop) state['coppa'] = cop;
const eids = getEIDs(utils.deepAccess(bids, '0.userIdAsEids'));
if (eids && eids.length > 0) state['eids'] = eids;
return state;
}
function newAdunit(adunitObject, adunits) {
Expand Down
69 changes: 69 additions & 0 deletions test/spec/modules/nobidBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,75 @@ describe('Nobid Adapter', function () {
});
});

describe('buildRequestsEIDs', function () {
const SITE_ID = 2;
const REFERER = 'https://www.examplereferer.com';
let bidRequests = [
{
'bidder': 'nobid',
'params': {
'siteId': SITE_ID
},
'adUnitCode': 'adunit-code',
'sizes': [[300, 250]],
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'userIdAsEids': [
{
'source': 'criteo.com',
'uids': [
{
'id': 'CRITEO_ID',
'atype': 1
}
]
},
{
'source': 'id5-sync.com',
'uids': [
{
'id': 'ID5_ID',
'atype': 1
}
],
'ext': {
'linkType': 0
}
},
{
'source': 'adserver.org',
'uids': [
{
'id': 'TD_ID',
'atype': 1,
'ext': {
'rtiPartner': 'TDID'
}
}
]
}
]
}
];

let bidderRequest = {
refererInfo: {referer: REFERER}
}

it('should criteo eid', function () {
const request = spec.buildRequests(bidRequests, bidderRequest);
const payload = JSON.parse(request.data);
expect(payload.sid).to.exist.and.to.equal(2);
expect(payload.eids[0].source).to.exist.and.to.equal('criteo.com');
expect(payload.eids[0].uids[0].id).to.exist.and.to.equal('CRITEO_ID');
expect(payload.eids[1].source).to.exist.and.to.equal('id5-sync.com');
expect(payload.eids[1].uids[0].id).to.exist.and.to.equal('ID5_ID');
expect(payload.eids[2].source).to.exist.and.to.equal('adserver.org');
expect(payload.eids[2].uids[0].id).to.exist.and.to.equal('TD_ID');
});
});

describe('buildRequests', function () {
const SITE_ID = 2;
const REFERER = 'https://www.examplereferer.com';
Expand Down

0 comments on commit 83279da

Please sign in to comment.