Skip to content

Commit

Permalink
Seedtag Bid Adapter: reads and sends bidFloor when available (#12277)
Browse files Browse the repository at this point in the history
* reads and sends bidFloor when available

* fixes seedtag adapter jsdoc
  • Loading branch information
sangarbe authored Oct 1, 2024
1 parent fd79aaa commit 30f0d80
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
30 changes: 27 additions & 3 deletions modules/seedtagBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { _map, isArray, triggerPixel } from '../src/utils.js';
* @typedef {import('../src/adapters/bidderFactory.js').SyncOptions} SyncOptions
* @typedef {import('../src/adapters/bidderFactory.js').UserSync} UserSync
* @typedef {import('../src/adapters/bidderFactory.js').validBidRequests} validBidRequests
* @typedef {import('../src/adapters/bidderFactory.js').bidderRequest} bidderRequest
* @typedef {import('../src/adapters/bidderFactory.js').TimedOutBid} TimedOutBid
*/

const BIDDER_CODE = 'seedtag';
Expand Down Expand Up @@ -38,6 +40,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 +151,11 @@ function buildBidRequest(validBidRequest) {
bidRequest.videoParams = getVideoParams(validBidRequest);
}

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

return bidRequest;
}

Expand Down Expand Up @@ -271,7 +294,8 @@ export const spec = {
/**
* Make a server request from the list of BidRequests.
*
* @param {validBidRequests[]} - an array of bids
* @param {validBidRequests[]} validBidRequests an array of bids
* @param {bidderRequest} bidderRequest an array of bids
* @return ServerRequest Info describing the request to the server.
*/
buildRequests(validBidRequests, bidderRequest) {
Expand Down Expand Up @@ -395,7 +419,7 @@ export const spec = {

/**
* Register bidder specific code, which will execute if bidder timed out after an auction
* @param {data} Containing timeout specific data
* @param {TimedOutBid} data Containing timeout specific data
*/
onTimeout(data) {
const url = getTimeoutUrl(data);
Expand All @@ -404,7 +428,7 @@ export const spec = {

/**
* Function to call when the adapter wins the auction
* @param {bid} Bid information received from the server
* @param {Bid} bid The bid information received from the server
*/
onBidWon: function (bid) {
if (bid && bid.nurl) {
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 30f0d80

Please sign in to comment.