prebid.js 7.25.0 → 7.26.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 (168) hide show
  1. package/dist/33acrossBidAdapter.js +1 -1
  2. package/dist/adagioBidAdapter.js +1 -1
  3. package/dist/adbookpspBidAdapter.js +1 -1
  4. package/dist/adgenerationBidAdapter.js +1 -1
  5. package/dist/admaticBidAdapter.js +1 -1
  6. package/dist/adrelevantisBidAdapter.js +1 -1
  7. package/dist/adtrgtmeBidAdapter.js +1 -1
  8. package/dist/adxcgBidAdapter.js +1 -1
  9. package/dist/ajaBidAdapter.js +1 -1
  10. package/dist/amxBidAdapter.js +1 -1
  11. package/dist/amxIdSystem.js +1 -1
  12. package/dist/appierAnalyticsAdapter.js +1 -1
  13. package/dist/appnexusBidAdapter.js +1 -1
  14. package/dist/asoBidAdapter.js +1 -1
  15. package/dist/axonixBidAdapter.js +1 -1
  16. package/dist/beopBidAdapter.js +1 -1
  17. package/dist/bidglassBidAdapter.js +1 -1
  18. package/dist/big-richmediaBidAdapter.js +1 -1
  19. package/dist/bridgewellBidAdapter.js +1 -1
  20. package/dist/brightMountainMediaBidAdapter.js +1 -1
  21. package/dist/captifyRtdProvider.js +1 -0
  22. package/dist/carodaBidAdapter.js +1 -1
  23. package/dist/chtnwBidAdapter.js +1 -1
  24. package/dist/concertBidAdapter.js +1 -1
  25. package/dist/connectadBidAdapter.js +1 -1
  26. package/dist/consumableBidAdapter.js +1 -1
  27. package/dist/conversantBidAdapter.js +1 -1
  28. package/dist/craftBidAdapter.js +1 -1
  29. package/dist/criteoBidAdapter.js +1 -1
  30. package/dist/discoveryBidAdapter.js +1 -1
  31. package/dist/dspxBidAdapter.js +1 -1
  32. package/dist/eplanningBidAdapter.js +1 -1
  33. package/dist/finativeBidAdapter.js +1 -1
  34. package/dist/glimpseBidAdapter.js +1 -1
  35. package/dist/gmosspBidAdapter.js +1 -1
  36. package/dist/goldbachBidAdapter.js +1 -1
  37. package/dist/gridBidAdapter.js +1 -1
  38. package/dist/gridNMBidAdapter.js +1 -1
  39. package/dist/gumgumBidAdapter.js +1 -1
  40. package/dist/h12mediaBidAdapter.js +1 -1
  41. package/dist/id5IdSystem.js +1 -1
  42. package/dist/improvedigitalBidAdapter.js +1 -1
  43. package/dist/inmarBidAdapter.js +1 -1
  44. package/dist/insticatorBidAdapter.js +1 -1
  45. package/dist/ixBidAdapter.js +1 -1
  46. package/dist/justpremiumBidAdapter.js +1 -1
  47. package/dist/konduitAnalyticsAdapter.js +1 -1
  48. package/dist/kueezBidAdapter.js +1 -1
  49. package/dist/kueezRtbBidAdapter.js +1 -1
  50. package/dist/lassoBidAdapter.js +1 -1
  51. package/dist/lifestreetBidAdapter.js +1 -1
  52. package/dist/liveyieldAnalyticsAdapter.js +1 -1
  53. package/dist/logicadBidAdapter.js +1 -1
  54. package/dist/loglyliftBidAdapter.js +1 -1
  55. package/dist/magniteAnalyticsAdapter.js +1 -1
  56. package/dist/malltvAnalyticsAdapter.js +1 -1
  57. package/dist/marsmediaBidAdapter.js +1 -1
  58. package/dist/mediafuseBidAdapter.js +1 -1
  59. package/dist/mediasquareBidAdapter.js +1 -1
  60. package/dist/mgidBidAdapter.js +1 -1
  61. package/dist/minutemediaBidAdapter.js +1 -1
  62. package/dist/nextMillenniumBidAdapter.js +1 -1
  63. package/dist/not-for-prod/prebid.js +152 -118
  64. package/dist/oguryBidAdapter.js +1 -1
  65. package/dist/onetagBidAdapter.js +1 -1
  66. package/dist/ooloAnalyticsAdapter.js +1 -1
  67. package/dist/outbrainBidAdapter.js +1 -1
  68. package/dist/parrableIdSystem.js +1 -1
  69. package/dist/pixfutureBidAdapter.js +1 -1
  70. package/dist/prebid-core.js +1 -1
  71. package/dist/publinkIdSystem.js +1 -1
  72. package/dist/pubmaticBidAdapter.js +1 -1
  73. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  74. package/dist/pxyzBidAdapter.js +1 -1
  75. package/dist/quantcastBidAdapter.js +1 -1
  76. package/dist/readpeakBidAdapter.js +1 -1
  77. package/dist/relaidoBidAdapter.js +1 -1
  78. package/dist/rhythmoneBidAdapter.js +1 -1
  79. package/dist/riseBidAdapter.js +1 -1
  80. package/dist/rubiconAnalyticsAdapter.js +1 -1
  81. package/dist/rubiconBidAdapter.js +1 -1
  82. package/dist/seedingAllianceBidAdapter.js +1 -1
  83. package/dist/seedtagBidAdapter.js +1 -1
  84. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  85. package/dist/sharethroughBidAdapter.js +1 -1
  86. package/dist/shinezBidAdapter.js +1 -1
  87. package/dist/smaatoBidAdapter.js +1 -1
  88. package/dist/smartadserverBidAdapter.js +1 -1
  89. package/dist/smartxBidAdapter.js +1 -1
  90. package/dist/smartytechBidAdapter.js +1 -0
  91. package/dist/smilewantedBidAdapter.js +1 -1
  92. package/dist/sonobiBidAdapter.js +1 -1
  93. package/dist/sovrnAnalyticsAdapter.js +1 -1
  94. package/dist/sovrnBidAdapter.js +1 -1
  95. package/dist/sspBCBidAdapter.js +1 -1
  96. package/dist/sublimeBidAdapter.js +1 -1
  97. package/dist/synacormediaBidAdapter.js +1 -1
  98. package/dist/taboolaBidAdapter.js +1 -1
  99. package/dist/tappxBidAdapter.js +1 -1
  100. package/dist/targetVideoBidAdapter.js +1 -1
  101. package/dist/teadsBidAdapter.js +1 -1
  102. package/dist/trionBidAdapter.js +1 -1
  103. package/dist/tripleliftBidAdapter.js +1 -1
  104. package/dist/ttdBidAdapter.js +1 -1
  105. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  106. package/dist/underdogmediaBidAdapter.js +1 -1
  107. package/dist/undertoneBidAdapter.js +1 -1
  108. package/dist/userId.js +1 -1
  109. package/dist/vidazooBidAdapter.js +1 -1
  110. package/dist/videobyteBidAdapter.js +1 -1
  111. package/dist/viqeoBidAdapter.js +1 -0
  112. package/dist/visxBidAdapter.js +1 -1
  113. package/dist/vuukleBidAdapter.js +1 -1
  114. package/dist/widespaceBidAdapter.js +1 -1
  115. package/dist/winrBidAdapter.js +1 -1
  116. package/dist/yahoosspBidAdapter.js +1 -1
  117. package/dist/yieldlabBidAdapter.js +1 -1
  118. package/dist/yieldmoBidAdapter.js +1 -1
  119. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  120. package/dist/zeta_global_sspBidAdapter.js +1 -1
  121. package/dist/zeusPrimeRtdProvider.js +31 -0
  122. package/integrationExamples/gpt/captifyRtdProvider_example.html +167 -0
  123. package/modules/.submodules.json +3 -1
  124. package/modules/admaticBidAdapter.js +108 -59
  125. package/modules/admaticBidAdapter.md +2 -2
  126. package/modules/beopBidAdapter.js +17 -2
  127. package/modules/captifyRtdProvider.js +146 -0
  128. package/modules/captifyRtdProvider.md +68 -0
  129. package/modules/discoveryBidAdapter.js +38 -17
  130. package/modules/discoveryBidAdapter.md +7 -6
  131. package/modules/gridBidAdapter.js +440 -22
  132. package/modules/nextMillenniumBidAdapter.js +19 -23
  133. package/modules/smartadserverBidAdapter.js +6 -2
  134. package/modules/smartxBidAdapter.js +10 -7
  135. package/modules/smartytechBidAdapter.js +78 -0
  136. package/modules/smartytechBidAdapter.md +44 -0
  137. package/modules/taboolaBidAdapter.js +3 -3
  138. package/modules/taboolaBidAdapter.md +0 -2
  139. package/modules/tappxBidAdapter.js +21 -6
  140. package/modules/ttdBidAdapter.js +4 -3
  141. package/modules/userId/index.js +1 -1
  142. package/modules/vidazooBidAdapter.js +15 -2
  143. package/modules/viqeoBidAdapter.js +180 -0
  144. package/modules/viqeoBidAdapter.md +56 -0
  145. package/modules/yieldlabBidAdapter.js +19 -8
  146. package/modules/yieldoneBidAdapter.js +60 -8
  147. package/modules/yieldoneBidAdapter.md +109 -9
  148. package/modules/zeta_global_sspBidAdapter.js +4 -0
  149. package/modules/zeusPrimeRtdProvider.js +357 -0
  150. package/modules/zeusPrimeRtdProvider.md +60 -0
  151. package/package.json +1 -1
  152. package/src/adloader.js +0 -1
  153. package/test/spec/modules/admaticBidAdapter_spec.js +262 -3
  154. package/test/spec/modules/beopBidAdapter_spec.js +52 -0
  155. package/test/spec/modules/captifyRtdProvider_spec.js +253 -0
  156. package/test/spec/modules/discoveryBidAdapter_spec.js +9 -8
  157. package/test/spec/modules/gridBidAdapter_spec.js +289 -1
  158. package/test/spec/modules/nextMillenniumBidAdapter_spec.js +4 -3
  159. package/test/spec/modules/smartadserverBidAdapter_spec.js +80 -0
  160. package/test/spec/modules/smartxBidAdapter_spec.js +32 -0
  161. package/test/spec/modules/smartytechBidAdapter_spec.js +162 -0
  162. package/test/spec/modules/taboolaBidAdapter_spec.js +0 -77
  163. package/test/spec/modules/ttdBidAdapter_spec.js +13 -0
  164. package/test/spec/modules/viqeoBidAdapter_spec.js +124 -0
  165. package/test/spec/modules/yieldlabBidAdapter_spec.js +125 -0
  166. package/test/spec/modules/yieldoneBidAdapter_spec.js +30 -6
  167. package/test/spec/modules/zeta_global_sspBidAdapter_spec.js +16 -1
  168. package/test/spec/modules/zeusPrimeRtdProvider_spec.js +410 -0
