prebid.js 5.18.0 → 6.1.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.
Files changed (150) hide show
  1. package/.babelrc.js +1 -10
  2. package/README.md +3 -1
  3. package/browsers.json +1 -8
  4. package/gulpfile.js +1 -0
  5. package/integrationExamples/gpt/akamaidap_segments_example.html +132 -0
  6. package/modules/.submodules.json +1 -0
  7. package/modules/adfBidAdapter.js +21 -16
  8. package/modules/adheseBidAdapter.js +7 -2
  9. package/modules/adkernelBidAdapter.js +1 -0
  10. package/modules/adlivetechBidAdapter.md +61 -0
  11. package/modules/adomikAnalyticsAdapter.js +10 -4
  12. package/modules/adtelligentBidAdapter.js +2 -1
  13. package/modules/airgridRtdProvider.js +1 -1
  14. package/modules/akamaiDapRtdProvider.js +474 -0
  15. package/modules/akamaiDapRtdProvider.md +47 -0
  16. package/modules/appnexusBidAdapter.js +9 -3
  17. package/modules/atsAnalyticsAdapter.js +67 -46
  18. package/modules/atsAnalyticsAdapter.md +1 -0
  19. package/modules/betweenBidAdapter.js +20 -3
  20. package/modules/browsiRtdProvider.js +106 -18
  21. package/modules/cleanioRtdProvider.js +192 -0
  22. package/modules/cleanioRtdProvider.md +59 -0
  23. package/modules/codefuelBidAdapter.js +181 -0
  24. package/modules/codefuelBidAdapter.md +111 -0
  25. package/modules/connectIdSystem.js +104 -0
  26. package/modules/connectIdSystem.md +33 -0
  27. package/modules/datablocksBidAdapter.js +3 -3
  28. package/modules/deepintentBidAdapter.js +107 -10
  29. package/modules/deepintentBidAdapter.md +36 -1
  30. package/modules/deltaprojectsBidAdapter.js +252 -0
  31. package/modules/deltaprojectsBidAdapter.md +32 -0
  32. package/modules/engageyaBidAdapter.js +171 -0
  33. package/modules/glimpseBidAdapter.js +31 -16
  34. package/modules/gptPreAuction.js +11 -5
  35. package/modules/gridBidAdapter.js +1 -0
  36. package/modules/gumgumBidAdapter.js +8 -0
  37. package/modules/id5IdSystem.md +6 -6
  38. package/modules/imRtdProvider.js +31 -0
  39. package/modules/inskinBidAdapter.js +7 -3
  40. package/modules/ixBidAdapter.js +174 -22
  41. package/modules/jixieBidAdapter.js +8 -2
  42. package/modules/justpremiumBidAdapter.js +6 -1
  43. package/modules/limelightDigitalBidAdapter.js +22 -2
  44. package/modules/livewrappedAnalyticsAdapter.js +49 -1
  45. package/modules/merkleIdSystem.js +5 -0
  46. package/modules/multibid/index.js +3 -3
  47. package/modules/nativoBidAdapter.js +32 -2
  48. package/modules/nextMillenniumBidAdapter.js +12 -3
  49. package/modules/oguryBidAdapter.js +16 -2
  50. package/modules/openxBidAdapter.js +40 -23
  51. package/modules/operaadsBidAdapter.js +21 -1
  52. package/modules/otmBidAdapter.js +146 -0
  53. package/modules/otmBidAdapter.md +27 -26
  54. package/modules/outbrainBidAdapter.js +5 -0
  55. package/modules/playwireBidAdapter.md +61 -0
  56. package/modules/prebidServerBidAdapter/index.js +3 -3
  57. package/modules/publinkIdSystem.js +11 -6
  58. package/modules/pubmaticBidAdapter.js +2 -0
  59. package/modules/rtdModule/index.js +2 -2
  60. package/modules/saambaaBidAdapter.js +420 -0
  61. package/modules/saambaaBidAdapter.md +65 -68
  62. package/modules/seedtagBidAdapter.js +6 -0
  63. package/modules/smaatoBidAdapter.js +6 -1
  64. package/modules/sonobiBidAdapter.js +7 -0
  65. package/modules/sortableBidAdapter.js +1 -0
  66. package/modules/sspBCBidAdapter.js +34 -3
  67. package/modules/teadsBidAdapter.js +3 -0
  68. package/modules/tripleliftBidAdapter.js +22 -5
  69. package/modules/trustxBidAdapter.js +18 -7
  70. package/modules/undertoneBidAdapter.js +9 -5
  71. package/modules/undertoneBidAdapter.md +5 -1
  72. package/modules/userId/eids.js +18 -0
  73. package/modules/userId/eids.md +7 -0
  74. package/modules/userId/userId.md +12 -0
  75. package/modules/ventesBidAdapter.js +370 -0
  76. package/modules/ventesBidAdapter.md +94 -0
  77. package/modules/videobyteBidAdapter.js +13 -6
  78. package/modules/videobyteBidAdapter.md +49 -0
  79. package/modules/vidoomyBidAdapter.js +51 -100
  80. package/modules/visxBidAdapter.js +1 -1
  81. package/modules/yahoosspBidAdapter.js +6 -6
  82. package/modules/yieldlabBidAdapter.js +41 -10
  83. package/modules/yieldlabBidAdapter.md +91 -48
  84. package/modules/yieldmoSyntheticInventoryModule.js +46 -0
  85. package/modules/yieldmoSyntheticInventoryModule.md +68 -0
  86. package/package.json +6 -1
  87. package/src/adapterManager.js +19 -8
  88. package/src/adapters/bidderFactory.js +4 -3
  89. package/src/auction.js +11 -11
  90. package/src/constants.json +1 -0
  91. package/src/secureCreatives.js +6 -7
  92. package/src/targeting.js +11 -9
  93. package/test/spec/modules/adfBidAdapter_spec.js +83 -29
  94. package/test/spec/modules/adheseBidAdapter_spec.js +27 -1
  95. package/test/spec/modules/adomikAnalyticsAdapter_spec.js +3 -1
  96. package/test/spec/modules/adtelligentBidAdapter_spec.js +1 -0
  97. package/test/spec/modules/akamaiDapRtdProvider_spec.js +246 -0
  98. package/test/spec/modules/appnexusBidAdapter_spec.js +16 -1
  99. package/test/spec/modules/atsAnalyticsAdapter_spec.js +42 -9
  100. package/test/spec/modules/betweenBidAdapter_spec.js +41 -0
  101. package/test/spec/modules/browsiRtdProvider_spec.js +62 -7
  102. package/test/spec/modules/cleanioRtdProvider_spec.js +188 -0
  103. package/test/spec/modules/codefuelBidAdapter_spec.js +316 -0
  104. package/test/spec/modules/connectIdSystem_spec.js +189 -0
  105. package/test/spec/modules/datablocksBidAdapter_spec.js +3 -3
  106. package/test/spec/modules/deepintentBidAdapter_spec.js +153 -3
  107. package/test/spec/modules/deltaprojectsBidAdapter_spec.js +399 -0
  108. package/test/spec/modules/engageyaBidAdapter_spec.js +422 -0
  109. package/test/spec/modules/eplanningBidAdapter_spec.js +8 -8
  110. package/test/spec/modules/glimpseBidAdapter_spec.js +33 -0
  111. package/test/spec/modules/gptPreAuction_spec.js +58 -4
  112. package/test/spec/modules/gumgumBidAdapter_spec.js +5 -1
  113. package/test/spec/modules/imRtdProvider_spec.js +25 -0
  114. package/test/spec/modules/ixBidAdapter_spec.js +298 -5
  115. package/test/spec/modules/jixieBidAdapter_spec.js +13 -11
  116. package/test/spec/modules/justpremiumBidAdapter_spec.js +9 -2
  117. package/test/spec/modules/konduitWrapper_spec.js +0 -1
  118. package/test/spec/modules/limelightDigitalBidAdapter_spec.js +155 -1
  119. package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +52 -7
  120. package/test/spec/modules/merkleIdSystem_spec.js +18 -0
  121. package/test/spec/modules/multibid_spec.js +31 -31
  122. package/test/spec/modules/nativoBidAdapter_spec.js +35 -18
  123. package/test/spec/modules/nextMillenniumBidAdapter_spec.js +13 -1
  124. package/test/spec/modules/oguryBidAdapter_spec.js +66 -23
  125. package/test/spec/modules/openxBidAdapter_spec.js +90 -13
  126. package/test/spec/modules/operaadsBidAdapter_spec.js +38 -6
  127. package/test/spec/modules/otmBidAdapter_spec.js +67 -0
  128. package/test/spec/modules/outbrainBidAdapter_spec.js +18 -0
  129. package/test/spec/modules/prebidServerBidAdapter_spec.js +19 -2
  130. package/test/spec/modules/publinkIdSystem_spec.js +6 -6
  131. package/test/spec/modules/seedtagBidAdapter_spec.js +3 -0
  132. package/test/spec/modules/smaatoBidAdapter_spec.js +30 -0
  133. package/test/spec/modules/sonobiBidAdapter_spec.js +34 -1
  134. package/test/spec/modules/sortableBidAdapter_spec.js +11 -0
  135. package/test/spec/modules/sspBCBidAdapter_spec.js +33 -3
  136. package/test/spec/modules/teadsBidAdapter_spec.js +132 -0
  137. package/test/spec/modules/tripleliftBidAdapter_spec.js +128 -0
  138. package/test/spec/modules/trustxBidAdapter_spec.js +45 -3
  139. package/test/spec/modules/undertoneBidAdapter_spec.js +52 -0
  140. package/test/spec/modules/ventesBidAdapter_spec.js +845 -0
  141. package/test/spec/modules/videobyteBidAdapter_spec.js +2 -2
  142. package/test/spec/modules/vidoomyBidAdapter_spec.js +32 -13
  143. package/test/spec/modules/visxBidAdapter_spec.js +1 -1
  144. package/test/spec/modules/yieldlabBidAdapter_spec.js +81 -0
  145. package/test/spec/modules/yieldmoSyntheticInventoryModule_spec.js +89 -0
  146. package/test/spec/unit/core/adapterManager_spec.js +56 -6
  147. package/test/spec/unit/core/bidderFactory_spec.js +61 -1
  148. package/test/spec/unit/pbjs_api_spec.js +37 -2
  149. package/test/spec/unit/secureCreatives_spec.js +54 -25
  150. package/wdio.conf.js +1 -1
