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

EbdrAdapter add usersync #2407

Merged
merged 11 commits into from
Apr 17, 2018
18 changes: 18 additions & 0 deletions modules/ebdrBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,24 @@ export const spec = {
ebdrResponseImps.push(response);
});
return ebdrResponseImps;
},
getUserSyncs: function(syncOptions, serverResponses) {
const syncs = []
if (syncOptions.pixelEnabled) {
const ebdrResponseObj = serverResponses.body;
if (!ebdrResponseObj || !ebdrResponseObj.seatbid || ebdrResponseObj.seatbid.length === 0 || !ebdrResponseObj.seatbid[0].bid || ebdrResponseObj.seatbid[0].bid.length === 0) {
return [];
}
ebdrResponseObj.seatbid[0].bid.forEach(ebdrBid => {
if (ebdrBid.iurl && ebdrBid.iurl.length > 0) {
syncs.push({
type: 'image',
url: ebdrBid.iurl
});
}
});
}
return syncs;
}
}
function getWidthAndHeight(bid) {
Expand Down
26 changes: 26 additions & 0 deletions test/spec/modules/ebdrBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,30 @@ describe('ebdrBidAdapter', () => {
});
});
});
describe('spec.getUserSyncs', () => {
let syncOptions
beforeEach(() => {
syncOptions = {
enabledBidders: ['ebdr'], // only these bidders are allowed to sync
pixelEnabled: true
}
});
it('sucess with usersync url', () => {
const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '<div><img src="http://cdnin.bnmla.com/0b1c6e85e9376e3092df8c9fc8ab9095.gif" width=350 height=250 /></div>', adomain: ['advertiserdomain.com'], iurl: '//match.bnmla.com/usersync?sspid=59&redir=', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250};
const result = [];
result.push({type: 'image', url: '//match.bnmla.com/usersync?sspid=59&redir='});
expect(spec.getUserSyncs(syncOptions, { body: serverResponse })).to.deep.equal(result);
});

it('sucess without usersync url', () => {
const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '<div><img src="http://cdnin.bnmla.com/0b1c6e85e9376e3092df8c9fc8ab9095.gif" width=350 height=250 /></div>', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250};
const result = [];
expect(spec.getUserSyncs(syncOptions, { body: serverResponse })).to.deep.equal(result);
});
it('empty response', () => {
const serverResponse = {};
const result = [];
expect(spec.getUserSyncs(syncOptions, { body: serverResponse })).to.deep.equal(result);
});
});
});