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

Vox Bid Addapter: add schain, floors, userid support #10109

Merged
merged 5 commits into from
Jul 10, 2023
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
21 changes: 16 additions & 5 deletions modules/voxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,31 @@ import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {find} from '../src/polyfill.js';
import {auctionManager} from '../src/auctionManager.js';
import {Renderer} from '../src/Renderer.js';
import {config} from '../src/config.js'

const { getConfig } = config;

const BIDDER_CODE = 'vox';
const SSP_ENDPOINT = 'https://ssp.hybrid.ai/auction/prebid';
const VIDEO_RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js';
const TTL = 60;

function buildBidRequests(validBidRequests) {
return _map(validBidRequests, function(validBidRequest) {
const params = validBidRequest.params;
return _map(validBidRequests, function(bid) {
const currency = getConfig('currency.adServerCurrency');
const floorInfo = bid.getFloor ? bid.getFloor({
currency: currency || 'USD'
}) : {};

const params = bid.params;
const bidRequest = {
bidId: validBidRequest.bidId,
floorInfo,
schain: bid.schain,
userId: bid.userId,
bidId: bid.bidId,
// TODO: fix transactionId leak: https://github.com/prebid/Prebid.js/issues/9781
transactionId: validBidRequest.transactionId,
sizes: validBidRequest.sizes,
transactionId: bid.transactionId,
sizes: bid.sizes,
placement: params.placement,
placeId: params.placementId,
imageUrl: params.imageUrl
Expand Down
93 changes: 93 additions & 0 deletions test/spec/modules/voxBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from 'chai'
import { spec } from 'modules/voxBidAdapter.js'
import {config} from 'src/config.js'

function getSlotConfigs(mediaTypes, params) {
return {
Expand Down Expand Up @@ -175,6 +176,98 @@ describe('VOX Adapter', function() {
expect(bid.transactionId).to.equal('31a58515-3634-4e90-9c96-f86196db1459')
})
})
it('should not set userid if not specified', function () {
const request = spec.buildRequests(validBidRequests, bidderRequest)
const data = JSON.parse(request.data)
data.bidRequests.forEach(bid => {
expect(bid.userId).to.be.undefined
})
})

it('should set userid if specified', function () {
const requests = validBidRequests.map(bid => ({
...bid,
userId: {
tdid: 'TDID_USER_ID',
pubcid: 'PUBID_USER_ID'
}
}))
const request = spec.buildRequests(requests, bidderRequest)
const data = JSON.parse(request.data)
data.bidRequests.forEach(bid => {
expect(bid.userId.tdid).to.equal('TDID_USER_ID')
expect(bid.userId.pubcid).to.equal('PUBID_USER_ID')
})
})

it('should not set schain if not specified', function () {
const request = spec.buildRequests(validBidRequests, bidderRequest)
const data = JSON.parse(request.data)
data.bidRequests.forEach(bid => {
expect(bid.schain).to.be.undefined
})
})

it('should set schain if not specified', function () {
const requests = validBidRequests.map(bid => ({
...bid,
schain: {
validation: 'strict',
config: {
ver: '1.0'
}
}
}))
const request = spec.buildRequests(requests, bidderRequest)
const data = JSON.parse(request.data)
data.bidRequests.forEach(bid => {
expect(bid.schain.validation).to.equal('strict')
expect(bid.schain.config.ver).to.equal('1.0')
})
})

describe('price floors', function () {
it('should be empty if floors module not configured', function () {
const request = spec.buildRequests(validBidRequests, bidderRequest)
const data = JSON.parse(request.data)
data.bidRequests.forEach(bid => {
expect(bid.floorInfo).to.be.empty
})
})

it('should add correct floor values', function () {
const expectedFloors = [ 2, 2.7, 1.4 ]
const validBidRequests = expectedFloors.map(getBidWithFloor)
const request = spec.buildRequests(validBidRequests, bidderRequest)
const data = JSON.parse(request.data)
expectedFloors.forEach((floor, index) => {
expect(data.bidRequests[index].floorInfo.floor).to.equal(floor)
expect(data.bidRequests[index].floorInfo.currency).to.equal('USD')
})
})

it('should request floor price in adserver currency', function () {
const configCurrency = 'DKK'
config.setConfig({ currency: { adServerCurrency: configCurrency } })
const request = spec.buildRequests([ getBidWithFloor() ], bidderRequest)
const data = JSON.parse(request.data)
data.bidRequests.forEach(bid => {
expect(bid.floorInfo.currency).to.equal(configCurrency)
})
})

function getBidWithFloor(floor) {
return {
...validBidRequests[0],
getFloor: ({ currency }) => {
return {
currency: currency,
floor
}
}
}
}
})

describe('GDPR params', function() {
describe('when there are not consent management platform', function() {
Expand Down