Skip to content

Commit

Permalink
PulsePoint Adapter: Fixing issues related to Prebid 5.0 (#6857)
Browse files Browse the repository at this point in the history
  • Loading branch information
anand-venkatraman authored May 28, 2021
1 parent c04b024 commit 9c484c0
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 25 deletions.
26 changes: 23 additions & 3 deletions modules/pulsepointBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ function bidResponseAvailable(request, response) {
adId: id,
ttl: idToBidMap[id].exp || DEFAULT_BID_TTL,
netRevenue: DEFAULT_NET_REVENUE,
currency: bidResponse.cur || DEFAULT_CURRENCY
currency: bidResponse.cur || DEFAULT_CURRENCY,
meta: { advertiserDomains: idToBidMap[id].adomain || [] }
};
if (idToImpMap[id].video) {
// for outstream, a renderer is specified
Expand Down Expand Up @@ -154,7 +155,7 @@ function impression(slot) {
'native': nativeImpression(slot),
tagid: slot.params.ct.toString(),
video: video(slot),
bidfloor: slot.params.bidfloor,
bidfloor: bidFloor(slot),
ext: ext(slot),
};
}
Expand Down Expand Up @@ -192,7 +193,11 @@ function parseSizes(slot) {
*/
function video(slot) {
if (slot.params.video) {
return Object.assign({}, slot.params.video, {battr: slot.params.battr});
return Object.assign({},
slot.params.video, // previously supported as bidder param
slot.mediaTypes && slot.mediaTypes.video ? slot.mediaTypes.video : {}, // params on mediaTypes.video
{battr: slot.params.battr}
);
}
return null;
}
Expand Down Expand Up @@ -519,4 +524,19 @@ function nativeResponse(imp, bid) {
return null;
}

function bidFloor(slot) {
let floor = slot.params.bidfloor;
if (utils.isFn(slot.getFloor)) {
const floorData = slot.getFloor({
mediaType: slot.mediaTypes.banner ? 'banner' : slot.mediaTypes.video ? 'video' : 'Native',
size: '*',
currency: DEFAULT_CURRENCY,
});
if (floorData && floorData.floor) {
floor = floorData.floor;
}
}
return floor;
}

registerBidder(spec);
35 changes: 15 additions & 20 deletions modules/pulsepointBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,21 @@ Please use ```pulsepoint``` as the bidder code.
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'outstream'
context: 'outstream',
h: 300,
w: 400,
minduration: 1,
maxduration: 210,
linearity: 1,
mimes: ["video/mp4", "video/ogg", "video/webm"],
pos: 3
}
},
bids: [{
bidder: 'pulsepoint',
params: {
cp: 512379,
ct: 505642,
video: {
h: 300,
w: 400,
minduration: 1,
maxduration: 210,
linearity: 1,
mimes: ["video/mp4", "video/ogg", "video/webm"],
pos: 3
}
ct: 505642
}
}],
renderer: {
Expand All @@ -74,22 +72,19 @@ Please use ```pulsepoint``` as the bidder code.
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'instream'
context: 'instream',
h: 300,
w: 400,
minduration: 1,
maxduration: 210,
protocols: [2,3,5]
}
},
bids: [{
bidder: 'pulsepoint',
params: {
cp: 512379,
ct: 694973,
video: {
battr: [1,3],
h: 300,
w: 400,
minduration: 1,
maxduration: 210,
protocols: [2,3,5]
}
}
}]
}];
Expand Down
64 changes: 62 additions & 2 deletions test/spec/modules/pulsepointBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ describe('PulsePoint Adapter Tests', function () {
expect(bid.ttl).to.equal(20);
});