@@ -0,0 +1,60 @@
1
+ # Overview
2
+
3
+ Module Name: Zeus Prime RTD Provider
4
+ Module Type: Rtd Provider
5
+ Maintainer: support@zeustechnology.com
6
+
7
+ ## Description
8
+
9
+ The Zeus Prime RTD Provider provides integration of Zeus Prime onto sites with Prebid. This module will request information from Zeus Prime servers to add the page level targeting required for Prime into the customer's ad setup.
10
+
11
+ Zeus Prime runs as soon as the code is initialized, so it can retrieve the information required from the Zeus Prime server to create the targeting key-values. Zeus Prime will provide two page level key-values: `zeus_<yourGamId>` and `zeus_insights`. Zeus Prime provides contextual information about a pages content, and does not provide user information that could present privacy implications.
12
+
13
+ For more information and help with setting up Zeus Prime, see the [onboarding documentation site](https://onboarding.zeustechnology.com).
14
+
15
+ ## Usage
16
+
17
+ To use Zeus Prime, add `zeusPrimeRtdProvider` into your Prebid build:
18
+
19
+ ```
20
+ gulp build --modules=rtdModule,zeusPrimeRtdProvider
21
+ ```
22
+
23
+ > Note that the global RTD module, `rtdModule`, is required for the Zeus Prime RTD module.
24
+
25
+ Once the code is included, configure Zeus Prime in your Prebid configuration:
26
+
27
+ ```javascript
28
+ pbjs.setConfig({
29
+ ...,
30
+ realTimeData: {
31
+ dataProviders: [{
32
+ name: 'zeusPrime',
33
+ waitForIt: false,
34
+ params: {
35
+ gamId: '<yourGamId>'
36
+ }
37
+ }]
38
+ },
39
+ ...
40
+ })
41
+ ```
42
+
43
+ ## Parameters
44
+
45
+ The parameters below describe the configuration object used to configure Zeus Prime.
46
+
47
+ | Name | Type | Description | Default |
48
+ |------------------------|----------|-----------------------------------------------------------------------------------------------|---------|
49
+ | name | String | This will always be `zeusPrime` | - |
50
+ | waitForIt | Boolean | Should be false since Zeus Prime runs on initial load and not during the bidding cycle. | `false` |
51
+ | params | Object | | - |
52
+ | params.gamId | String | The gamId or Google Ad Manager Network Code to access your Google Ad Manager instance. | - |
53
+
54
+ ### `gamId` Parameter
55
+
56
+ Zeus Prime requires the gamId parameter, or the Google Ad Manager Network Code, to reference your account. See the [Google documentation](https://support.google.com/admanager/answer/7674889?hl=en) to find out where you can retrieve the Network Code.
57
+
58
+ ## Troubleshooting
59
+
60
+ For troubleshooting steps and guides to assist with verifying your Zeus Prime installation, see our [installation documentation](https://onboarding.zeustechnology.com/docs/installation).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prebid.js",
3
- "version": "7.25.0",
3
+ "version": "7.26.0",
4
4
  "description": "Header Bidding Management Library",
5
5
  "main": "src/prebid.js",
6
6
  "scripts": {
package/src/adloader.js CHANGED
@@ -6,7 +6,6 @@ const _requestCache = new WeakMap();
6
6
  const _approvedLoadExternalJSList = [
7
7
  'debugging',
8
8
  'adloox',
9
- 'admatic',
10
9
  'criteo',
11
10
  'outstream',
12
11
  'adagio',
@@ -3,7 +3,7 @@ import {spec, storage} from 'modules/admaticBidAdapter.js';
3
3
  import {newBidder} from 'src/adapters/bidderFactory.js';
4
4
  import {getStorageManager} from 'src/storageManager';
5
5
 
6
- const ENDPOINT = 'https://layer.serve.admatic.com.tr/v1';
6
+ const ENDPOINT = 'https://layer.serve.admatic.com.tr/pb?bidder=admatic';
7
7
 
8
8
  describe('admaticBidAdapter', () => {
9
9
  const adapter = newBidder(spec);
@@ -18,7 +18,8 @@ describe('admaticBidAdapter', () => {
18
18
  let bid = {
19
19
  'bidder': 'admatic',
20
20
  'params': {
21
- 'networkId': 10433394
21
+ 'networkId': 10433394,
22
+ 'host': 'layer.serve.admatic.com.tr'
22
23
  },
23
24
  'adUnitCode': 'adunit-code',
24
25
  'sizes': [[300, 250], [300, 600]],
@@ -37,10 +38,268 @@ describe('admaticBidAdapter', () => {
37
38
  delete bid.params;
38
39
 
39
40
  bid.params = {
40
- 'networkId': 0
41
+ 'networkId': 0,
42
+ 'host': 'layer.serve.admatic.com.tr'
41
43
  };
42
44
 
43
45
  expect(spec.isBidRequestValid(bid)).to.equal(false);
44
46
  });
45
47
  });
48
+
49
+ describe('buildRequests', function () {
50
+ it('sends bid request to ENDPOINT via POST', function () {
51
+ let validRequest = [ {
52
+ 'bidder': 'admatic',
53
+ 'params': {
54
+ 'networkId': 10433394,
55
+ 'host': 'layer.serve.admatic.com.tr'
56
+ },
57
+ 'mediaTypes': {
58
+ 'banner': {
59
+ 'sizes': [[300, 250], [728, 90]]
60
+ }
61
+ },
62
+ getFloor: inputParams => {
63
+ if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) {
64
+ return {
65
+ currency: 'USD',
66
+ floor: 1.0
67
+ };
68
+ } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) {
69
+ return {
70
+ currency: 'USD',
71
+ floor: 2.0
72
+ };
73
+ } else {
74
+ return {}
75
+ }
76
+ },
77
+ 'user': {
78
+ 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'
79
+ },
80
+ 'blacklist': [],
81
+ 'site': {
82
+ 'page': 'http://localhost:8888/admatic.html',
83
+ 'ref': 'http://localhost:8888',
84
+ 'publisher': {
85
+ 'name': 'localhost',
86
+ 'publisherId': 12321312
87
+ }
88
+ },
89
+ 'imp': [
90
+ {
91
+ 'size': [
92
+ {
93
+ 'w': 300,
94
+ 'h': 250
95
+ },
96
+ {
97
+ 'w': 728,
98
+ 'h': 90
99
+ }
100
+ ],
101
+ 'id': '2205da7a81846b',
102
+ 'floors': {
103
+ 'banner': {
104
+ '300x250': { 'currency': 'USD', 'floor': 1 },
105
+ '728x90': { 'currency': 'USD', 'floor': 2 }
106
+ }
107
+ }
108
+ }
109
+ ],
110
+ 'ext': {
111
+ 'cur': 'USD',
112
+ 'bidder': 'admatic'
113
+ }
114
+ } ];
115
+ let bidderRequest = {
116
+ 'bidder': 'admatic',
117
+ 'params': {
118
+ 'networkId': 10433394,
119
+ 'host': 'layer.serve.admatic.com.tr'
120
+ },
121
+ 'mediaTypes': {
122
+ 'banner': {
123
+ 'sizes': [[300, 250], [728, 90]]
124
+ }
125
+ },
126
+ getFloor: inputParams => {
127
+ if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) {
128
+ return {
129
+ currency: 'USD',
130
+ floor: 1.0
131
+ };
132
+ } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) {
133
+ return {
134
+ currency: 'USD',
135
+ floor: 2.0
136
+ };
137
+ } else {
138
+ return {}
139
+ }
140
+ },
141
+ 'user': {
142
+ 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'
143
+ },
144
+ 'blacklist': [],
145
+ 'site': {
146
+ 'page': 'http://localhost:8888/admatic.html',
147
+ 'ref': 'http://localhost:8888',
148
+ 'publisher': {
149
+ 'name': 'localhost',
150
+ 'publisherId': 12321312
151
+ }
152
+ },
153
+ 'imp': [
154
+ {
155
+ 'size': [
156
+ {
157
+ 'w': 300,
158
+ 'h': 250
159
+ },
160
+ {
161
+ 'w': 728,
162
+ 'h': 90
163
+ }
164
+ ],
165
+ 'id': '2205da7a81846b',
166
+ 'floors': {
167
+ 'banner': {
168
+ '300x250': { 'currency': 'USD', 'floor': 1 },
169
+ '728x90': { 'currency': 'USD', 'floor': 2 }
170
+ }
171
+ }
172
+ }
173
+ ],
174
+ 'ext': {
175
+ 'cur': 'USD',
176
+ 'bidder': 'admatic'
177
+ }
178
+ };
179
+ const request = spec.buildRequests(validRequest, bidderRequest);
180
+ expect(request.url).to.equal(ENDPOINT);
181
+ expect(request.method).to.equal('POST');
182
+ });
183
+
184
+ it('should properly build a banner request with floors', function () {
185
+ let bidRequests = [
186
+ {
187
+ 'bidder': 'admatic',
188
+ 'params': {
189
+ 'networkId': 10433394,
190
+ 'host': 'layer.serve.admatic.com.tr'
191
+ },
192
+ 'mediaTypes': {
193
+ 'banner': {
194
+ 'sizes': [[300, 250], [728, 90]]
195
+ }
196
+ },
197
+ getFloor: inputParams => {
198
+ if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) {
199
+ return {
200
+ currency: 'USD',
201
+ floor: 1.0
202
+ };
203
+ } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) {
204
+ return {
205
+ currency: 'USD',
206
+ floor: 2.0
207
+ };
208
+ } else {
209
+ return {}
210
+ }
211
+ }
212
+ },
213
+ ];
214
+ let bidderRequest = {
215
+ 'bidder': 'admatic',
216
+ 'params': {
217
+ 'networkId': 10433394,
218
+ 'host': 'layer.serve.admatic.com.tr'
219
+ },
220
+ 'adUnitCode': 'adunit-code',
221
+ 'sizes': [[300, 250], [728, 90]],
222
+ 'bidId': '30b31c1838de1e',
223
+ 'bidderRequestId': '22edbae2733bf6',
224
+ 'auctionId': '1d1a030790a475',
225
+ 'creativeId': 'er2ee',
226
+ 'mediaTypes': {
227
+ 'banner': {
228
+ 'sizes': [[300, 250], [728, 90]]
229
+ }
230
+ }
231
+ };
232
+ const request = spec.buildRequests(bidRequests, bidderRequest);
233
+ request.data.imp[0].floors = {
234
+ 'banner': {
235
+ '300x250': { 'currency': 'USD', 'floor': 1 },
236
+ '728x90': { 'currency': 'USD', 'floor': 2 }
237
+ }
238
+ };
239
+ });
240
+ });
241
+
242
+ describe('interpretResponse', function () {
243
+ it('should get correct bid responses', function() {
244
+ let bids = { body: {
245
+ data: [
246
+ {
247
+ 'id': 1,
248
+ 'creative_id': '374',
249
+ 'width': 300,
250
+ 'height': 250,
251
+ 'price': 0.01,
252
+ 'bidder': 'admatic',
253
+ 'adomain': ['admatic.com.tr'],
254
+ 'party_tag': '<div></div>'
255
+ }
256
+ ],
257
+ 'queryId': 'cdnbh24rlv0hhkpfpln0',
258
+ 'status': true
259
+ }};
260
+
261
+ let expectedResponse = [
262
+ {
263
+ requestId: 1,
264
+ cpm: 0.01,
265
+ width: 300,
266
+ height: 250,
267
+ currency: 'TRY',
268
+ netRevenue: true,
269
+ ad: '<div></div>',
270
+ creativeId: '374',
271
+ meta: {
272
+ advertiserDomains: ['admatic.com.tr']
273
+ },
274
+ ttl: 360,
275
+ bidder: 'admatic'
276
+ }
277
+ ];
278
+ const request = {
279
+ ext: {
280
+ 'cur': 'TRY',
281
+ 'type': 'admatic'
282
+ }
283
+ };
284
+ let result = spec.interpretResponse(bids, {data: request});
285
+ expect(result).to.eql(expectedResponse);
286
+ });
287
+
288
+ it('handles nobid responses', function () {
289
+ let request = {
290
+ ext: {
291
+ 'cur': 'TRY',
292
+ 'type': 'admatic'
293
+ }
294
+ };
295
+ let bids = { body: {
296
+ data: [],
297
+ 'queryId': 'cdnbh24rlv0hhkpfpln0',
298
+ 'status': true
299
+ }};
300
+
301
+ let result = spec.interpretResponse(bids, {data: request});
302
+ expect(result.length).to.equal(0);
303
+ });
304
+ });
46
305
  });
