prebid.js 5.17.0 → 5.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/modules/adgenerationBidAdapter.js +28 -4
- package/modules/adkernelBidAdapter.js +2 -1
- package/modules/admixerBidAdapter.js +11 -0
- package/modules/aolBidAdapter.js +2 -1
- package/modules/bliinkBidAdapter.js +58 -32
- package/modules/bliinkBidAdapter.md +29 -6
- package/modules/cwireBidAdapter.js +272 -0
- package/modules/cwireBidAdapter.md +43 -0
- package/modules/dgkeywordRtdProvider.js +0 -1
- package/modules/livewrappedAnalyticsAdapter.js +4 -2
- package/modules/mediakeysBidAdapter.js +2 -1
- package/modules/nativoBidAdapter.js +1 -1
- package/modules/oguryBidAdapter.js +22 -6
- package/modules/pixfutureBidAdapter.js +24 -4
- package/modules/pixfutureBidAdapter.md +127 -0
- package/modules/prebidServerBidAdapter/index.js +1 -1
- package/modules/proxistoreBidAdapter.js +4 -6
- package/modules/pubmaticBidAdapter.js +9 -0
- package/modules/pubmaticBidAdapter.md +1 -1
- package/modules/talkadsBidAdapter.js +129 -0
- package/modules/talkadsBidAdapter.md +60 -0
- package/modules/unicornBidAdapter.js +3 -3
- package/modules/visxBidAdapter.js +15 -22
- package/modules/yahoosspBidAdapter.js +637 -0
- package/modules/yahoosspBidAdapter.md +795 -0
- package/modules/yieldlabBidAdapter.js +48 -3
- package/modules/yieldlabBidAdapter.md +16 -1
- package/package.json +1 -1
- package/test/spec/modules/adgenerationBidAdapter_spec.js +121 -50
- package/test/spec/modules/bliinkBidAdapter_spec.js +87 -36
- package/test/spec/modules/cwireBidAdapter_spec.js +246 -0
- package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +17 -7
- package/test/spec/modules/oguryBidAdapter_spec.js +72 -25
- package/test/spec/modules/pubmaticBidAdapter_spec.js +39 -1
- package/test/spec/modules/talkadsBidAdapter_spec.js +231 -0
- package/test/spec/modules/unicornBidAdapter_spec.js +4 -4
- package/test/spec/modules/visxBidAdapter_spec.js +48 -4
- package/test/spec/modules/yahoosspBidAdapter_spec.js +1332 -0
- package/test/spec/modules/yieldlabBidAdapter_spec.js +65 -1
- package/modules/turktelekomBidAdapter.md +0 -49
- package/yarn.lock +0 -13122
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {tryAppendQueryString, getBidIdParameter} from '../src/utils.js';
|
|
2
2
|
import {registerBidder} from '../src/adapters/bidderFactory.js';
|
|
3
3
|
import {BANNER, NATIVE} from '../src/mediaTypes.js';
|
|
4
4
|
import {config} from '../src/config.js';
|
|
@@ -25,7 +25,7 @@ export const spec = {
|
|
|
25
25
|
* @return ServerRequest Info describing the request to the server.
|
|
26
26
|
*/
|
|
27
27
|
buildRequests: function (validBidRequests, bidderRequest) {
|
|
28
|
-
const ADGENE_PREBID_VERSION = '1.
|
|
28
|
+
const ADGENE_PREBID_VERSION = '1.2.0';
|
|
29
29
|
let serverRequests = [];
|
|
30
30
|
for (let i = 0, len = validBidRequests.length; i < len; i++) {
|
|
31
31
|
const validReq = validBidRequests[i];
|
|
@@ -118,13 +118,25 @@ export const spec = {
|
|
|
118
118
|
function createAd(body, bidRequest) {
|
|
119
119
|
let ad = body.ad;
|
|
120
120
|
if (body.vastxml && body.vastxml.length > 0) {
|
|
121
|
-
|
|
121
|
+
if (isUpperBillboard(body)) {
|
|
122
|
+
const marginTop = bidRequest.params.marginTop ? bidRequest.params.marginTop : '0';
|
|
123
|
+
ad = `<body>${createADGBrowserMTag()}${insertVASTMethodForADGBrowserM(body.vastxml, marginTop)}</body>`;
|
|
124
|
+
} else {
|
|
125
|
+
ad = `<body><div id="apvad-${bidRequest.bidId}"></div>${createAPVTag()}${insertVASTMethodForAPV(bidRequest.bidId, body.vastxml)}</body>`;
|
|
126
|
+
}
|
|
122
127
|
}
|
|
123
128
|
ad = appendChildToBody(ad, body.beacon);
|
|
124
129
|
if (removeWrapper(ad)) return removeWrapper(ad);
|
|
125
130
|
return ad;
|
|
126
131
|
}
|
|
127
132
|
|
|
133
|
+
function isUpperBillboard(body) {
|
|
134
|
+
if (body.location_params && body.location_params.option && body.location_params.option.ad_type) {
|
|
135
|
+
return body.location_params.option.ad_type === 'upper_billboard';
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
128
140
|
function isNative(body) {
|
|
129
141
|
if (!body) return false;
|
|
130
142
|
return body.native_ad && body.native_ad.assets.length > 0;
|
|
@@ -190,7 +202,12 @@ function createAPVTag() {
|
|
|
190
202
|
return apvScript.outerHTML;
|
|
191
203
|
}
|
|
192
204
|
|
|
193
|
-
function
|
|
205
|
+
function createADGBrowserMTag() {
|
|
206
|
+
const ADGBrowserMURL = 'https://i.socdm.com/sdk/js/adg-browser-m.js';
|
|
207
|
+
return `<script type="text/javascript" src="${ADGBrowserMURL}"></script>`;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function insertVASTMethodForAPV(targetId, vastXml) {
|
|
194
211
|
let apvVideoAdParam = {
|
|
195
212
|
s: targetId
|
|
196
213
|
};
|
|
@@ -200,6 +217,13 @@ function insertVASTMethod(targetId, vastXml) {
|
|
|
200
217
|
return script.outerHTML;
|
|
201
218
|
}
|
|
202
219
|
|
|
220
|
+
function insertVASTMethodForADGBrowserM(vastXml, marginTop) {
|
|
221
|
+
const script = document.createElement(`script`);
|
|
222
|
+
script.type = 'text/javascript';
|
|
223
|
+
script.innerHTML = `window.ADGBrowserM.init({vastXml: '${vastXml.replace(/\r?\n/g, '')}', marginTop: '${marginTop}'});`;
|
|
224
|
+
return script.outerHTML;
|
|
225
|
+
}
|
|
226
|
+
|
|
203
227
|
/**
|
|
204
228
|
*
|
|
205
229
|
* @param ad
|
|
@@ -19,9 +19,20 @@ export const spec = {
|
|
|
19
19
|
* Make a server request from the list of BidRequests.
|
|
20
20
|
*/
|
|
21
21
|
buildRequests: function (validRequest, bidderRequest) {
|
|
22
|
+
let w;
|
|
23
|
+
let docRef;
|
|
24
|
+
do {
|
|
25
|
+
w = w ? w.parent : window;
|
|
26
|
+
try {
|
|
27
|
+
docRef = w.document.referrer;
|
|
28
|
+
} catch (e) {
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
} while (w !== window.top);
|
|
22
32
|
const payload = {
|
|
23
33
|
imps: [],
|
|
24
34
|
ortb2: config.getConfig('ortb2'),
|
|
35
|
+
docReferrer: docRef,
|
|
25
36
|
};
|
|
26
37
|
let endpointUrl;
|
|
27
38
|
if (bidderRequest) {
|
package/modules/aolBidAdapter.js
CHANGED
|
@@ -38,7 +38,8 @@ const SUPPORTED_USER_ID_SOURCES = [
|
|
|
38
38
|
'liveintent.com',
|
|
39
39
|
'quantcast.com',
|
|
40
40
|
'verizonmedia.com',
|
|
41
|
-
'liveramp.com'
|
|
41
|
+
'liveramp.com',
|
|
42
|
+
'yahoo.com'
|
|
42
43
|
];
|
|
43
44
|
|
|
44
45
|
const pubapiTemplate = template`${'host'}/pubapi/3.0/${'network'}/${'placement'}/${'pageid'}/${'sizeid'}/ADTECH;v=2;cmd=bid;cors=yes;alias=${'alias'};misc=${'misc'};${'dynamicParams'}`;
|
|
@@ -10,10 +10,9 @@ export const META_KEYWORDS = 'keywords'
|
|
|
10
10
|
export const META_DESCRIPTION = 'description'
|
|
11
11
|
|
|
12
12
|
const VIDEO = 'video'
|
|
13
|
-
const NATIVE = 'native'
|
|
14
13
|
const BANNER = 'banner'
|
|
15
14
|
|
|
16
|
-
const supportedMediaTypes = [BANNER, VIDEO
|
|
15
|
+
const supportedMediaTypes = [BANNER, VIDEO]
|
|
17
16
|
const aliasBidderCode = ['bk']
|
|
18
17
|
|
|
19
18
|
export function getMetaList(name) {
|
|
@@ -90,7 +89,11 @@ export const parseXML = (content) => {
|
|
|
90
89
|
if (typeof content !== 'string' || content.length === 0) return null
|
|
91
90
|
|
|
92
91
|
const parser = new DOMParser()
|
|
93
|
-
|
|
92
|
+
let xml;
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
xml = parser.parseFromString(content, 'text/xml')
|
|
96
|
+
} catch (e) {}
|
|
94
97
|
|
|
95
98
|
if (xml &&
|
|
96
99
|
xml.getElementsByTagName('VAST')[0] &&
|
|
@@ -104,19 +107,19 @@ export const parseXML = (content) => {
|
|
|
104
107
|
/**
|
|
105
108
|
* @param bidRequest
|
|
106
109
|
* @param bliinkCreative
|
|
107
|
-
* @return {{cpm, netRevenue: boolean,
|
|
110
|
+
* @return {{cpm, netRevenue: boolean, requestId, width: (*|number), currency, ttl: number, creativeId, height: (*|number)} & {mediaType: string, vastXml}}
|
|
108
111
|
*/
|
|
109
112
|
export const buildBid = (bidRequest, bliinkCreative) => {
|
|
110
113
|
if (!bidRequest && !bliinkCreative) return null
|
|
111
114
|
|
|
112
115
|
const body = {
|
|
113
116
|
requestId: bidRequest.bidId,
|
|
117
|
+
currency: bliinkCreative.currency,
|
|
114
118
|
cpm: bliinkCreative.price,
|
|
115
119
|
creativeId: bliinkCreative.creativeId,
|
|
116
|
-
|
|
120
|
+
width: (bidRequest.sizes && bidRequest.sizes[0][0]) || 1,
|
|
121
|
+
height: (bidRequest.sizes && bidRequest.sizes[0][1]) || 1,
|
|
117
122
|
netRevenue: false,
|
|
118
|
-
width: 1,
|
|
119
|
-
height: 1,
|
|
120
123
|
ttl: 3600,
|
|
121
124
|
}
|
|
122
125
|
|
|
@@ -131,14 +134,20 @@ export const buildBid = (bidRequest, bliinkCreative) => {
|
|
|
131
134
|
|
|
132
135
|
delete bidRequest['bids']
|
|
133
136
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
switch (bliinkCreative.media_type) {
|
|
138
|
+
case VIDEO:
|
|
139
|
+
return Object.assign(body, {
|
|
140
|
+
mediaType: VIDEO,
|
|
141
|
+
vastXml: bliinkCreative.content,
|
|
142
|
+
})
|
|
143
|
+
case BANNER:
|
|
144
|
+
return Object.assign(body, {
|
|
145
|
+
mediaType: BANNER,
|
|
146
|
+
ad: (bliinkCreative && bliinkCreative.content && bliinkCreative.content.creative && bliinkCreative.content.creative.adm) || '',
|
|
147
|
+
})
|
|
148
|
+
default:
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
142
151
|
}
|
|
143
152
|
|
|
144
153
|
/**
|
|
@@ -209,7 +218,7 @@ export const buildRequests = (_, bidderRequest) => {
|
|
|
209
218
|
* @return
|
|
210
219
|
*/
|
|
211
220
|
const interpretResponse = (serverResponse, request) => {
|
|
212
|
-
if ((serverResponse && serverResponse.mode === 'no-ad')
|
|
221
|
+
if ((serverResponse && serverResponse.mode === 'no-ad')) {
|
|
213
222
|
return []
|
|
214
223
|
}
|
|
215
224
|
|
|
@@ -218,23 +227,40 @@ const interpretResponse = (serverResponse, request) => {
|
|
|
218
227
|
|
|
219
228
|
const xml = parseXML(body)
|
|
220
229
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
230
|
+
let creative;
|
|
231
|
+
|
|
232
|
+
switch (serverBody.bids[0].params.placement) {
|
|
233
|
+
case xml && VIDEO:
|
|
234
|
+
const price = xml.getElementsByTagName('Price') && xml.getElementsByTagName('Price')[0]
|
|
235
|
+
const currency = xml.getElementsByTagName('Currency') && xml.getElementsByTagName('Currency')[0]
|
|
236
|
+
const creativeId = xml.getElementsByTagName('CreativeId') && xml.getElementsByTagName('CreativeId')[0]
|
|
237
|
+
|
|
238
|
+
creative = {
|
|
239
|
+
content: body,
|
|
240
|
+
price: (price && price.textContent) || 0,
|
|
241
|
+
currency: (currency && currency.textContent) || 'EUR',
|
|
242
|
+
creativeId: creativeId || 0,
|
|
243
|
+
media_type: 'video',
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return buildBid(serverBody.bids[0], creative)
|
|
247
|
+
case BANNER:
|
|
248
|
+
if (body) {
|
|
249
|
+
creative = {
|
|
250
|
+
content: body,
|
|
251
|
+
price: body.price,
|
|
252
|
+
currency: body.currency,
|
|
253
|
+
creativeId: 0,
|
|
254
|
+
media_type: 'banner',
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return buildBid(serverBody.bids[0], creative)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
break
|
|
261
|
+
default:
|
|
262
|
+
break
|
|
235
263
|
}
|
|
236
|
-
|
|
237
|
-
return []
|
|
238
264
|
}
|
|
239
265
|
|
|
240
266
|
/**
|
|
@@ -31,7 +31,7 @@ const adUnits = [
|
|
|
31
31
|
bidder: 'bliink',
|
|
32
32
|
params: {
|
|
33
33
|
placement: 'banner',
|
|
34
|
-
tagId: '
|
|
34
|
+
tagId: '41'
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
]
|
|
@@ -50,11 +50,34 @@ const adUnits = [
|
|
|
50
50
|
mediaTypes: {
|
|
51
51
|
video: {
|
|
52
52
|
context: 'instream',
|
|
53
|
-
playerSize: [640,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
playerSize: [[640,480]],
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
bids: [
|
|
57
|
+
{
|
|
58
|
+
bidder: 'bliink',
|
|
59
|
+
params: {
|
|
60
|
+
tagId: '41',
|
|
61
|
+
placement: 'video',
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Sample outstream Video Ad Unit
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
const adUnits = [
|
|
73
|
+
{
|
|
74
|
+
code: '/19968336/prebid_cache_video_adunit',
|
|
75
|
+
sizes: [[640,480]],
|
|
76
|
+
mediaType: 'video',
|
|
77
|
+
mediaTypes: {
|
|
78
|
+
video: {
|
|
79
|
+
context: 'outstream',
|
|
80
|
+
playerSize: [[640,480]],
|
|
58
81
|
}
|
|
59
82
|
},
|
|
60
83
|
bids: [
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import {registerBidder} from '../src/adapters/bidderFactory.js';
|
|
2
|
+
import { getRefererInfo } from '../src/refererDetection.js';
|
|
3
|
+
import { getStorageManager } from '../src/storageManager.js';
|
|
4
|
+
import {BANNER, VIDEO} from '../src/mediaTypes.js';
|
|
5
|
+
import { OUTSTREAM } from '../src/video.js';
|
|
6
|
+
import {
|
|
7
|
+
isArray,
|
|
8
|
+
isNumber,
|
|
9
|
+
generateUUID,
|
|
10
|
+
parseSizesInput,
|
|
11
|
+
deepAccess,
|
|
12
|
+
getParameterByName,
|
|
13
|
+
getValue,
|
|
14
|
+
getBidIdParameter,
|
|
15
|
+
logError,
|
|
16
|
+
logWarn,
|
|
17
|
+
} from '../src/utils.js';
|
|
18
|
+
import { Renderer } from '../src/Renderer.js';
|
|
19
|
+
import find from 'core-js-pure/features/array/find.js';
|
|
20
|
+
|
|
21
|
+
// ------------------------------------
|
|
22
|
+
const BIDDER_CODE = 'cwire';
|
|
23
|
+
export const ENDPOINT_URL = 'https://embed.cwi.re/delivery/prebid';
|
|
24
|
+
export const RENDERER_URL = 'https://cdn.cwi.re/prebid/renderer/LATEST/renderer.min.js';
|
|
25
|
+
// ------------------------------------
|
|
26
|
+
export const CW_PAGE_VIEW_ID = generateUUID();
|
|
27
|
+
const LS_CWID_KEY = 'cw_cwid';
|
|
28
|
+
const CW_GROUPS_QUERY = 'cwgroups';
|
|
29
|
+
|
|
30
|
+
const storage = getStorageManager();
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* ------------------------------------
|
|
34
|
+
* ------------------------------------
|
|
35
|
+
* @param bid
|
|
36
|
+
* @returns {Array<string>}
|
|
37
|
+
*/
|
|
38
|
+
export function getSlotSizes(bid) {
|
|
39
|
+
return parseSizesInput(getAllMediaSizes(bid));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* ------------------------------------
|
|
44
|
+
* ------------------------------------
|
|
45
|
+
* @param bid
|
|
46
|
+
* @returns {*[]}
|
|
47
|
+
*/
|
|
48
|
+
export function getAllMediaSizes(bid) {
|
|
49
|
+
let playerSizes = deepAccess(bid, 'mediaTypes.video.playerSize');
|
|
50
|
+
let videoSizes = deepAccess(bid, 'mediaTypes.video.sizes');
|
|
51
|
+
let bannerSizes = deepAccess(bid, 'mediaTypes.banner.sizes');
|
|
52
|
+
|
|
53
|
+
const sizes = [];
|
|
54
|
+
|
|
55
|
+
if (isArray(playerSizes)) {
|
|
56
|
+
playerSizes.forEach((s) => {
|
|
57
|
+
sizes.push(s);
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (isArray(videoSizes)) {
|
|
62
|
+
videoSizes.forEach((s) => {
|
|
63
|
+
sizes.push(s);
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (isArray(bannerSizes)) {
|
|
68
|
+
bannerSizes.forEach((s) => {
|
|
69
|
+
sizes.push(s);
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
return sizes;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const getQueryVariable = (variable) => {
|
|
76
|
+
let value = getParameterByName(variable);
|
|
77
|
+
if (value === '') {
|
|
78
|
+
value = null;
|
|
79
|
+
}
|
|
80
|
+
return value;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* ------------------------------------
|
|
85
|
+
* ------------------------------------
|
|
86
|
+
* @param validBidRequests
|
|
87
|
+
* @returns {*[]}
|
|
88
|
+
*/
|
|
89
|
+
export const mapSlotsData = function(validBidRequests) {
|
|
90
|
+
const slots = [];
|
|
91
|
+
validBidRequests.forEach(bid => {
|
|
92
|
+
const bidObj = {};
|
|
93
|
+
// get the pacement and page ids
|
|
94
|
+
let placementId = getValue(bid.params, 'placementId');
|
|
95
|
+
let pageId = getValue(bid.params, 'pageId');
|
|
96
|
+
let adUnitElementId = getValue(bid.params, 'adUnitElementId');
|
|
97
|
+
// get the rest of the auction/bid/transaction info
|
|
98
|
+
bidObj.auctionId = getBidIdParameter('auctionId', bid);
|
|
99
|
+
bidObj.adUnitCode = getBidIdParameter('adUnitCode', bid);
|
|
100
|
+
bidObj.adUnitElementId = adUnitElementId;
|
|
101
|
+
bidObj.bidId = getBidIdParameter('bidId', bid);
|
|
102
|
+
bidObj.bidderRequestId = getBidIdParameter('bidderRequestId', bid);
|
|
103
|
+
bidObj.placementId = placementId;
|
|
104
|
+
bidObj.pageId = pageId;
|
|
105
|
+
bidObj.mediaTypes = getBidIdParameter('mediaTypes', bid);
|
|
106
|
+
bidObj.transactionId = getBidIdParameter('transactionId', bid);
|
|
107
|
+
bidObj.sizes = getSlotSizes(bid);
|
|
108
|
+
slots.push(bidObj);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return slots;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const spec = {
|
|
115
|
+
code: BIDDER_CODE,
|
|
116
|
+
supportedMediaTypes: [BANNER, VIDEO],
|
|
117
|
+
/**
|
|
118
|
+
* Determines whether or not the given bid request is valid.
|
|
119
|
+
*
|
|
120
|
+
* @param {BidRequest} bid The bid params to validate.
|
|
121
|
+
* @return boolean True if this is a valid bid, and false otherwise.
|
|
122
|
+
*/
|
|
123
|
+
isBidRequestValid: function(bid) {
|
|
124
|
+
bid.params = bid.params || {};
|
|
125
|
+
|
|
126
|
+
// if ad unit elemt id not provided - use adUnitCode by default
|
|
127
|
+
if (!bid.params.adUnitElementId) {
|
|
128
|
+
bid.params.adUnitElementId = bid.code;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (!bid.params.placementId || !isNumber(bid.params.placementId)) {
|
|
132
|
+
logError('placementId not provided or invalid');
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!bid.params.pageId || !isNumber(bid.params.pageId)) {
|
|
137
|
+
logError('pageId not provided');
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return true;
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* ------------------------------------
|
|
146
|
+
* Make a server request from the
|
|
147
|
+
* list of BidRequests.
|
|
148
|
+
* ------------------------------------
|
|
149
|
+
* @param {validBidRequests[]} - an array of bids
|
|
150
|
+
* @return ServerRequest Info describing the request to the server.
|
|
151
|
+
*/
|
|
152
|
+
buildRequests: function(validBidRequests, bidderRequest) {
|
|
153
|
+
let slots = [];
|
|
154
|
+
let referer;
|
|
155
|
+
try {
|
|
156
|
+
referer = getRefererInfo().referer;
|
|
157
|
+
slots = mapSlotsData(validBidRequests);
|
|
158
|
+
} catch (e) {
|
|
159
|
+
logWarn(e);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let refgroups = [];
|
|
163
|
+
|
|
164
|
+
const rgQuery = getQueryVariable(CW_GROUPS_QUERY);
|
|
165
|
+
if (rgQuery !== null) {
|
|
166
|
+
refgroups = rgQuery.split(',');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const localStorageCWID = storage.localStorageIsEnabled() ? storage.getDataFromLocalStorage(LS_CWID_KEY) : null;
|
|
170
|
+
|
|
171
|
+
const payload = {
|
|
172
|
+
cwid: localStorageCWID,
|
|
173
|
+
refgroups,
|
|
174
|
+
slots: slots,
|
|
175
|
+
httpRef: referer || '',
|
|
176
|
+
pageViewId: CW_PAGE_VIEW_ID,
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
method: 'POST',
|
|
181
|
+
url: ENDPOINT_URL,
|
|
182
|
+
data: payload
|
|
183
|
+
};
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Unpack the response from the server into a list of bids.
|
|
188
|
+
*
|
|
189
|
+
* @param {ServerResponse} serverResponse A successful response from the server.
|
|
190
|
+
* @return {Bid[]} An array of bids which were nested inside the server.
|
|
191
|
+
*/
|
|
192
|
+
interpretResponse: function(serverResponse, bidRequest) {
|
|
193
|
+
const bidResponses = [];
|
|
194
|
+
|
|
195
|
+
try {
|
|
196
|
+
if (typeof bidRequest.data === 'string') {
|
|
197
|
+
bidRequest.data = JSON.parse(bidRequest.data);
|
|
198
|
+
}
|
|
199
|
+
const serverBody = serverResponse.body;
|
|
200
|
+
serverBody.bids.forEach((br) => {
|
|
201
|
+
const bidReq = find(bidRequest.data.slots, bid => bid.bidId === br.requestId);
|
|
202
|
+
|
|
203
|
+
let mediaType = BANNER;
|
|
204
|
+
|
|
205
|
+
const bidResponse = {
|
|
206
|
+
requestId: br.requestId,
|
|
207
|
+
cpm: br.cpm,
|
|
208
|
+
bidderCode: BIDDER_CODE,
|
|
209
|
+
width: br.dimensions[0],
|
|
210
|
+
height: br.dimensions[1],
|
|
211
|
+
creativeId: br.creativeId,
|
|
212
|
+
currency: br.currency,
|
|
213
|
+
netRevenue: br.netRevenue,
|
|
214
|
+
ttl: br.ttl,
|
|
215
|
+
meta: {
|
|
216
|
+
advertiserDomains: br.adomains ? br.advertiserDomains : [],
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// ------------------------------------
|
|
222
|
+
// IF BANNER
|
|
223
|
+
// ------------------------------------
|
|
224
|
+
|
|
225
|
+
if (deepAccess(bidReq, 'mediaTypes.banner')) {
|
|
226
|
+
bidResponse.ad = br.html;
|
|
227
|
+
}
|
|
228
|
+
// ------------------------------------
|
|
229
|
+
// IF VIDEO
|
|
230
|
+
// ------------------------------------
|
|
231
|
+
if (deepAccess(bidReq, 'mediaTypes.video')) {
|
|
232
|
+
mediaType = VIDEO;
|
|
233
|
+
bidResponse.vastXml = br.vastXml;
|
|
234
|
+
bidResponse.videoScript = br.html;
|
|
235
|
+
const mediaTypeContext = deepAccess(bidReq, 'mediaTypes.video.context');
|
|
236
|
+
if (mediaTypeContext === OUTSTREAM) {
|
|
237
|
+
const r = Renderer.install({
|
|
238
|
+
id: bidResponse.requestId,
|
|
239
|
+
adUnitCode: bidReq.adUnitCode,
|
|
240
|
+
url: RENDERER_URL,
|
|
241
|
+
loaded: false,
|
|
242
|
+
config: {
|
|
243
|
+
...deepAccess(bidReq, 'mediaTypes.video'),
|
|
244
|
+
...deepAccess(br, 'outstream', {})
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// set renderer
|
|
249
|
+
try {
|
|
250
|
+
bidResponse.renderer = r;
|
|
251
|
+
bidResponse.renderer.setRender(function(bid) {
|
|
252
|
+
if (window.CWIRE && window.CWIRE.outstream) {
|
|
253
|
+
window.CWIRE.outstream.renderAd(bid);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
} catch (err) {
|
|
257
|
+
logWarn('Prebid Error calling setRender on newRenderer', err);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
bidResponse.mediaType = mediaType;
|
|
263
|
+
bidResponses.push(bidResponse);
|
|
264
|
+
});
|
|
265
|
+
} catch (e) {
|
|
266
|
+
logWarn(e);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return bidResponses;
|
|
270
|
+
},
|
|
271
|
+
}
|
|
272
|
+
registerBidder(spec);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
Module Name: C-WIRE Bid Adapter
|
|
4
|
+
Module Type: Adagio Adapter
|
|
5
|
+
Maintainer: dragan@cwire.ch
|
|
6
|
+
|
|
7
|
+
## Description
|
|
8
|
+
|
|
9
|
+
Connects to C-WIRE demand source to fetch bids.
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Below, the list of C-WIRE params and where they can be set.
|
|
15
|
+
|
|
16
|
+
| Param name | Global config | AdUnit config | Type | Required |
|
|
17
|
+
| ---------- | ------------- | ------------- | ---- | ---------|
|
|
18
|
+
| pageId | | x | number | YES |
|
|
19
|
+
| placementId | | x | number | YES |
|
|
20
|
+
| adUnitElementId | | x | string | NO |
|
|
21
|
+
|
|
22
|
+
### adUnit configuration
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
var adUnits = [
|
|
26
|
+
{
|
|
27
|
+
code: 'target_div_id', // REQUIRED
|
|
28
|
+
bids: [{
|
|
29
|
+
bidder: 'cwire',
|
|
30
|
+
mediaTypes: {
|
|
31
|
+
banner: {
|
|
32
|
+
sizes: [[1, 1]],
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
params: {
|
|
36
|
+
pageId: 1422, // required - number
|
|
37
|
+
placementId: 2211521, // required - number
|
|
38
|
+
adUnitElementId: 'other_div', // optional, div id to write to, if not set it will default to ad unit code
|
|
39
|
+
}
|
|
40
|
+
}]
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
```
|
|
@@ -81,6 +81,7 @@ let livewrappedAnalyticsAdapter = Object.assign(adapter({EMPTYURL, ANALYTICSTYPE
|
|
|
81
81
|
bidResponse.ttr = args.timeToRespond;
|
|
82
82
|
bidResponse.readyToSend = 1;
|
|
83
83
|
bidResponse.mediaType = args.mediaType == 'native' ? 2 : (args.mediaType == 'video' ? 4 : 1);
|
|
84
|
+
bidResponse.floorData = args.floorData;
|
|
84
85
|
if (!bidResponse.ttr) {
|
|
85
86
|
bidResponse.ttr = time - bidResponse.start;
|
|
86
87
|
}
|
|
@@ -108,6 +109,7 @@ let livewrappedAnalyticsAdapter = Object.assign(adapter({EMPTYURL, ANALYTICSTYPE
|
|
|
108
109
|
logInfo('LIVEWRAPPED_BID_WON:', args);
|
|
109
110
|
let wonBid = cache.auctions[args.auctionId].bids[args.requestId];
|
|
110
111
|
wonBid.won = true;
|
|
112
|
+
wonBid.floorData = args.floorData;
|
|
111
113
|
if (wonBid.sendStatus != 0) {
|
|
112
114
|
livewrappedAnalyticsAdapter.sendEvents();
|
|
113
115
|
}
|
|
@@ -226,7 +228,7 @@ function getResponses(gdpr, auctionIds) {
|
|
|
226
228
|
IsBid: bid.isBid,
|
|
227
229
|
mediaType: bid.mediaType,
|
|
228
230
|
gdpr: gdprPos,
|
|
229
|
-
floor: bid.floorData ? bid.floorData.floorValue :
|
|
231
|
+
floor: bid.lwFloor ? bid.lwFloor : (bid.floorData ? bid.floorData.floorValue : undefined),
|
|
230
232
|
floorCur: bid.floorData ? bid.floorData.floorCurrency : undefined,
|
|
231
233
|
auctionId: auctionIdPos,
|
|
232
234
|
auc: bid.auc,
|
|
@@ -263,7 +265,7 @@ function getWins(gdpr, auctionIds) {
|
|
|
263
265
|
cpm: bid.cpm,
|
|
264
266
|
mediaType: bid.mediaType,
|
|
265
267
|
gdpr: gdprPos,
|
|
266
|
-
floor: bid.floorData ? bid.floorData.floorValue :
|
|
268
|
+
floor: bid.lwFloor ? bid.lwFloor : (bid.floorData ? bid.floorData.floorValue : undefined),
|
|
267
269
|
floorCur: bid.floorData ? bid.floorData.floorCurrency : undefined,
|
|
268
270
|
auctionId: auctionIdPos,
|
|
269
271
|
auc: bid.auc,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import find from 'core-js-pure/features/array/find.js';
|
|
2
|
+
import arrayFrom from 'core-js-pure/features/array/from';
|
|
2
3
|
import { getWindowTop, isFn, logWarn, getDNT, deepAccess, isArray, inIframe, mergeDeep, isStr, isEmpty, deepSetValue, deepClone, parseUrl, cleanObj, logError, triggerPixel, isInteger, isNumber } from '../src/utils.js';
|
|
3
4
|
import { registerBidder } from '../src/adapters/bidderFactory.js';
|
|
4
5
|
import { config } from '../src/config.js';
|
|
@@ -54,7 +55,7 @@ const ORTB_VIDEO_PARAMS = {
|
|
|
54
55
|
skipmin: value => isInteger(value),
|
|
55
56
|
skipafter: value => isInteger(value),
|
|
56
57
|
sequence: value => isInteger(value),
|
|
57
|
-
battr: value => Array.isArray(value) && value.every(v =>
|
|
58
|
+
battr: value => Array.isArray(value) && value.every(v => arrayFrom({length: 17}, (_, i) => i + 1).indexOf(v) !== -1),
|
|
58
59
|
maxextended: value => isInteger(value),
|
|
59
60
|
minbitrate: value => isInteger(value),
|
|
60
61
|
maxbitrate: value => isInteger(value),
|
|
@@ -71,7 +71,7 @@ export const spec = {
|
|
|
71
71
|
// Track if we've already requested for this ad unit code
|
|
72
72
|
adUnitsRequested[adUnit.adUnitCode] =
|
|
73
73
|
adUnitsRequested[adUnit.adUnitCode] !== undefined
|
|
74
|
-
? adUnitsRequested[adUnit.adUnitCode]
|
|
74
|
+
? adUnitsRequested[adUnit.adUnitCode] + 1
|
|
75
75
|
: 0
|
|
76
76
|
return {
|
|
77
77
|
adUnitCode: adUnit.adUnitCode,
|