Skip to content

PulsePoint bid adapter: Multi-size support #4988

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

Merged
merged 42 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2fba6a2
ET-1691: Pulsepoint Analytics adapter for Prebid. (#1)
anand-venkatraman Oct 14, 2016
ca17acb
Merge remote-tracking branch 'upstream/master'
anand-venkatraman Oct 25, 2016
5da43c3
Adding bidRequest to bidFactory.createBid method as per https://githu…
anand-venkatraman Oct 25, 2016
cf41114
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Nov 8, 2016
62756a9
ET-1765: Adding support for additional params in PulsePoint adapter (#2)
anand-venkatraman Nov 9, 2016
f8fabb7
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Dec 8, 2016
b9af15c
ET-1850: Fixing https://github.com/prebid/Prebid.js/issues/866
anand-venkatraman Dec 8, 2016
6523c25
Merge pull request #3 from pulsepointinc/ET-1850
anand-venkatraman Dec 8, 2016
b5eeb7f
Minor fix
anand-venkatraman Dec 8, 2016
0f33ef5
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Mar 1, 2017
b5dbd34
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Jun 27, 2017
d6fcd11
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Jul 17, 2017
fce16ad
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Aug 15, 2017
9833867
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Sep 22, 2017
70924c5
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Oct 12, 2017
41f4aca
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Nov 13, 2017
aae98a7
Adding mandatory parameters to Bid
anand-venkatraman Nov 13, 2017
6d546ed
Merge from upstream
anand-venkatraman Nov 27, 2017
a04a18f
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Mar 7, 2018
467e9e3
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Apr 20, 2018
af1b3db
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Apr 30, 2018
a438b67
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman May 4, 2018
e2fa8c3
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman May 21, 2018
6db9eb4
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman May 22, 2018
92a6034
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman May 29, 2018
2195429
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Jan 21, 2019
c0e32d5
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman May 18, 2019
832976a
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman May 30, 2019
b780838
Merge branch 'master' of github.com:prebid/Prebid.js
anand-venkatraman Jun 19, 2019
07ccd3d
Merge branch 'master' of github.com:prebid/Prebid.js
anand-venkatraman Jul 10, 2019
8b5815f
Merge branch 'master' of github.com:prebid/Prebid.js
anand-venkatraman Jul 15, 2019
3d0dcc2
Merge branch 'master' of github.com:prebid/Prebid.js
anand-venkatraman Oct 1, 2019
4f24443
Merge branch 'master' of github.com:prebid/Prebid.js
anand-venkatraman Oct 30, 2019
cf94b55
Merge branch 'master' of github.com:prebid/Prebid.js
anand-venkatraman Oct 31, 2019
ac055d1
Merge branch 'master' of github.com:prebid/Prebid.js
anand-venkatraman Nov 7, 2019
66a991b
Merge branch 'master' of github.com:prebid/Prebid.js
anand-venkatraman Dec 9, 2019
4436d00
Merge branch 'master' of github.com:prebid/Prebid.js
anand-venkatraman Jan 23, 2020
7d3b19d
Merge branch 'master' of github.com:prebid/Prebid.js
anand-venkatraman Mar 13, 2020
48f1bb9
PulsePoint: support for banner.format object
anand-venkatraman Mar 13, 2020
f1ae8b5
AdSize on response for banner responses
anand-venkatraman Mar 16, 2020
2a5ed9c
Fixing review comment
anand-venkatraman Mar 16, 2020
9bd11db
Reverting package-json changes
anand-venkatraman Mar 16, 2020
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
26 changes: 22 additions & 4 deletions modules/pulsepointBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ function bidResponseAvailable(request, response) {
bid.height = idToBidMap[id].h;
} else {
bid.ad = idToBidMap[id].adm;
bid.width = idToImpMap[id].banner.w;
bid.height = idToImpMap[id].banner.h;
bid.width = idToBidMap[id].w || idToImpMap[id].banner.w;
bid.height = idToBidMap[id].h || idToImpMap[id].banner.h;
}
bids.push(bid);
}
Expand All @@ -161,14 +161,30 @@ function impression(slot) {
* Produces an OpenRTB Banner object for the slot given.
*/
function banner(slot) {
const size = adSize(slot);
const sizes = parseSizes(slot);
const size = adSize(slot, sizes);
return (slot.nativeParams || slot.params.video) ? null : {
w: size[0],
h: size[1],
battr: slot.params.battr,
format: sizes
};
}

/**
* Produce openrtb format objects based on the sizes configured for the slot.
*/
function parseSizes(slot) {
const sizes = utils.deepAccess(slot, 'mediaTypes.banner.sizes');
if (sizes && utils.isArray(sizes)) {
return sizes.filter(sz => utils.isArray(sz) && sz.length === 2).map(sz => ({
w: sz[0],
h: sz[1]
}));
}
return null;
}

/**
* Produces an OpenRTB Video object for the slot given
*/
Expand Down Expand Up @@ -372,12 +388,14 @@ function parse(rawResponse) {
/**
* Determines the AdSize for the slot.
*/
function adSize(slot) {
function adSize(slot, sizes) {
if (slot.params.cf) {
const size = slot.params.cf.toUpperCase().split('X');
const width = parseInt(slot.params.cw || size[0], 10);
const height = parseInt(slot.params.ch || size[1], 10);
return [width, height];
} else if (sizes && sizes.length > 0) {
return [sizes[0].w, sizes[0].h];
}
return [1, 1];
}
Expand Down
46 changes: 46 additions & 0 deletions test/spec/modules/pulsepointBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import {deepClone} from 'src/utils.js';
describe('PulsePoint Adapter Tests', function () {
const slotConfigs = [{
placementCode: '/DfpAccount1/slot1',
mediaTypes: {
banner: {
sizes: [[728, 90], [160, 600]]
}
},
bidId: 'bid12345',
params: {
cp: 'p10000',
Expand Down Expand Up @@ -655,4 +660,45 @@ describe('PulsePoint Adapter Tests', function () {
userVerify(ortbRequest.user.ext.eids[4], 'parrable.com', 'parrable_id234');
userVerify(ortbRequest.user.ext.eids[5], 'liveintent.com', 'liveintent_id123');
});
it('Verify multiple adsizes', function () {
const bidRequests = deepClone(slotConfigs);
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request).to.be.not.null;
expect(request.data).to.be.not.null;
const ortbRequest = request.data;
expect(ortbRequest.imp).to.have.lengthOf(2);
// first impression has multi sizes
expect(ortbRequest.imp[0].banner).to.not.be.null;
expect(ortbRequest.imp[0].banner.w).to.equal(300);
expect(ortbRequest.imp[0].banner.h).to.equal(250);
expect(ortbRequest.imp[0].banner.format).to.not.be.null;
expect(ortbRequest.imp[0].banner.format).to.have.lengthOf(2);
expect(ortbRequest.imp[0].banner.format[0].w).to.equal(728);
expect(ortbRequest.imp[0].banner.format[0].h).to.equal(90);
expect(ortbRequest.imp[0].banner.format[1].w).to.equal(160);
expect(ortbRequest.imp[0].banner.format[1].h).to.equal(600);
// slot 2
expect(ortbRequest.imp[1].banner).to.not.be.null;
expect(ortbRequest.imp[1].banner.w).to.equal(728);
expect(ortbRequest.imp[1].banner.h).to.equal(90);
expect(ortbRequest.imp[1].banner.format).to.be.null;
// adsize on response
const ortbResponse = {
seatbid: [{
bid: [{
impid: ortbRequest.imp[0].id,
price: 1.25,
adm: 'This is an Ad',
crid: 'Creative#123',
w: 728,
h: 90
}]
}]
};
const bids = spec.interpretResponse({ body: ortbResponse }, request);
expect(bids).to.have.lengthOf(1);
const bid = bids[0];
expect(bid.width).to.equal(728);
expect(bid.height).to.equal(90);
});
});