it('Verify ttl/currency applied to bid', function () {
it('Verify ttl/currency/adomain applied to bid', function () {
const request = spec.buildRequests(slotConfigs, bidderRequest);
const ortbRequest = request.data;
const ortbResponse = {
Expand All @@ -264,7 +264,8 @@ describe('PulsePoint Adapter Tests', function () {
price: 1.25,
adm: 'This is an Ad#1',
crid: 'Creative#123',
exp: 50
exp: 50,
adomain: ['advertiser.com']
}, {
impid: ortbRequest.imp[1].id,
price: 1.25,
Expand All @@ -282,11 +283,15 @@ describe('PulsePoint Adapter Tests', function () {
expect(bid.ad).to.equal('This is an Ad#1');
expect(bid.ttl).to.equal(50);
expect(bid.currency).to.equal('GBP');
expect(bid.meta).to.not.be.null;
expect(bid.meta.advertiserDomains).to.eql(['advertiser.com']);
const secondBid = bids[1];
expect(secondBid.cpm).to.equal(1.25);
expect(secondBid.ad).to.equal('This is an Ad#2');
expect(secondBid.ttl).to.equal(20);
expect(secondBid.currency).to.equal('GBP');
expect(secondBid.meta).to.not.be.null;
expect(secondBid.meta.advertiserDomains).to.eql([]);
});

it('Verify full passback', function () {
Expand Down Expand Up @@ -778,4 +783,59 @@ describe('PulsePoint Adapter Tests', function () {
const secondBid = bids[1];
expect(secondBid.vastXml).to.equal('<vast url="http://ad.com/video"></vast>');
});
it('Verify bid floor', function () {
const bidRequests = deepClone(slotConfigs);
bidRequests[0].params.bidfloor = 1.05;
let request = spec.buildRequests(bidRequests, bidderRequest);
let ortbRequest = request.data;
expect(ortbRequest).to.not.equal(null);
expect(ortbRequest.imp[0].bidfloor).to.equal(1.05);
expect(ortbRequest.imp[1].bidfloor).to.be.undefined;
let floorArg = null;
// publisher uses the floor module
bidRequests[0].getFloor = (arg) => {
floorArg = arg;
return { floor: 1.25 };
};
bidRequests[1].getFloor = () => {
return { floor: 2.05 };
};
request = spec.buildRequests(bidRequests, bidderRequest);
ortbRequest = request.data;
expect(ortbRequest).to.not.equal(null);
expect(ortbRequest.imp[0].bidfloor).to.equal(1.25);
expect(ortbRequest.imp[1].bidfloor).to.equal(2.05);
expect(floorArg).to.not.be.null;
expect(floorArg.mediaType).to.equal('banner');
expect(floorArg.currency).to.equal('USD');
expect(floorArg.size).to.equal('*');
});
it('Verify Video params on mediaTypes.video', function () {
const bidRequests = deepClone(videoSlotConfig);
bidRequests[0].mediaTypes = {
video: {
w: 600,
h: 400,
minduration: 15,
maxduration: 20,
startdelay: 10,
skip: 0,
}
};
const request = spec.buildRequests(bidRequests, bidderRequest);
const ortbRequest = request.data;
expect(ortbRequest).to.not.equal(null);
expect(ortbRequest.imp).to.have.lengthOf(1);
expect(ortbRequest.imp[0].video).to.not.be.null;
expect(ortbRequest.imp[0].native).to.be.null;
expect(ortbRequest.imp[0].banner).to.be.null;
expect(ortbRequest.imp[0].video.w).to.equal(600);
expect(ortbRequest.imp[0].video.h).to.equal(400);
expect(ortbRequest.imp[0].video.minduration).to.equal(15);
expect(ortbRequest.imp[0].video.maxduration).to.equal(20);
expect(ortbRequest.imp[0].video.startdelay).to.equal(10);
expect(ortbRequest.imp[0].video.skip).to.equal(0);
expect(ortbRequest.imp[0].video.minbitrate).to.equal(200);
expect(ortbRequest.imp[0].video.protocols).to.eql([1, 2, 4]);
});
});

0 comments on commit 9c484c0

Please sign in to comment.