@@ -216,4 +216,56 @@ describe('BeOp Bid Adapter tests', () => {
216
216
  expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.include('pid=5a8af500c9e77c00017e4cad');
217
217
  });
218
218
  });
219
+
220
+ describe('Ensure keywords is always array of string', function () {
221
+ let bidRequests = [];
222
+ afterEach(function () {
223
+ bidRequests = [];
224
+ });
225
+
226
+ it('should work with keywords as an array', function () {
227
+ let bid = Object.assign({}, validBid);
228
+ bid.params.keywords = ['a', 'b'];
229
+ bidRequests.push(bid);
230
+ config.setConfig({
231
+ currency: { adServerCurrency: 'USD' }
232
+ });
233
+ const request = spec.buildRequests(bidRequests, {});
234
+ const payload = JSON.parse(request.data);
235
+ const url = request.url;
236
+ expect(payload.kwds).to.exist;
237
+ expect(payload.kwds).to.include('a');
238
+ expect(payload.kwds).to.include('b');
239
+ });
240
+
241
+ it('should work with keywords as a string', function () {
242
+ let bid = Object.assign({}, validBid);
243
+ bid.params.keywords = 'list of keywords';
244
+ bidRequests.push(bid);
245
+ config.setConfig({
246
+ currency: { adServerCurrency: 'USD' }
247
+ });
248
+ const request = spec.buildRequests(bidRequests, {});
249
+ const payload = JSON.parse(request.data);
250
+ const url = request.url;
251
+ expect(payload.kwds).to.exist;
252
+ expect(payload.kwds).to.include('list of keywords');
253
+ });
254
+
255
+ it('should work with keywords as a string containing a comma', function () {
256
+ let bid = Object.assign({}, validBid);
257
+ bid.params.keywords = 'list, of, keywords';
258
+ bidRequests.push(bid);
259
+ config.setConfig({
260
+ currency: { adServerCurrency: 'USD' }
261
+ });
262
+ const request = spec.buildRequests(bidRequests, {});
263
+ const payload = JSON.parse(request.data);
264
+ const url = request.url;
265
+ expect(payload.kwds).to.exist;
266
+ expect(payload.kwds).to.include('list');
267
+ expect(payload.kwds).to.include('of');
268
+ expect(payload.kwds).to.include('keywords');
269
+ })
270
+ })
219
271
  });
