Skip to content

Onetag Bid Adapter: fix the priceFloor size field format #13415

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 2 commits into from
Jun 24, 2025
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
30 changes: 15 additions & 15 deletions modules/onetagBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ function getPageInfo(bidderRequest) {
timing: getTiming(),
version: {
prebid: '$prebid.version$',
adapter: '1.1.3'
adapter: '1.1.4'
}
};
}
Expand Down Expand Up @@ -476,23 +476,23 @@ function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent, gpp

function getBidFloor(bidRequest, mediaType, sizes) {
if (typeof bidRequest.getFloor !== 'function') return [];
const getFloorObject = (size) => {
const floorData = bidRequest.getFloor({
currency: 'EUR',
mediaType: mediaType || '*',
size: size || '*'
}) || {};

return {
...floorData,
size: size ? deepClone(size) : undefined,
floor: floorData.floor != null ? floorData.floor : null
};
const getFloorObject = (size) => {
const floorData = bidRequest.getFloor({
currency: 'EUR',
mediaType: mediaType || '*',
size: size || null
}) || {};

return {
...floorData,
size: size && size.length == 2 ? {width: size[0], height: size[1]} : null,
floor: floorData.floor != null ? floorData.floor : null
};
};

if (Array.isArray(sizes) && sizes.length > 0) {
return sizes.map(size => getFloorObject([size.width, size.height]));
}
return [getFloorObject('*')];
} return [getFloorObject(null)];
}

export function isSchainValid(schain) {
Expand Down
109 changes: 108 additions & 1 deletion test/spec/modules/onetagBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ import { hasTypeNative } from '../../../modules/onetagBidAdapter';

const NATIVE_SUFFIX = 'Ad';

const getFloor = function(params) {
let floorPrice = 0.0001;
switch (params.mediaType) {
case BANNER:
floorPrice = 1.0;
break;
case VIDEO:
floorPrice = 2.0;
break;
case INSTREAM:
floorPrice = 3.0;
break;
case OUTSTREAM:
floorPrice = 4.0;
break;
case NATIVE:
floorPrice = 5.0;
break;
}
return {currency: params.currency, floor: floorPrice};
};

describe('onetag', function () {
function createBid() {
return {
Expand Down Expand Up @@ -84,6 +106,17 @@ describe('onetag', function () {
bid.mediaTypes.native = {};
bid.mediaTypes.native.adTemplate = bid.nativeParams.adTemplate;
bid.mediaTypes.native.ortb = ortbConversion;
bid.floors = {
currency: 'EUR',
schema: {
delimiter: '|',
fields: [ 'mediaType', 'size' ]
},
values: {
'native|*': 1.10
}
}
bid.getFloor = getFloor;
return bid;
}

Expand All @@ -106,7 +139,7 @@ describe('onetag', function () {
assets: [{
id: 1,
required: 1,
title: {
title: {
len: 140
}
},
Expand Down Expand Up @@ -142,6 +175,19 @@ describe('onetag', function () {
}]
}
};

bid.floors = {
currency: 'EUR',
schema: {
delimiter: '|',
fields: [ 'mediaType', 'size' ]
},
values: {
'native|*': 1.10
}
}
bid.getFloor = getFloor;

return bid;
}

Expand All @@ -151,6 +197,18 @@ describe('onetag', function () {
bid.mediaTypes.banner = {
sizes: [[300, 250]]
};
bid.floors = {
currency: 'EUR',
schema: {
delimiter: '|',
fields: [ 'mediaType', 'size' ]
},
values: {
'banner|300x250': 0.10
}
}
bid.getFloor = getFloor;

return bid;
}

Expand All @@ -162,6 +220,17 @@ describe('onetag', function () {
mimes: ['video/mp4', 'video/webm', 'application/javascript', 'video/ogg'],
playerSize: [640, 480]
};
bid.floors = {
currency: 'EUR',
schema: {
delimiter: '|',
fields: [ 'mediaType', 'size' ]
},
values: {
'video|640x480': 0.10
}
}
bid.getFloor = getFloor;
return bid;
}

Expand All @@ -173,6 +242,17 @@ describe('onetag', function () {
mimes: ['video/mp4', 'video/webm', 'application/javascript', 'video/ogg'],
playerSize: [640, 480]
};
bid.floors = {
currency: 'EUR',
schema: {
delimiter: '|',
fields: [ 'mediaType', 'size' ]
},
values: {
'video|640x480': 0.10
}
}
bid.getFloor = getFloor;
return bid;
}

Expand Down Expand Up @@ -483,6 +563,33 @@ describe('onetag', function () {
}
expect(bid.bidId).to.be.a('string');
expect(bid.pubId).to.be.a('string');
expect(bid.priceFloors).to.be.an('array');
expect(bid.priceFloors).to.satisfy(function (priceFloors) {
if (priceFloors.length === 0) {
return true;
}
return priceFloors.every(function (priceFloor) {
expect(priceFloor).to.have.all.keys('currency', 'floor', 'size');
expect(priceFloor.currency).to.be.a('string');
expect(priceFloor.floor).to.be.a('number');
expect(priceFloor.size).to.satisfy(function (size) {
if (typeof size !== 'object' && size !== null && typeof size !== 'undefined') {
return false;
}
if (size !== null) {
const keys = Object.keys(size);
if (keys.length == 0) {
return true;
}
expect(size).to.have.keys('width', 'height');
expect(size.width).to.be.a('number');
expect(size.height).to.be.a('number');
}
return true;
});
return true;
});
});
}
});
it('Returns empty data if no valid requests are passed', function () {
Expand Down