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

EMX Digital Bid Adapter: floor module and advertiserDomain support #6805

Merged
merged 26 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e7cb062
adding ccpa support for emx_digital adapter
Dec 9, 2019
5c0cfc1
emx_digital ccpa compliance: lint fix
Dec 10, 2019
4c0a008
Merge branch 'master' of https://github.com/prebid/Prebid.js
Dec 17, 2019
676b419
emx 3.0 compliance update
Dec 17, 2019
36524b3
Merge branch 'master' of https://github.com/prebid/Prebid.js
ncolletti Jan 29, 2020
ec9f12f
Merge remote-tracking branch 'upstream/master'
Apr 22, 2020
9d96181
fix outstream renderer issue, update test spec
Apr 22, 2020
7a5fad2
sync with upstream
Apr 23, 2020
de685c9
Merge branch 'bug/EI-34'
Apr 23, 2020
b2d22a3
refactor formatVideoResponse function to use core-js/find
Apr 29, 2020
5b54a8c
Merge remote-tracking branch 'upstream/master'
DBogdanEMX Aug 15, 2020
29b8d20
Merge remote-tracking branch 'upstream/master'
Nov 9, 2020
aba7bb5
Merge remote-tracking branch 'upstream/master' into add_schain_forwar…
Nov 9, 2020
9be10ca
Add support for schain forwarding
Nov 9, 2020
080b2c7
Merge branch 'add_schain_forwarding'
Nov 9, 2020
09ec591
Merge remote-tracking branch 'upstream/master'
Nov 20, 2020
558a791
Resolved issue with Schain object location
Nov 20, 2020
734a72b
Merge remote-tracking branch 'upstream/master'
Dec 3, 2020
c33a070
Merge remote-tracking branch 'upstream/master'
rakeshbalakrishnan28 Dec 15, 2020
6a06e18
Merge remote-tracking branch 'upstream/master'
rakeshbalakrishnan28 Jan 19, 2021
b22ed51
Merge remote-tracking branch 'upstream/master'
rakeshbalakrishnan28 May 10, 2021
9f235e7
Merge remote-tracking branch 'upstream/master'
rakeshbalakrishnan28 May 11, 2021
ab197dc
Merge remote-tracking branch 'upstream/master'
rakeshbalakrishnan28 May 12, 2021
fc0ab49
prebid 5.0 floor module and advertiserDomain support
rakeshbalakrishnan28 May 19, 2021
372e1bb
Merge remote-tracking branch 'upstream/master'
rakeshbalakrishnan28 May 20, 2021
08dc8e2
Merge remote-tracking branch 'origin/prebid-5.0-support'
rakeshbalakrishnan28 May 20, 2021
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
28 changes: 27 additions & 1 deletion modules/emx_digitalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export const spec = {

utils._each(validBidRequests, function (bid) {
let tagid = utils.getBidIdParameter('tagid', bid.params);
let bidfloor = parseFloat(utils.getBidIdParameter('bidfloor', bid.params)) || 0;
let bidfloor = parseFloat(getBidFloor(bid)) || 0;
let isVideo = !!bid.mediaTypes.video;
let data = {
id: bid.bidId,
Expand Down Expand Up @@ -287,6 +287,14 @@ export const spec = {
bidResponse = emxAdapter.formatVideoResponse(bidResponse, Object.assign({}, emxBid), bidRequest);
}
bidResponse.mediaType = (isVideo ? VIDEO : BANNER);

// support for adomain in prebid 5.0
if (emxBid.adomain && emxBid.adomain.length) {
bidResponse.meta = {
advertiserDomains: emxBid.adomain
};
}

emxBidResponses.push(bidResponse);
});
}
Expand All @@ -312,4 +320,22 @@ export const spec = {
return syncs;
}
};

// support floors module in prebid 5.0
function getBidFloor(bid) {
if (!utils.isFn(bid.getFloor)) {
return parseFloat(utils.getBidIdParameter('bidfloor', bid.params));
}

let floor = bid.getFloor({
currency: DEFAULT_CUR,
mediaType: '*',
size: '*'
});
if (utils.isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'USD') {
return floor.floor;
}
return null;
}