@@ -0,0 +1,253 @@
1
+ import {addSegmentData, captifySubmodule, getMatchingBidders, setCaptifyTargeting} from 'modules/captifyRtdProvider.js';
2
+ import {server} from 'test/mocks/xhr.js';
3
+ import {config} from 'src/config.js';
4
+ import {deepAccess} from '../../../src/utils';
5
+
6
+ const responseHeader = {'Content-Type': 'application/json'};
7
+ const defaultRequestUrl = 'https://live-classification.cpx.to/prebid-segments';
8
+
9
+ describe('captifyRtdProvider', function () {
10
+ describe('init function', function () {
11
+ it('successfully instantiates, when configured properly', function () {
12
+ const config = {
13
+ params: {
14
+ pubId: 123456,
15
+ bidders: ['appnexus'],
16
+ }
17
+ };
18
+ expect(captifySubmodule.init(config, null)).to.equal(true);
19
+ });
20
+
21
+ it('return false on init, when config is invalid', function () {
22
+ const config = {
23
+ params: {}
24
+ };
25
+ expect(captifySubmodule.init(config, null)).to.equal(false);
26
+ expect(captifySubmodule.init(null, null)).to.equal(false);
27
+ });
28
+
29
+ it('return false on init, when pubId is absent', function () {
30
+ const config = {
31
+ params: {
32
+ bidders: ['appnexus'],
33
+ }
34
+ };
35
+ expect(captifySubmodule.init(config, null)).to.equal(false);
36
+ expect(captifySubmodule.init(null, null)).to.equal(false);
37
+ });
38
+
39
+ it('return false on init, when bidders is empty array', function () {
40
+ const config = {
41
+ params: {
42
+ bidders: [],
43
+ pubId: 123,
44
+ }
45
+ };
46
+ expect(captifySubmodule.init(config, null)).to.equal(false);
47
+ expect(captifySubmodule.init(null, null)).to.equal(false);
48
+ });
49
+ });
50
+
51
+ describe('addSegmentData function', function () {
52
+ it('adds segment data', function () {
53
+ config.resetConfig();
54
+
55
+ let data = {
56
+ xandr: [111111, 222222],
57
+ };
58
+
59
+ addSegmentData(['appnexus'], data);
60
+ expect(deepAccess(config.getConfig(), 'appnexusAuctionKeywords.captify_segments')).to.eql(data['xandr']);
61
+ });
62
+ });
63
+
64
+ describe('getMatchingBidders function', function () {
65
+ it('returns only bidders that used within adUnits', function () {
66
+ const moduleConfig = {
67
+ params: {
68
+ pubId: 123,
69
+ bidders: ['appnexus', 'pubmatic'],
70
+ }
71
+ };
72
+ let reqBidsConfigObj = {
73
+ adUnits: [{
74
+ bids: [{
75
+ bidder: 'appnexus',
76
+ params: {
77
+ placementId: 13144370
78
+ }
79
+ }]
80
+ }]
81
+ };
82
+
83
+ let matchedBidders = getMatchingBidders(moduleConfig, reqBidsConfigObj);
84
+ expect(matchedBidders).to.eql(['appnexus']);
85
+ });
86
+
87
+ it('return empty result, when there are no bidders configured for adUnits', function () {
88
+ const moduleConfig = {
89
+ params: {
90
+ pubId: 123,
91
+ bidders: ['pubmatic'],
92
+ }
93
+ };
94
+ let reqBidsConfigObj = {
95
+ adUnits: [{
96
+ bids: []
97
+ }]
98
+ };
99
+ expect(getMatchingBidders(moduleConfig, reqBidsConfigObj)).to.be.empty;
100
+ });
101
+
102
+ it('return empty result, when there are no bidders matched', function () {
103
+ const moduleConfig = {
104
+ params: {
105
+ pubId: 123,
106
+ bidders: ['pubmatic'],
107
+ }
108
+ };
109
+ let reqBidsConfigObj = {
110
+ adUnits: [{
111
+ bids: [{
112
+ params: {
113
+ bidder: 'appnexus',
114
+ placementId: 13144370,
115
+ }
116
+ }]
117
+ }]
118
+ };
119
+ expect(getMatchingBidders(moduleConfig, reqBidsConfigObj)).to.be.empty;
120
+ });
121
+
122
+ it('return empty result, when there are no adUnits with bidders', function () {
123
+ const moduleConfig = {
124
+ params: {
125
+ pubId: 123,
126
+ bidders: ['pubmatic'],
127
+ }
128
+ };
129
+ let reqBidsConfigObj = {
130
+ adUnits: [{
131
+ bids: [{
132
+ params: {
133
+ placementId: 13144370,
134
+ }
135
+ }]
136
+ }]
137
+ };
138
+ expect(getMatchingBidders(moduleConfig, reqBidsConfigObj)).to.be.empty;
139
+ });
140
+ });
141
+
142
+ describe('integration test with mock live-classification response', function () {
143
+ const moduleConfig = {
144
+ params: {
145
+ pubId: 123456,
146
+ bidders: ['appnexus'],
147
+ }
148
+ };
149
+
150
+ const reqBidsConfigObj = {
151
+ adUnits: [{
152
+ bids: [{
153
+ bidder: 'appnexus',
154
+ params: {
155
+ placementId: 13144370
156
+ }
157
+ }, {
158
+ bidder: 'other'
159
+ }]
160
+ }]
161
+ };
162
+
163
+ const expectedUrlParam = 'http://localhost:9876/context.html';
164
+
165
+ it('gets data from async request and adds segment data', function () {
166
+ config.resetConfig();
167
+ let data = {xandr: [111111, 222222]};
168
+ const callbackSpy = sinon.spy();
169
+ setCaptifyTargeting(reqBidsConfigObj, callbackSpy, moduleConfig, {});
170
+ let request = server.requests[0];
171
+ let requestBody = JSON.parse(server.requests[0].requestBody);
172
+ expect(request.url).to.be.eq(defaultRequestUrl);
173
+ expect(requestBody['pubId']).to.eq(moduleConfig.params.pubId);
174
+ expect(requestBody['url']).to.eq(expectedUrlParam);
175
+ request.respond(200, responseHeader, JSON.stringify(data));
176
+ expect(deepAccess(config.getConfig(), 'appnexusAuctionKeywords.captify_segments')).to.eql(data['xandr']);
177
+ expect(callbackSpy.calledOnce).to.be.true;
178
+ });
179
+
180
+ it('do not send classification request, if no matching adUnits on page', function () {
181
+ config.resetConfig();
182
+ let reqBidsConfigObj = {
183
+ adUnits: [{
184
+ bids: [
185
+ {bidder: 'pubmatic'}
186
+ ]
187
+ }]
188
+ };
189
+ const callbackSpy = sinon.spy();
190
+ setCaptifyTargeting(reqBidsConfigObj, callbackSpy, moduleConfig, {});
191
+ expect(server.requests).to.be.empty;
192
+ });
193
+
194
+ it('gets data from async request and adds segment data, using URL from config', function () {
195
+ config.resetConfig();
196
+ let data = {xandr: [111111, 222222]};
197
+ const callbackSpy = sinon.spy();
198
+ const testUrl = 'http://my-test-server.com/path';
199
+ const conf = {
200
+ params: {
201
+ url: testUrl,
202
+ pubId: 123456,
203
+ bidders: ['appnexus'],
204
+ }
205
+ };
206
+ setCaptifyTargeting(reqBidsConfigObj, callbackSpy, conf, {});
207
+ let request = server.requests[0];
208
+ let requestBody = JSON.parse(server.requests[0].requestBody);
209
+ expect(request.url).to.be.eq(testUrl);
210
+ expect(requestBody['pubId']).to.eq(conf.params.pubId);
211
+ expect(requestBody['url']).to.eq(expectedUrlParam);
212
+ request.respond(200, responseHeader, JSON.stringify(data));
213
+ expect(deepAccess(config.getConfig(), 'appnexusAuctionKeywords.captify_segments')).to.eql(data['xandr']);
214
+ expect(callbackSpy.calledOnce).to.be.true;
215
+ });
216
+
217
+ it('do not set anything, in case server responded with 202', function () {
218
+ config.resetConfig();
219
+ const callbackSpy = sinon.spy();
220
+ setCaptifyTargeting(reqBidsConfigObj, callbackSpy, moduleConfig, {});
221
+ let request = server.requests[0];
222
+ let requestBody = JSON.parse(server.requests[0].requestBody);
223
+ expect(request.url).to.be.eq(defaultRequestUrl);
224
+ expect(requestBody['pubId']).to.eq(moduleConfig.params.pubId);
225
+ expect(requestBody['url']).to.eq(expectedUrlParam);
226
+ request.respond(202, responseHeader, '');
227
+ expect(deepAccess(config.getConfig(), 'appnexusAuctionKeywords.captify_segments')).to.be.undefined;
228
+ expect(callbackSpy.calledOnce).to.be.true;
229
+ });
230
+
231
+ it('do not set anything, in case server responded with error', function () {
232
+ config.resetConfig();
233
+ const callbackSpy = sinon.spy();
234
+ setCaptifyTargeting(reqBidsConfigObj, callbackSpy, moduleConfig, {});
235
+ let request = server.requests[0];
236
+ expect(request.url).to.be.eq(defaultRequestUrl);
237
+ request.respond(500, null, '');
238
+ expect(deepAccess(config.getConfig(), 'appnexusAuctionKeywords.captify_segments')).to.be.undefined;
239
+ expect(callbackSpy.calledOnce).to.be.true;
240
+ });
241
+
242
+ it('do not set anything, in case request error', function () {
243
+ config.resetConfig();
244
+ const callbackSpy = sinon.spy();
245
+ setCaptifyTargeting(reqBidsConfigObj, callbackSpy, moduleConfig, {});
246
+ let request = server.requests[0];
247
+ expect(request.url).to.be.eq(defaultRequestUrl);
248
+ request.abort('test error');
249
+ expect(deepAccess(config.getConfig(), 'appnexusAuctionKeywords.captify_segments')).to.be.undefined;
250
+ expect(callbackSpy.calledOnce).to.be.true;
251
+ });
252
+ });
253
+ });