@@ -8,7 +8,7 @@ Maintainer: prebid@deepintent.com
8
8
 
9
9
  # Description
10
10
 
11
- Deepintent currently supports the BANNER type ads through prebid js
11
+ Deepintent currently supports the BANNER and VIDEO type ads through prebid js
12
12
 
13
13
  Module that connects to Deepintent's demand sources.
14
14
 
@@ -40,6 +40,41 @@ Module that connects to Deepintent's demand sources.
40
40
  ];
41
41
  ```
42
42
 
43
+ # Sample Video Ad Unit
44
+ ```
45
+ var adVideoAdUnits = [
46
+ {
47
+ code: 'test-div-video',
48
+ mediaTypes: {
49
+ video: {
50
+ playerSize: [640, 480], // required
51
+ context: 'instream' //required
52
+ }
53
+ },
54
+ bids: [{
55
+ bidder: 'deepintent',
56
+ params: {
57
+ tagId: '1300', // Required parameter // required
58
+ video: {
59
+ mimes: ['video/mp4','video/x-flv'], // required
60
+ skippable: true, // optional
61
+ minduration: 5, // optional
62
+ maxduration: 30, // optional
63
+ startdelay: 5, // optional
64
+ playbackmethod: [1,3], // optional
65
+ api: [ 1, 2 ], // optional
66
+ protocols: [ 2, 3 ], // optional
67
+ battr: [ 13, 14 ], // optional
68
+ linearity: 1, // optional
69
+ placement: 2, // optional
70
+ minbitrate: 10, // optional
71
+ maxbitrate: 10 // optional
72
+ }
73
+ }
74
+ }]
75
+ }]
76
+ ```
77
+
43
78
  ###Recommended User Sync Configuration
44
79
 
45
80
  ```javascript
