Skip to content

Commit

Permalink
reads and sends bidFloor when available
Browse files Browse the repository at this point in the history
  • Loading branch information
sangarbe committed Sep 27, 2024
1 parent 44b2a46 commit 3375189
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
21 changes: 21 additions & 0 deletions modules/seedtagBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ const deviceConnection = {
UNKNOWN: 'unknown',
};

export const BIDFLOOR_CURRENCY = 'USD'

function getBidFloor(bidRequest) {
let floorInfo = {};

if (typeof bidRequest.getFloor === 'function') {
floorInfo = bidRequest.getFloor({
currency: BIDFLOOR_CURRENCY,
mediaType: '*',
size: '*'
});
}

return floorInfo.floor;
}

const getConnectionType = () => {
const connection =
navigator.connection ||
Expand Down Expand Up @@ -133,6 +149,11 @@ function buildBidRequest(validBidRequest) {
bidRequest.videoParams = getVideoParams(validBidRequest);
}

const bidFloor = getBidFloor(validBidRequest)
if (bidFloor) {
bidRequest.bidFloor = bidFloor;
}

return bidRequest;
}

Expand Down
16 changes: 16 additions & 0 deletions test/spec/modules/seedtagBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getTimeoutUrl, spec } from 'modules/seedtagBidAdapter.js';
import * as utils from 'src/utils.js';
import * as mockGpt from 'test/spec/integration/faker/googletag.js';
import { config } from '../../../src/config.js';
import { BIDFLOOR_CURRENCY } from '../../../modules/seedtagBidAdapter.js';

const PUBLISHER_ID = '0000-0000-01';
const ADUNIT_ID = '000000';
Expand Down Expand Up @@ -253,6 +254,7 @@ describe('Seedtag Adapter', function () {
});

describe('buildRequests method', function () {
const bidFloor = 0.60
const bidderRequest = {
refererInfo: { page: 'referer' },
timeout: 1000,
Expand Down Expand Up @@ -280,6 +282,11 @@ describe('Seedtag Adapter', function () {
mandatoryVideoParams
),
];
validBidRequests[0].getFloor = () => ({
currency: BIDFLOOR_CURRENCY,
floor: bidFloor
})

it('Url params should be correct ', function () {
const request = spec.buildRequests(validBidRequests, bidderRequest);
expect(request.method).to.equal('POST');
Expand Down Expand Up @@ -426,6 +433,15 @@ describe('Seedtag Adapter', function () {
expect(bannerBid).to.not.have.property('geom')
}
})

it('should have bidfloor parameter if available', function() {
const request = spec.buildRequests(validBidRequests, bidderRequest);
const data = JSON.parse(request.data);
const bidRequests = data.bidRequests;

expect(bidRequests[0].bidFloor).to.be.equal(bidFloor)
expect(bidRequests[1]).not.to.have.property('bidFloor')
})
});

describe('COPPA param', function () {
Expand Down

0 comments on commit 3375189

Please sign in to comment.