registerBidder(spec);
52 changes: 45 additions & 7 deletions test/spec/modules/emx_digitalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,38 @@ describe('emx_digital Adapter', function () {
expect(queryParams[1]).to.match(new RegExp('^ts=\d*', 'g'));
});

it('builds with bid floor', function () {
const bidRequestWithBidFloor = utils.deepClone(bidderRequest.bids);
bidRequestWithBidFloor[0].params.bidfloor = 1;
const requestWithFloor = spec.buildRequests(bidRequestWithBidFloor, bidderRequest);
it('builds bidfloor value from bid param when getFloor function does not exist', function () {
const bidRequestWithFloor = utils.deepClone(bidderRequest.bids);
bidRequestWithFloor[0].params.bidfloor = 1;
const requestWithFloor = spec.buildRequests(bidRequestWithFloor, bidderRequest);
const data = JSON.parse(requestWithFloor.data);
expect(data.imp[0].bidfloor).to.equal(bidRequestWithBidFloor[0].params.bidfloor);
expect(data.imp[0].bidfloor).to.equal(bidRequestWithFloor[0].params.bidfloor);
});

it('builds bidfloor value from getFloor function when it exists', function () {
const floorResponse = { currency: 'USD', floor: 3 };
const bidRequestWithGetFloor = utils.deepClone(bidderRequest.bids);
bidRequestWithGetFloor[0].getFloor = () => floorResponse;
const requestWithGetFloor = spec.buildRequests(bidRequestWithGetFloor, bidderRequest);
const data = JSON.parse(requestWithGetFloor.data);
expect(data.imp[0].bidfloor).to.equal(3);
});

it('builds bidfloor value from getFloor when both floor and getFloor function exists', function () {
const floorResponse = { currency: 'USD', floor: 3 };
const bidRequestWithBothFloors = utils.deepClone(bidderRequest.bids);
bidRequestWithBothFloors[0].params.bidfloor = 1;
bidRequestWithBothFloors[0].getFloor = () => floorResponse;
const requestWithBothFloors = spec.buildRequests(bidRequestWithBothFloors, bidderRequest);
const data = JSON.parse(requestWithBothFloors.data);
expect(data.imp[0].bidfloor).to.equal(3);
});

it('empty bidfloor value when floor and getFloor is not defined', function () {
const bidRequestWithoutFloor = utils.deepClone(bidderRequest.bids);
const requestWithoutFloor = spec.buildRequests(bidRequestWithoutFloor, bidderRequest);
const data = JSON.parse(requestWithoutFloor.data);
expect(data.imp[0].bidfloor).to.not.exist;
});

it('builds request properly', function () {
Expand Down Expand Up @@ -470,7 +496,8 @@ describe('emx_digital Adapter', function () {
'id': '987654321cba',
'price': 0.5,
'ttl': 300,
'w': 300
'w': 300,
'adomain': ['example.com']
}],
'seat': '1356'
}, {
Expand Down Expand Up @@ -498,7 +525,10 @@ describe('emx_digital Adapter', function () {
'netRevneue': true,
'mediaType': 'banner',
'ad': '<!-- Creative -->',
'ttl': 300
'ttl': 300,
'meta': {
'advertiserDomains': ['example.com']
}
}, {
'requestId': '12819a18-56e1-4256-b836-b69a10202668',
'cpm': 0.7,
Expand Down Expand Up @@ -630,6 +660,14 @@ describe('emx_digital Adapter', function () {
body: badAdmServerResponse
}));
});

it('returns valid advertiser domain', function () {
const bidResponse = utils.deepClone(serverResponse);
let result = spec.interpretResponse({body: bidResponse});
expect(result[0].meta.advertiserDomains).to.deep.equal(expectedResponse[0].meta.advertiserDomains);
// case where adomains are not in request
expect(result[1].meta).to.not.exist;
});
});

describe('getUserSyncs', function () {
Expand Down