@@ -0,0 +1,252 @@
1
+ import { registerBidder } from '../src/adapters/bidderFactory.js';
2
+ import { BANNER } from '../src/mediaTypes.js';
3
+ import {
4
+ _each, _map, isFn, isNumber, createTrackPixelHtml, deepAccess, parseUrl, logWarn, logError
5
+ } from '../src/utils.js';
6
+ import {config} from '../src/config.js';
7
+
8
+ export const BIDDER_CODE = 'deltaprojects';
9
+ export const BIDDER_ENDPOINT_URL = 'https://d5p.de17a.com/dogfight/prebid';
10
+ export const USERSYNC_URL = 'https://userservice.de17a.com/getuid/prebid';
11
+
12
+ /** -- isBidRequestValid --**/
13
+ function isBidRequestValid(bid) {
14
+ if (!bid) return false;
15
+
16
+ if (bid.bidder !== BIDDER_CODE) return false;
17
+
18
+ // publisher id is required
19
+ const publisherId = deepAccess(bid, 'params.publisherId')
20
+ if (!publisherId) {
21
+ logError('Invalid bid request, missing publisher id in params');
22
+ return false;
23
+ }
24
+
25
+ return true;
26
+ }
27
+
28
+ /** -- Build requests --**/
29
+ function buildRequests(validBidRequests, bidderRequest) {
30
+ /** == shared ==**/
31
+ // -- build id
32
+ const id = bidderRequest.auctionId;
33
+
34
+ // -- build site
35
+ const loc = parseUrl(bidderRequest.refererInfo.referer);
36
+ const publisherId = setOnAny(validBidRequests, 'params.publisherId');
37
+ const siteId = setOnAny(validBidRequests, 'params.siteId');
38
+ const site = {
39
+ id: siteId,
40
+ domain: loc.hostname,
41
+ page: loc.href,
42
+ ref: loc.href,
43
+ publisher: { id: publisherId },
44
+ };
45
+
46
+ // -- build device
47
+ const ua = navigator.userAgent;
48
+ const device = {
49
+ ua,
50
+ w: screen.width,
51
+ h: screen.height
52
+ }
53
+
54
+ // -- build user, reg
55
+ let user = { ext: {} };
56
+ const regs = { ext: {} };
57
+ const gdprConsent = bidderRequest && bidderRequest.gdprConsent;
58
+ if (gdprConsent) {
59
+ user.ext = { consent: gdprConsent.consentString };
60
+ if (typeof gdprConsent.gdprApplies == 'boolean') {
61
+ regs.ext.gdpr = gdprConsent.gdprApplies ? 1 : 0
62
+ }
63
+ }
64
+
65
+ // -- build tmax
66
+ let tmax = (bidderRequest && bidderRequest.timeout > 0) ? bidderRequest.timeout : undefined;
67
+
68
+ // build bid specific
69
+ return validBidRequests.map(validBidRequest => {
70
+ const openRTBRequest = buildOpenRTBRequest(validBidRequest, id, site, device, user, tmax, regs);
71
+ return {
72
+ method: 'POST',
73
+ url: BIDDER_ENDPOINT_URL,
74
+ data: openRTBRequest,
75
+ options: { contentType: 'application/json' },
76
+ bids: [validBidRequest],
77
+ };
78
+ });
79
+ }
80
+
81
+ function buildOpenRTBRequest(validBidRequest, id, site, device, user, tmax, regs) {
82
+ // build cur
83
+ const currency = config.getConfig('currency.adServerCurrency') || deepAccess(validBidRequest, 'params.currency');
84
+ const cur = currency && [currency];
85
+
86
+ // build impression
87
+ const impression = buildImpression(validBidRequest, currency);
88
+
89
+ // build test
90
+ const test = deepAccess(validBidRequest, 'params.test') ? 1 : 0
91
+
92
+ const at = 1
93
+
94
+ // build source
95
+ const source = {
96
+ tid: validBidRequest.transactionId,
97
+ fd: 1,
98
+ }
99
+
100
+ return {
101
+ id,
102
+ at,
103
+ imp: [impression],
104
+ site,
105
+ device,
106
+ user,
107
+ test,
108
+ tmax,
109
+ cur,
110
+ source,
111
+ regs,
112
+ ext: {},
113
+ };
114
+ }
115
+
116
+ function buildImpression(bid, currency) {
117
+ const impression = {
118
+ id: bid.bidId,
119
+ tagid: bid.params.tagId,
120
+ ext: {},
121
+ };
122
+
123
+ const bannerMediaType = deepAccess(bid, `mediaTypes.${BANNER}`);
124
+ impression.banner = buildImpressionBanner(bid, bannerMediaType);
125
+
126
+ // bid floor
127
+ const bidFloor = getBidFloor(bid, BANNER, '*', currency);
128
+ if (bidFloor) {
129
+ impression.bidfloor = bidFloor.floor;
130
+ impression.bidfloorcur = bidFloor.currency;
131
+ }
132
+
133
+ return impression;
134
+ }
135
+
136
+ function buildImpressionBanner(bid, bannerMediaType) {
137
+ const bannerSizes = (bannerMediaType && bannerMediaType.sizes) || bid.sizes;
138
+ return {
139
+ format: _map(bannerSizes, ([width, height]) => ({ w: width, h: height })),
140
+ };
141
+ }
142
+
143
+ /** -- Interpret response --**/
144
+ function interpretResponse(serverResponse) {
145
+ if (!serverResponse.body) {
146
+ logWarn('Response body is invalid, return !!');
147
+ return [];
148
+ }
149
+
150
+ const { body: { id, seatbid, cur } } = serverResponse;
151
+ if (!id || !seatbid) {
152
+ logWarn('Id / seatbid of response is invalid, return !!');
153
+ return [];
154
+ }
155
+
156
+ const bidResponses = [];
157
+
158
+ _each(seatbid, seatbid => {
159
+ _each(seatbid.bid, bid => {
160
+ const bidObj = {
161
+ requestId: bid.impid,
162
+ cpm: parseFloat(bid.price),
163
+ width: parseInt(bid.w),
164
+ height: parseInt(bid.h),
165
+ creativeId: bid.crid || bid.id,
166
+ dealId: bid.dealid || null,
167
+ currency: cur,
168
+ netRevenue: true,
169
+ ttl: 60,
170
+ };
171
+
172
+ bidObj.mediaType = BANNER;
173
+ bidObj.ad = bid.adm;
174
+ if (bid.nurl) {
175
+ bidObj.ad += createTrackPixelHtml(decodeURIComponent(bid.nurl));
176
+ }
177
+ if (bid.ext) {
178
+ bidObj[BIDDER_CODE] = bid.ext;
179
+ }
180
+ bidResponses.push(bidObj);
181
+ });
182
+ });
183
+ return bidResponses;
184
+ }
185
+
186
+ /** -- On Bid Won -- **/
187
+ function onBidWon(bid) {
188
+ let cpm = bid.cpm;
189
+ if (bid.currency && bid.currency !== bid.originalCurrency && typeof bid.getCpmInNewCurrency === 'function') {
190
+ cpm = bid.getCpmInNewCurrency(bid.originalCurrency);
191
+ }
192
+ const wonPrice = Math.round(cpm * 1000000);
193
+ const wonPriceMacroPatten = /\$\{AUCTION_PRICE:B64\}/g;
194
+ bid.ad = bid.ad.replace(wonPriceMacroPatten, wonPrice);
195
+ }
196
+
197
+ /** -- Get user syncs --**/
198
+ function getUserSyncs(syncOptions, serverResponses, gdprConsent) {
199
+ const syncs = []
200
+
201
+ if (syncOptions.pixelEnabled) {
202
+ let gdprParams;
203
+ if (gdprConsent) {
204
+ if (typeof gdprConsent.gdprApplies === 'boolean') {
205
+ gdprParams = `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
206
+ } else {
207
+ gdprParams = `?gdpr_consent=${gdprConsent.consentString}`;
208
+ }
209
+ } else {
210
+ gdprParams = '';
211
+ }
212
+ syncs.push({
213
+ type: 'image',
214
+ url: USERSYNC_URL + gdprParams
215
+ });
216
+ }
217
+ return syncs;
218
+ }
219
+
220
+ /** -- Get bid floor --**/
221
+ export function getBidFloor(bid, mediaType, size, currency) {
222
+ if (isFn(bid.getFloor)) {
223
+ const bidFloorCurrency = currency || 'USD';
224
+ const bidFloor = bid.getFloor({currency: bidFloorCurrency, mediaType: mediaType, size: size});
225
+ if (isNumber(bidFloor.floor)) {
226
+ return bidFloor;
227
+ }
228
+ }
229
+ }
230
+
231
+ /** -- Helper methods --**/
232
+ function setOnAny(collection, key) {
233
+ for (let i = 0, result; i < collection.length; i++) {
234
+ result = deepAccess(collection[i], key);
235
+ if (result) {
236
+ return result;
237
+ }
238
+ }
239
+ }
240
+
241
+ /** -- Register -- */
242
+ export const spec = {
243
+ code: BIDDER_CODE,
244
+ supportedMediaTypes: [BANNER],
245
+ isBidRequestValid,
246
+ buildRequests,
247
+ interpretResponse,
248
+ onBidWon,
249
+ getUserSyncs,
250
+ };
251
+
252
+ registerBidder(spec);
@@ -0,0 +1,32 @@
1
+ # Overview
2
+
3
+ ```
4
+ Module Name: Delta Projects Bid Adapter
5
+ Module Type: Bidder Adapter
6
+ Maintainer: dev@deltaprojects.com
7
+ ```
8
+
9
+ # Description
10
+
11
+ Connects to Delta Projects DSP for bids.
12
+
13
+ # Test Parameters
14
+ ```
15
+ // define banner unit
16
+ var bannerUnit = {
17
+ code: 'div-gpt-ad-1460505748561-0',
18
+ mediaTypes: {
19
+ banner: {
20
+ sizes: [[300, 250], [300,600]],
21
+ }
22
+ },
23
+ // Replace this object to test a new Adapter!
24
+ bids: [{
25
+ bidder: 'deltaprojects',
26
+ params: {
27
+ publisherId: '4' //required
28
+ }
29
+ }]
30
+ };
31
+ ```
32
+
@@ -0,0 +1,171 @@
1
+ import { BANNER, NATIVE } from '../src/mediaTypes.js';
2
+ import { createTrackPixelHtml } from '../src/utils.js';
3
+
4
+ const {
5
+ registerBidder
6
+ } = require('../src/adapters/bidderFactory.js');
7
+ const BIDDER_CODE = 'engageya';
8
+ const ENDPOINT_URL = 'https://recs.engageya.com/rec-api/getrecs.json';
9
+ const ENDPOINT_METHOD = 'GET';
10
+ const SUPPORTED_SIZES = [
11
+ [100, 75], [236, 202], [100, 100], [130, 130], [200, 200], [250, 250], [300, 272], [300, 250], [300, 230], [300, 214], [300, 187], [300, 166], [300, 150], [300, 133], [300, 120], [400, 200], [300, 200], [250, 377], [620, 410], [207, 311], [310, 166], [310, 333], [190, 106], [228, 132], [300, 174], [80, 60], [600, 500], [600, 600], [1080, 610], [1080, 610], [624, 350], [650, 1168], [1080, 1920], [300, 374]
12
+ ];
13
+
14
+ function getPageUrl(bidRequest, bidderRequest) {
15
+ if (bidRequest.params.pageUrl && bidRequest.params.pageUrl != '[PAGE_URL]') {
16
+ return bidRequest.params.pageUrl;
17
+ }
18
+ if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) {
19
+ return bidderRequest.refererInfo.referer;
20
+ }
21
+ const pageUrl = (isInIframe() && document.referrer)
22
+ ? document.referrer
23
+ : window.location.href;
24
+ return encodeURIComponent(pageUrl);
25
+ }
26
+
27
+ function isInIframe() {
28
+ try {
29
+ var isInIframe = (window.self !== window.top);
30
+ } catch (e) {
31
+ isInIframe = true;
32
+ }
33
+ return isInIframe;
34
+ }
35
+
36
+ function getImageSrc(rec) {
37
+ return rec.thumbnail_path.indexOf('http') === -1 ? 'https:' + rec.thumbnail_path : rec.thumbnail_path;
38
+ }
39
+
40
+ function getImpressionTrackers(rec, response) {
41
+ const responseTrackers = [response.viewPxl];
42
+ if (!rec.trackers) {
43
+ return responseTrackers;
44
+ }
45
+ const impressionTrackers = rec.trackers.impressionPixels || [];
46
+ const viewTrackers = rec.trackers.viewPixels || [];
47
+ return [...impressionTrackers, ...viewTrackers, ...responseTrackers];
48
+ }
49
+
50
+ function parseNativeResponse(rec, response) {
51
+ return {
52
+ title: rec.title,
53
+ body: '',
54
+ image: {
55
+ url: getImageSrc(rec),
56
+ width: response.imageWidth,
57
+ height: response.imageHeight
58
+ },
59
+ privacyLink: '',
60
+ clickUrl: rec.clickUrl,
61
+ displayUrl: rec.url,
62
+ cta: '',
63
+ sponsoredBy: rec.displayName,
64
+ impressionTrackers: getImpressionTrackers(rec, response),
65
+ };
66
+ }
67
+
68
+ function parseBannerResponse(rec, response) {
69
+ if (rec.tag) {
70
+ return rec.tag;
71
+ }
72
+ let style;
73
+ try {
74
+ let additionalData = JSON.parse(response.widget.additionalData);
75
+ const css = additionalData.css || '';
76
+ style = css ? `<style>${css}</style>` : '';
77
+ } catch (e) {
78
+ style = '';
79
+ }
80
+ const title = rec.title && rec.title.trim() ? `<div class="eng_tag_ttl" style="display: none">${rec.title}</div>` : '';
81
+ const displayName = rec.displayName && title ? `<div class="eng_tag_brnd" style="display: none">${rec.displayName}</div>` : '';
82
+ const trackers = getImpressionTrackers(rec, response)
83
+ .map(createTrackPixelHtml)
84
+ .join('');
85
+ return `<html><body>${style}<div id="ENG_TAG"><a href="${rec.clickUrl}" target=_blank><img class="eng_tag_img" src="${getImageSrc(rec)}" style="width:${response.imageWidth}px;height:${response.imageHeight}px;" alt="${rec.title}"/>${displayName}${title}</a>${trackers}</div></body></html>`;
86
+ }
87
+
88
+ function getImageSize(bidRequest) {
89
+ if (bidRequest.sizes && bidRequest.sizes.length > 0) {
90
+ return bidRequest.sizes[0];
91
+ } else if (bidRequest.nativeParams && bidRequest.nativeParams.image && bidRequest.nativeParams.image.sizes) {
92
+ return bidRequest.nativeParams.image.sizes;
93
+ }
94
+ return [-1, -1];
95
+ }
96
+
97
+ function isValidSize([width, height]) {
98
+ if (!width || !height) {
99
+ return false;
100
+ }
101
+ return SUPPORTED_SIZES.some(([supportedWidth, supportedHeight]) => supportedWidth === width && supportedHeight === height);
102
+ }
103
+
104
+ export const spec = {
105
+ code: BIDDER_CODE,
106
+ supportedMediaTypes: [BANNER, NATIVE],
107
+
108
+ isBidRequestValid: function (bidRequest) {
109
+ return bidRequest &&
110
+ bidRequest.params &&
111
+ bidRequest.params.hasOwnProperty('widgetId') &&
112
+ bidRequest.params.hasOwnProperty('websiteId') &&
113
+ !isNaN(bidRequest.params.widgetId) &&
114
+ !isNaN(bidRequest.params.websiteId) &&
115
+ isValidSize(getImageSize(bidRequest));
116
+ },
117
+
118
+ buildRequests: function (validBidRequests, bidderRequest) {
119
+ if (!validBidRequests) {
120
+ return [];
121
+ }
122
+ return validBidRequests.map(bidRequest => {
123
+ if (bidRequest.params) {
124
+ const mediaType = bidRequest.hasOwnProperty('nativeParams') ? 1 : 2;
125
+ const [imageWidth, imageHeight] = getImageSize(bidRequest);
126
+ const widgetId = bidRequest.params.widgetId;
127
+ const websiteId = bidRequest.params.websiteId;
128
+ const pageUrl = getPageUrl(bidRequest, bidderRequest);
129
+ const bidId = bidRequest.bidId;
130
+ let finalUrl = ENDPOINT_URL + '?pubid=0&webid=' + websiteId + '&wid=' + widgetId + '&url=' + pageUrl + '&ireqid=' + bidId + '&pbtpid=' + mediaType + '&imw=' + imageWidth + '&imh=' + imageHeight;
131
+ if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprApplies && bidderRequest.consentString) {
132
+ finalUrl += '&is_gdpr=1&gdpr_consent=' + bidderRequest.consentString;
133
+ }
134
+ return {
135
+ url: finalUrl,
136
+ method: ENDPOINT_METHOD,
137
+ data: ''
138
+ };
139
+ }
140
+ }).filter(Boolean);
141
+ },
142
+
143
+ interpretResponse: function (serverResponse, bidRequest) {
144
+ if (!serverResponse.body || !serverResponse.body.recs || !serverResponse.body.recs.length) {
145
+ return [];
146
+ }
147
+ var response = serverResponse.body;
148
+ var isNative = response.pbtypeId == 1;
149
+ return response.recs.map(rec => {
150
+ let bid = {
151
+ requestId: response.ireqId,
152
+ width: response.imageWidth,
153
+ height: response.imageHeight,
154
+ creativeId: rec.postId,
155
+ cpm: rec.pecpm || (rec.ecpm / 100),
156
+ currency: 'USD',
157
+ netRevenue: !!rec.pecpm,
158
+ ttl: 360,
159
+ meta: { advertiserDomains: rec.domain ? [rec.domain] : [] },
160
+ }
161
+ if (isNative) {
162
+ bid.native = parseNativeResponse(rec, response);
163
+ } else {
164
+ bid.ad = parseBannerResponse(rec, response);
165
+ }
166
+ return bid;
167
+ });
168
+ }
169
+ };
170
+
171
+ registerBidder(spec);
@@ -1,19 +1,22 @@
1
1
  import { BANNER } from '../src/mediaTypes.js'
2
+ import { config } from '../src/config.js'
2
3
  import { getStorageManager } from '../src/storageManager.js'
3
4
  import { isArray } from '../src/utils.js'
4
5
  import { registerBidder } from '../src/adapters/bidderFactory.js'
5
6
 
6
7
  const storageManager = getStorageManager()
7
8
 
9
+ const GVLID = 1012
8
10
  const BIDDER_CODE = 'glimpse'
9
11
  const ENDPOINT = 'https://api.glimpsevault.io/ads/serving/public/v1/prebid'
10
12
  const LOCAL_STORAGE_KEY = {
11
- glimpse: {
13
+ vault: {
12
14
  jwt: 'gp_vault_jwt',
13
15
  },
14
16
  }
15
17
 
16
18
  export const spec = {
19
+ gvlid: GVLID,
17
20
  code: BIDDER_CODE,
18
21
  supportedMediaTypes: [BANNER],
19
22
 
@@ -37,20 +40,28 @@ export const spec = {
37
40
  * @returns {ServerRequest}
38
41
  */
39
42
  buildRequests: (validBidRequests, bidderRequest) => {
40
- const networkId = window.networkId || -1
41
- const bids = validBidRequests.map(processBidRequest)
43
+ const demo = config.getConfig('glimpse.demo') || false
44
+ const account = config.getConfig('glimpse.account') || -1
45
+ const demand = config.getConfig('glimpse.demand') || 'glimpse'
46
+ const keywords = config.getConfig('glimpse.keywords') || {}
47
+
48
+ const auth = getVaultJwt()
42
49
  const referer = getReferer(bidderRequest)
43
50
  const gdprConsent = getGdprConsentChoice(bidderRequest)
44
- const jwt = getVaultJwt()
51
+ const bids = validBidRequests.map((bidRequest) => {
52
+ return processBidRequest(bidRequest, keywords)
53
+ })
45
54
 
46
55
  const data = {
47
- auth: jwt,
56
+ auth,
48
57
  data: {
49
58
  bidderCode: spec.code,
50
- networkId,
51
- bids,
59
+ demo,
60
+ account,
61
+ demand,
52
62
  referer,
53
63
  gdprConsent,
64
+ bids,
54
65
  }
55
66
  }
56
67
 
@@ -65,10 +76,9 @@ export const spec = {
65
76
  /**
66
77
  * Parse response from Glimpse server
67
78
  * @param bidResponse {ServerResponse}
68
- * @param bidRequest {BidRequest}
69
79
  * @returns {Bid[]}
70
80
  */
71
- interpretResponse: (bidResponse, bidRequest) => {
81
+ interpretResponse: (bidResponse) => {
72
82
  const isValidResponse = isValidBidResponse(bidResponse)
73
83
 
74
84
  if (isValidResponse) {
@@ -81,16 +91,20 @@ export const spec = {
81
91
  },
82
92
  }
83
93
 
84
- function processBidRequest(bidRequest) {
94
+ function processBidRequest(bidRequest, globalKeywords) {
85
95
  const sizes = normalizeSizes(bidRequest.sizes)
86
- const keywords = bidRequest.params.keywords || []
96
+ const bidKeywords = bidRequest.params.keywords || {}
97
+ const keywords = {
98
+ ...globalKeywords,
99
+ ...bidKeywords,
100
+ }
87
101
 
88
102
  return {
103
+ unitCode: bidRequest.adUnitCode,
89
104
  bidId: bidRequest.bidId,
90
105
  placementId: bidRequest.params.placementId,
91
- unitCode: bidRequest.adUnitCode,
92
- sizes,
93
106
  keywords,
107
+ sizes,
94
108
  }
95
109
  }
96
110
 
@@ -124,7 +138,8 @@ function getReferer(bidderRequest) {
124
138
  function getGdprConsentChoice(bidderRequest) {
125
139
  const hasGdprConsent =
126
140
  hasValue(bidderRequest) &&
127
- hasValue(bidderRequest.gdprConsent)
141
+ hasValue(bidderRequest.gdprConsent) &&
142
+ hasStringValue(bidderRequest.gdprConsent.consentString)
128
143
 
129
144
  if (hasGdprConsent) {
130
145
  return bidderRequest.gdprConsent
@@ -138,11 +153,11 @@ function getGdprConsentChoice(bidderRequest) {
138
153
  }
139
154
 
140
155
  function setVaultJwt(auth) {
141
- storageManager.setDataInLocalStorage(LOCAL_STORAGE_KEY.glimpse.jwt, auth)
156
+ storageManager.setDataInLocalStorage(LOCAL_STORAGE_KEY.vault.jwt, auth)
142
157
  }
143
158
 
144
159
  function getVaultJwt() {
145
- return storageManager.getDataFromLocalStorage(LOCAL_STORAGE_KEY.glimpse.jwt) || ''
160
+ return storageManager.getDataFromLocalStorage(LOCAL_STORAGE_KEY.vault.jwt) || ''
146
161
  }
147
162
 
148
163
  function isValidBidResponse(bidResponse) {
@@ -55,15 +55,16 @@ export const appendPbAdSlot = adUnit => {
55
55
  const context = adUnit.ortb2Imp.ext.data;
56
56
  const { customPbAdSlot } = _currentConfig;
57
57
 
58
- if (customPbAdSlot) {
59
- context.pbadslot = customPbAdSlot(adUnit.code, deepAccess(context, 'adserver.adslot'));
58
+ // use context.pbAdSlot if set (if someone set it already, it will take precedence over others)
59
+ if (context.pbadslot) {
60
60
  return;
61
61
  }
62
62
 
63
- // use context.pbAdSlot if set
64
- if (context.pbadslot) {
63
+ if (customPbAdSlot) {
64
+ context.pbadslot = customPbAdSlot(adUnit.code, deepAccess(context, 'adserver.adslot'));
65
65
  return;
66
66
  }
67
+
67
68
  // use data attribute 'data-adslotid' if set
68
69
  try {
69
70
  const adUnitCodeDiv = document.getElementById(adUnit.code);
@@ -78,12 +79,17 @@ export const appendPbAdSlot = adUnit => {
78
79
  return;
79
80
  }
80
81
  context.pbadslot = adUnit.code;
82
+ return true;
81
83
  };
82
84
 
83
85
  export const makeBidRequestsHook = (fn, adUnits, ...args) => {
84
86
  appendGptSlots(adUnits);
85
87
  adUnits.forEach(adUnit => {
86
- appendPbAdSlot(adUnit);
88
+ const usedAdUnitCode = appendPbAdSlot(adUnit);
89
+ // gpid should be set to itself if already set, or to what pbadslot was (as long as it was not adUnit code)
90
+ if (!adUnit.ortb2Imp.ext.gpid && !usedAdUnitCode) {
91
+ adUnit.ortb2Imp.ext.gpid = adUnit.ortb2Imp.ext.data.pbadslot;
92
+ }
87
93
  });
88
94
  return fn.call(this, adUnits, ...args);
89
95
  };
@@ -29,6 +29,7 @@ let hasSynced = false;
29
29
 
30
30
  export const spec = {
31
31
  code: BIDDER_CODE,
32
+ aliases: ['playwire', 'adlivetech'],
32
33
  supportedMediaTypes: [ BANNER, VIDEO ],
33
34
  /**
34
35
  * Determines whether or not the given bid request is valid.
@@ -294,6 +294,14 @@ function buildRequests(validBidRequests, bidderRequest) {
294
294
  let data = {};
295
295
  let gpid = '';
296
296
 
297
+ const date = new Date();
298
+ const lt = date && date.getTime();
299
+ const to = date && date.getTimezoneOffset();
300
+ if (to) {
301
+ lt && (data.lt = lt);
302
+ data.to = to;
303
+ }
304
+
297
305
  // ADTS-134 Retrieve ID envelopes
298
306
  for (const eid in eids) data[eid] = eids[eid];
299
307