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

Price Floors: use standard cpmAdjustment #6194

Merged
merged 2 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion modules/priceFloors.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function generatePossibleEnumerations(arrayOfFields, delimiter) {
* @summary If a the input bidder has a registered cpmadjustment it returns the input CPM after being adjusted
*/
export function getBiddersCpmAdjustment(bidderName, inputCpm, bid = {}) {
const adjustmentFunction = utils.deepAccess(getGlobal(), `bidderSettings.${bidderName}.bidCpmAdjustment`);
const adjustmentFunction = utils.deepAccess(getGlobal(), `bidderSettings.${bidderName}.bidCpmAdjustment`) || utils.deepAccess(getGlobal(), 'bidderSettings.standard.bidCpmAdjustment');
if (adjustmentFunction) {
return parseFloat(adjustmentFunction(inputCpm, {...bid, cpm: inputCpm}));
}
Expand Down
35 changes: 35 additions & 0 deletions test/spec/modules/priceFloors_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,41 @@ describe('the price floors module', function () {
floor: 1.3334 // 1.3334 * 0.75 = 1.000005 which is the floor (we cut off getFloor at 4 decimal points)
});
});

it('should use standard cpmAdjustment if no bidder cpmAdjustment', function () {
getGlobal().bidderSettings = {
rubicon: {
bidCpmAdjustment: function (bidCpm, bidResponse) {
return bidResponse.cpm * 0.5;
},
},
standard: {
bidCpmAdjustment: function (bidCpm, bidResponse) {
return bidResponse.cpm * 0.75;
},
}
};
_floorDataForAuction[bidRequest.auctionId] = utils.deepClone(basicFloorConfig);
_floorDataForAuction[bidRequest.auctionId].data.values = { '*': 1.0 };
let appnexusBid = {
...bidRequest,
bidder: 'appnexus'
};

// the conversion should be what the bidder would need to return in order to match the actual floor
// rubicon
expect(bidRequest.getFloor()).to.deep.equal({
currency: 'USD',
floor: 2.0 // a 2.0 bid after rubicons cpm adjustment would be 1.0 and thus is the floor after adjust
});

// appnexus
expect(appnexusBid.getFloor()).to.deep.equal({
currency: 'USD',
floor: 1.3334 // 1.3334 * 0.75 = 1.000005 which is the floor (we cut off getFloor at 4 decimal points)
});
});

it('should work when cpmAdjust function uses bid object', function () {
getGlobal().bidderSettings = {
rubicon: {
Expand Down