Skip to content

Commit b72a74c

Browse files
committed
Merge branch 'master' into bidderSettings-allowStorage
2 parents df27267 + c0d4135 commit b72a74c

10 files changed

+202
-52
lines changed

modules/dspxBidAdapter.js

Lines changed: 69 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { BANNER, VIDEO } from '../src/mediaTypes.js';
66
const BIDDER_CODE = 'dspx';
77
const ENDPOINT_URL = 'https://buyer.dspx.tv/request/';
88
const ENDPOINT_URL_DEV = 'https://dcbuyer.dspx.tv/request/';
9-
const DEFAULT_VAST_FORMAT = 'vast2';
109
const GVLID = 602;
1110

1211
export const spec = {
@@ -26,37 +25,30 @@ export const spec = {
2625
const referrer = bidderRequest.refererInfo.referer;
2726
const bidId = bidRequest.bidId;
2827
const isDev = params.devMode || false;
28+
const pbcode = bidRequest.adUnitCode || false; // div id
29+
const auctionId = bidRequest.auctionId || false;
2930

3031
let endpoint = isDev ? ENDPOINT_URL_DEV : ENDPOINT_URL;
31-
let payload = {};
3232

33-
if (isBannerRequest(bidRequest)) {
34-
let size = getBannerSizes(bidRequest)[0];
35-
payload = {
36-
_f: 'html',
37-
alternative: 'prebid_js',
38-
inventory_item_id: placementId,
39-
srw: size.width,
40-
srh: size.height,
41-
idt: 100,
42-
rnd: rnd,
43-
ref: referrer,
44-
bid_id: bidId,
45-
};
46-
} else {
47-
let size = getVideoSizes(bidRequest)[0];
48-
let vastFormat = params.vastFormat || DEFAULT_VAST_FORMAT;
49-
payload = {
50-
_f: vastFormat,
51-
alternative: 'prebid_js',
52-
inventory_item_id: placementId,
53-
srw: size.width,
54-
srh: size.height,
55-
idt: 100,
56-
rnd: rnd,
57-
ref: referrer,
58-
bid_id: bidId,
59-
};
33+
let mediaTypesInfo = getMediaTypesInfo(bidRequest);
34+
let type = isBannerRequest(bidRequest) ? BANNER : VIDEO;
35+
let sizes = mediaTypesInfo[type];
36+
37+
let payload = {
38+
_f: 'auto',
39+
alternative: 'prebid_js',
40+
inventory_item_id: placementId,
41+
srw: sizes ? sizes[0].width : 0,
42+
srh: sizes ? sizes[0].height : 0,
43+
idt: 100,
44+
rnd: rnd,
45+
ref: referrer,
46+
bid_id: bidId,
47+
pbver: '$prebid.version$'
48+
};
49+
50+
if (mediaTypesInfo[VIDEO] !== undefined && params.vastFormat !== undefined) {
51+
payload.vf = params.vastFormat;
6052
}
6153

6254
if (params.pfilter !== undefined) {
@@ -94,6 +86,15 @@ export const spec = {
9486
payload.did_uid2 = bidRequest.userId.uid2;
9587
}
9688

89+
if (auctionId) {
90+
payload.auctionId = auctionId;
91+
}
92+
if (pbcode) {
93+
payload.pbcode = pbcode;
94+
}
95+
96+
payload.media_types = convertMediaInfoForRequest(mediaTypesInfo);
97+
9798
return {
9899
method: 'GET',
99100
url: endpoint,
@@ -256,4 +257,43 @@ function parseSizes(sizes) {
256257
return [parseSize(sizes)]; // or a single one ? (ie. [728,90])
257258
}
258259

260+
/**
261+
* Get MediaInfo object for server request
262+
*
263+
* @param mediaTypesInfo
264+
* @returns {*}
265+
*/
266+
function convertMediaInfoForRequest(mediaTypesInfo) {
267+
let requestData = {};
268+
Object.keys(mediaTypesInfo).forEach(mediaType => {
269+
requestData[mediaType] = mediaTypesInfo[mediaType].map(size => {
270+
return size.width + 'x' + size.height;
271+
}).join(',');
272+
});
273+
return requestData;
274+
}
275+
276+
/**
277+
* Get media types info
278+
*
279+
* @param bid
280+
*/
281+
function getMediaTypesInfo(bid) {
282+
let mediaTypesInfo = {};
283+
284+
if (bid.mediaTypes) {
285+
Object.keys(bid.mediaTypes).forEach(mediaType => {
286+
if (mediaType === BANNER) {
287+
mediaTypesInfo[mediaType] = getBannerSizes(bid);
288+
}
289+
if (mediaType === VIDEO) {
290+
mediaTypesInfo[mediaType] = getVideoSizes(bid);
291+
}
292+
});
293+
} else {
294+
mediaTypesInfo[BANNER] = getBannerSizes(bid);
295+
}
296+
return mediaTypesInfo;
297+
}
298+
259299
registerBidder(spec);

modules/dspxBidAdapter.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ DSPx adapter for Prebid.
5757
bids: [{
5858
bidder: 'dspx',
5959
params: {
60-
placement: '106'
60+
placement: '106',
61+
vastFormat: 'vast2|vast4' // set vast format
6162
}
6263
}]
6364
}

modules/mediasquareBidAdapter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const BIDDER_ENDPOINT_WINNING = 'winning';
1111

1212
export const spec = {
1313
code: BIDDER_CODE,
14+
gvlid: 791,
1415
aliases: ['msq'], // short code
1516
supportedMediaTypes: [BANNER, NATIVE, VIDEO],
1617
/**

modules/nextMillenniumBidAdapter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export const spec = {
109109
let bidders = []
110110
if (responses) {
111111
_each(responses, (response) => {
112+
if (!(response && response.body && response.body.ext && response.body.ext.responsetimemillis)) return
112113
_each(Object.keys(response.body.ext.responsetimemillis), b => bidders.push(b))
113114
})
114115
}

modules/oguryBidAdapter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const DEFAULT_TIMEOUT = 1000;
1010
const BID_HOST = 'https://mweb-hb.presage.io/api/header-bidding-request';
1111
const TIMEOUT_MONITORING_HOST = 'https://ms-ads-monitoring-events.presage.io';
1212
const MS_COOKIE_SYNC_DOMAIN = 'https://ms-cookie-sync.presage.io';
13-
const ADAPTER_VERSION = '1.2.9';
13+
const ADAPTER_VERSION = '1.2.10';
1414

1515
function isBidRequestValid(bid) {
1616
const adUnitSizes = getAdUnitSizes(bid);
@@ -41,7 +41,7 @@ function buildRequests(validBidRequests, bidderRequest) {
4141
const openRtbBidRequestBanner = {
4242
id: bidderRequest.auctionId,
4343
tmax: DEFAULT_TIMEOUT,
44-
at: 2,
44+
at: 1,
4545
regs: {
4646
ext: {
4747
gdpr: bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies ? 1 : 0

src/targeting.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,15 @@ export function newTargeting(auctionManager) {
438438
let bidsReceived = auctionManager.getBidsReceived();
439439

440440
if (!config.getConfig('useBidCache')) {
441+
// don't use bid cache (i.e. filter out bids not in the latest auction)
441442
bidsReceived = bidsReceived.filter(bid => latestAuctionForAdUnit[bid.adUnitCode] === bid.auctionId)
443+
} else {
444+
// if custom bid cache filter function exists, run for each bid from
445+
// previous auctions. If it returns true, include bid in bid pool
446+
const filterFunction = config.getConfig('bidCacheFilterFunction');
447+
if (typeof filterFunction === 'function') {
448+
bidsReceived = bidsReceived.filter(bid => latestAuctionForAdUnit[bid.adUnitCode] === bid.auctionId || !!filterFunction(bid))
449+
}
442450
}
443451

444452
bidsReceived = bidsReceived

test/fixtures/fixtures.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ export function getCurrencyRates() {
12311231
};
12321232
}
12331233

1234-
export function createBidReceived({bidder, cpm, auctionId, responseTimestamp, adUnitCode, adId, status, ttl, requestId}) {
1234+
export function createBidReceived({bidder, cpm, auctionId, responseTimestamp, adUnitCode, adId, status, ttl, requestId, mediaType}) {
12351235
let bid = {
12361236
'bidderCode': bidder,
12371237
'width': '300',
@@ -1259,6 +1259,7 @@ export function createBidReceived({bidder, cpm, auctionId, responseTimestamp, ad
12591259
'hb_pb': cpm,
12601260
'foobar': '300x250'
12611261
}),
1262+
'mediaType': mediaType,
12621263
'netRevenue': true,
12631264
'currency': 'USD',
12641265
'ttl': (!ttl) ? 300 : ttl

test/spec/modules/dspxBidAdapter_spec.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ describe('dspxAdapter', function () {
6262
'bidId': '30b31c1838de1e1',
6363
'bidderRequestId': '22edbae2733bf61',
6464
'auctionId': '1d1a030790a475',
65+
'adUnitCode': 'testDiv1',
6566
'userId': {
6667
'netId': '123',
6768
'uid2': '456'
@@ -98,7 +99,8 @@ describe('dspxAdapter', function () {
9899
],
99100
'bidId': '30b31c1838de1e3',
100101
'bidderRequestId': '22edbae2733bf69',
101-
'auctionId': '1d1a030790a477'
102+
'auctionId': '1d1a030790a477',
103+
'adUnitCode': 'testDiv2'
102104
},
103105
{
104106
'bidder': 'dspx',
@@ -120,13 +122,15 @@ describe('dspxAdapter', function () {
120122

121123
'bidId': '30b31c1838de1e4',
122124
'bidderRequestId': '22edbae2733bf67',
123-
'auctionId': '1d1a030790a478'
125+
'auctionId': '1d1a030790a478',
126+
'adUnitCode': 'testDiv3'
124127
},
125128
{
126129
'bidder': 'dspx',
127130
'params': {
128131
'placement': '101',
129-
'devMode': true
132+
'devMode': true,
133+
'vastFormat': 'vast4'
130134
},
131135
'mediaTypes': {
132136
'video': {
@@ -136,7 +140,8 @@ describe('dspxAdapter', function () {
136140
},
137141
'bidId': '30b31c1838de1e41',
138142
'bidderRequestId': '22edbae2733bf67',
139-
'auctionId': '1d1a030790a478'
143+
'auctionId': '1d1a030790a478',
144+
'adUnitCode': 'testDiv4'
140145
}
141146

142147
];
@@ -157,16 +162,16 @@ describe('dspxAdapter', function () {
157162
it('sends bid request to our endpoint via GET', function () {
158163
expect(request1.method).to.equal('GET');
159164
expect(request1.url).to.equal(ENDPOINT_URL);
160-
let data = request1.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid');
161-
expect(data).to.equal('_f=html&alternative=prebid_js&inventory_item_id=6682&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e1&pfilter%5Bfloorprice%5D=1000000&pfilter%5Bprivate_auction%5D=0&pfilter%5Bgeo%5D%5Bcountry%5D=DE&pfilter%5Bgdpr_consent%5D=BOJ%2FP2HOJ%2FP2HABABMAAAAAZ%2BA%3D%3D&pfilter%5Bgdpr%5D=true&bcat=IAB2%2CIAB4&dvt=desktop&did_netid=123&did_uid2=456');
165+
let data = request1.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&');
166+
expect(data).to.equal('_f=auto&alternative=prebid_js&inventory_item_id=6682&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e1&pbver=test&pfilter%5Bfloorprice%5D=1000000&pfilter%5Bprivate_auction%5D=0&pfilter%5Bgeo%5D%5Bcountry%5D=DE&pfilter%5Bgdpr_consent%5D=BOJ%2FP2HOJ%2FP2HABABMAAAAAZ%2BA%3D%3D&pfilter%5Bgdpr%5D=true&bcat=IAB2%2CIAB4&dvt=desktop&did_netid=123&did_uid2=456&auctionId=1d1a030790a475&pbcode=testDiv1&media_types%5Bbanner%5D=300x250');
162167
});
163168

164169
var request2 = spec.buildRequests([bidRequests[1]], bidderRequest)[0];
165170
it('sends bid request to our DEV endpoint via GET', function () {
166171
expect(request2.method).to.equal('GET');
167172
expect(request2.url).to.equal(ENDPOINT_URL_DEV);
168-
let data = request2.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid');
169-
expect(data).to.equal('_f=html&alternative=prebid_js&inventory_item_id=101&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e2&pfilter%5Bgdpr_consent%5D=BOJ%2FP2HOJ%2FP2HABABMAAAAAZ%2BA%3D%3D&pfilter%5Bgdpr%5D=true&prebidDevMode=1');
173+
let data = request2.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&');
174+
expect(data).to.equal('_f=auto&alternative=prebid_js&inventory_item_id=101&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e2&pbver=test&pfilter%5Bgdpr_consent%5D=BOJ%2FP2HOJ%2FP2HABABMAAAAAZ%2BA%3D%3D&pfilter%5Bgdpr%5D=true&prebidDevMode=1&auctionId=1d1a030790a476&media_types%5Bbanner%5D=300x250');
170175
});
171176

172177
// Without gdprConsent
@@ -179,23 +184,23 @@ describe('dspxAdapter', function () {
179184
it('sends bid request without gdprConsent to our endpoint via GET', function () {
180185
expect(request3.method).to.equal('GET');
181186
expect(request3.url).to.equal(ENDPOINT_URL);
182-
let data = request3.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid');
183-
expect(data).to.equal('_f=html&alternative=prebid_js&inventory_item_id=6682&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e3&pfilter%5Bfloorprice%5D=1000000&pfilter%5Bprivate_auction%5D=0&pfilter%5Bgeo%5D%5Bcountry%5D=DE&bcat=IAB2%2CIAB4&dvt=desktop');
187+
let data = request3.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&');
188+
expect(data).to.equal('_f=auto&alternative=prebid_js&inventory_item_id=6682&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e3&pbver=test&pfilter%5Bfloorprice%5D=1000000&pfilter%5Bprivate_auction%5D=0&pfilter%5Bgeo%5D%5Bcountry%5D=DE&bcat=IAB2%2CIAB4&dvt=desktop&auctionId=1d1a030790a477&pbcode=testDiv2&media_types%5Bbanner%5D=300x250');
184189
});
185190

186191
var request4 = spec.buildRequests([bidRequests[3]], bidderRequestWithoutGdpr)[0];
187192
it('sends bid request without gdprConsent to our DEV endpoint via GET', function () {
188193
expect(request4.method).to.equal('GET');
189194
expect(request4.url).to.equal(ENDPOINT_URL_DEV);
190-
let data = request4.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid');
191-
expect(data).to.equal('_f=html&alternative=prebid_js&inventory_item_id=101&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e4&prebidDevMode=1');
195+
let data = request4.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&');
196+
expect(data).to.equal('_f=auto&alternative=prebid_js&inventory_item_id=101&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e4&pbver=test&prebidDevMode=1&auctionId=1d1a030790a478&pbcode=testDiv3&media_types%5Bvideo%5D=640x480&media_types%5Bbanner%5D=300x250');
192197
});
193198

194199
var request5 = spec.buildRequests([bidRequests[4]], bidderRequestWithoutGdpr)[0];
195-
it('sends bid video request to our rads endpoint via GET', function () {
200+
it('sends bid video request to our endpoint via GET', function () {
196201
expect(request5.method).to.equal('GET');
197-
let data = request5.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid');
198-
expect(data).to.equal('_f=vast2&alternative=prebid_js&inventory_item_id=101&srw=640&srh=480&idt=100&bid_id=30b31c1838de1e41&prebidDevMode=1');
202+
let data = request5.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&');
203+
expect(data).to.equal('_f=auto&alternative=prebid_js&inventory_item_id=101&srw=640&srh=480&idt=100&bid_id=30b31c1838de1e41&pbver=test&vf=vast4&prebidDevMode=1&auctionId=1d1a030790a478&pbcode=testDiv4&media_types%5Bvideo%5D=640x480');
199204
});
200205
});
201206

test/spec/modules/oguryBidAdapter_spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ describe('OguryBidAdapter', function () {
229229
const defaultTimeout = 1000;
230230
const expectedRequestObject = {
231231
id: bidRequests[0].auctionId,
232-
at: 2,
232+
at: 1,
233233
tmax: defaultTimeout,
234234
imp: [{
235235
id: bidRequests[0].bidId,
@@ -271,7 +271,7 @@ describe('OguryBidAdapter', function () {
271271
},
272272
ext: {
273273
prebidversion: '$prebid.version$',
274-
adapterversion: '1.2.9'
274+
adapterversion: '1.2.10'
275275
}
276276
};
277277

@@ -482,7 +482,7 @@ describe('OguryBidAdapter', function () {
482482
advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[0].adomain
483483
},
484484
nurl: openRtbBidResponse.body.seatbid[0].bid[0].nurl,
485-
adapterVersion: '1.2.9',
485+
adapterVersion: '1.2.10',
486486
prebidVersion: '$prebid.version$'
487487
}, {
488488
requestId: openRtbBidResponse.body.seatbid[0].bid[1].impid,
@@ -499,7 +499,7 @@ describe('OguryBidAdapter', function () {
499499
advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[1].adomain
500500
},
501501
nurl: openRtbBidResponse.body.seatbid[0].bid[1].nurl,
502-
adapterVersion: '1.2.9',
502+
adapterVersion: '1.2.10',
503503
prebidVersion: '$prebid.version$'
504504
}]
505505

0 commit comments

Comments
 (0)