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

Sovrn: Update adapter to remove tpids and how it gets sizes #8581

Merged
merged 5 commits into from
Jun 21, 2022
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
26 changes: 16 additions & 10 deletions modules/sovrnBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import {
_each,
deepAccess,
deepSetValue,
getBidIdParameter,
getUniqueIdentifierStr,
isArray,
isInteger,
getUniqueIdentifierStr,
deepSetValue,
logError,
deepAccess,
isInteger,
logWarn
} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {ADPOD, BANNER, VIDEO} from '../src/mediaTypes.js';
import { registerBidder } from '../src/adapters/bidderFactory.js'
import {
ADPOD,
BANNER,
VIDEO
} from '../src/mediaTypes.js'
import {createEidsArray} from './userId/eids.js';

const ORTB_VIDEO_PARAMS = {
Expand Down Expand Up @@ -83,7 +87,6 @@ export const spec = {
let iv;
let schain;
let eids;
let tpid = []
let criteoId;

_each(bidReqs, function (bid) {
Expand All @@ -94,7 +97,6 @@ export const spec = {
if (id.source === 'criteo.com') {
criteoId = id.uids[0].id
}
tpid.push({source: id.source, uid: id.uids[0].id})
}
})
}
Expand Down Expand Up @@ -175,7 +177,6 @@ export const spec = {

if (eids) {
deepSetValue(sovrnBidReq, 'user.ext.eids', eids)
deepSetValue(sovrnBidReq, 'user.ext.tpid', tpid)
if (criteoId) {
deepSetValue(sovrnBidReq, 'user.ext.prebid_criteoid', criteoId)
}
Expand Down Expand Up @@ -276,11 +277,16 @@ export const spec = {

function _buildVideoRequestObj(bid) {
const videoObj = {}
const bidSizes = deepAccess(bid, 'sizes')
const videoAdUnitParams = deepAccess(bid, 'mediaTypes.video', {})
const videoBidderParams = deepAccess(bid, 'params.video', {})
const computedParams = {}

if (Array.isArray(videoAdUnitParams.playerSize)) {
if (bidSizes) {
const sizes = (Array.isArray(bidSizes[0])) ? bidSizes[0] : bidSizes
computedParams.w = sizes[0]
computedParams.h = sizes[1]
} else if (Array.isArray(videoAdUnitParams.playerSize)) {
const sizes = (Array.isArray(videoAdUnitParams.playerSize[0])) ? videoAdUnitParams.playerSize[0] : videoAdUnitParams.playerSize
computedParams.w = sizes[0]
computedParams.h = sizes[1]
Expand Down
44 changes: 39 additions & 5 deletions test/spec/modules/sovrnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ describe('sovrnBidAdapter', function() {
expect(impression.banner.h).to.equal(1)
})

it('sets the proper video object', function() {
const width = 640
const height = 480
it('sets the proper video object with sizes defined', function() {
const width = 300
const height = 250
const mimes = ['video/mp4', 'application/javascript']
const protocols = [2, 5]
const minduration = 5
Expand Down Expand Up @@ -129,6 +129,42 @@ describe('sovrnBidAdapter', function() {
expect(impression.video.startdelay).to.equal(startdelay)
})

it('sets the proper video object wihtout sizes defined but video sizes defined', function() {
const width = 360
const height = 240
const mimes = ['video/mp4', 'application/javascript']
const protocols = [2, 5]
const minduration = 5
const maxduration = 60
const startdelay = 0
const modifiedBidRequest = baseBidRequest;
delete modifiedBidRequest.sizes;
const videoBidRequest = {
...modifiedBidRequest,
mediaTypes: {
video: {
mimes,
protocols,
playerSize: [[width, height], [360, 240]],
minduration,
maxduration,
startdelay
}
}
}
const request = spec.buildRequests([videoBidRequest], baseBidderRequest)
const payload = JSON.parse(request.data)
const impression = payload.imp[0]

expect(impression.video.w).to.equal(width)
expect(impression.video.h).to.equal(height)
expect(impression.video.mimes).to.have.same.members(mimes)
expect(impression.video.protocols).to.have.same.members(protocols)
expect(impression.video.minduration).to.equal(minduration)
expect(impression.video.maxduration).to.equal(maxduration)
expect(impression.video.startdelay).to.equal(startdelay)
})

it('gets correct site info', function() {
expect(payload.site.page).to.equal('http://example.com/page.html')
expect(payload.site.domain).to.equal('example.com')
Expand Down Expand Up @@ -254,8 +290,6 @@ describe('sovrnBidAdapter', function() {
expect(secondEID.uids[0].id).to.equal('SOMESORTOFID')
expect(secondEID.uids[0].ext.rtiPartner).to.equal('TDID')
expect(secondEID.uids[0].atype).to.equal(1)
expect(ext.tpid[0].source).to.equal('criteo.com')
expect(ext.tpid[0].uid).to.equal('A_CRITEO_ID')
expect(ext.prebid_criteoid).to.equal('A_CRITEO_ID')
})

Expand Down