prebid.js 7.18.0 → 7.19.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 (197) 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/adfBidAdapter.js +1 -1
  5. package/dist/adgenerationBidAdapter.js +1 -1
  6. package/dist/adqueryIdSystem.js +1 -1
  7. package/dist/adrelevantisBidAdapter.js +1 -1
  8. package/dist/adtrgtmeBidAdapter.js +1 -1
  9. package/dist/adxcgBidAdapter.js +1 -1
  10. package/dist/ajaBidAdapter.js +1 -1
  11. package/dist/amxBidAdapter.js +1 -1
  12. package/dist/amxIdSystem.js +1 -1
  13. package/dist/appierAnalyticsAdapter.js +1 -1
  14. package/dist/appnexusBidAdapter.js +1 -1
  15. package/dist/asoBidAdapter.js +1 -1
  16. package/dist/axonixBidAdapter.js +1 -1
  17. package/dist/{andBeyondMediaBidAdapter.js → beyondmediaBidAdapter.js} +1 -1
  18. package/dist/bidglassBidAdapter.js +1 -1
  19. package/dist/big-richmediaBidAdapter.js +1 -1
  20. package/dist/bridgewellBidAdapter.js +1 -1
  21. package/dist/brightMountainMediaBidAdapter.js +1 -1
  22. package/dist/carodaBidAdapter.js +1 -1
  23. package/dist/cleanioRtdProvider.js +1 -1
  24. package/dist/colossussspBidAdapter.js +1 -1
  25. package/dist/concertBidAdapter.js +1 -1
  26. package/dist/connectadBidAdapter.js +1 -1
  27. package/dist/consumableBidAdapter.js +1 -1
  28. package/dist/conversantAnalyticsAdapter.js +1 -0
  29. package/dist/conversantBidAdapter.js +1 -1
  30. package/dist/craftBidAdapter.js +1 -1
  31. package/dist/criteoBidAdapter.js +1 -1
  32. package/dist/debugging-standalone.js +1 -1
  33. package/dist/debugging.js +1 -1
  34. package/dist/dependencies.json +6 -0
  35. package/dist/dgkeywordRtdProvider.js +1 -1
  36. package/dist/dianomiBidAdapter.js +1 -1
  37. package/dist/dspxBidAdapter.js +1 -1
  38. package/dist/enrichmentFpdModule.js +1 -1
  39. package/dist/eplanningBidAdapter.js +1 -1
  40. package/dist/finativeBidAdapter.js +1 -1
  41. package/dist/fpd.js +1 -0
  42. package/dist/glimpseBidAdapter.js +1 -1
  43. package/dist/gmosspBidAdapter.js +1 -1
  44. package/dist/goldbachBidAdapter.js +1 -1
  45. package/dist/gridBidAdapter.js +1 -1
  46. package/dist/gridNMBidAdapter.js +1 -1
  47. package/dist/gumgumBidAdapter.js +1 -1
  48. package/dist/h12mediaBidAdapter.js +1 -1
  49. package/dist/id5IdSystem.js +1 -1
  50. package/dist/improvedigitalBidAdapter.js +1 -1
  51. package/dist/inmarBidAdapter.js +1 -1
  52. package/dist/insticatorBidAdapter.js +1 -1
  53. package/dist/ixBidAdapter.js +1 -1
  54. package/dist/justpremiumBidAdapter.js +1 -1
  55. package/dist/konduitAnalyticsAdapter.js +1 -1
  56. package/dist/kueezBidAdapter.js +1 -1
  57. package/dist/lassoBidAdapter.js +1 -1
  58. package/dist/lifestreetBidAdapter.js +1 -1
  59. package/dist/liveIntentIdSystem.js +1 -1
  60. package/dist/liveyieldAnalyticsAdapter.js +1 -1
  61. package/dist/logicadBidAdapter.js +1 -1
  62. package/dist/loglyliftBidAdapter.js +1 -1
  63. package/dist/malltvAnalyticsAdapter.js +1 -1
  64. package/dist/marsmediaBidAdapter.js +1 -1
  65. package/dist/mediafuseBidAdapter.js +1 -1
  66. package/dist/mediakeysBidAdapter.js +1 -1
  67. package/dist/mediasquareBidAdapter.js +1 -1
  68. package/dist/mgidBidAdapter.js +1 -1
  69. package/dist/minutemediaBidAdapter.js +1 -1
  70. package/dist/nativoBidAdapter.js +1 -1
  71. package/dist/not-for-prod/prebid.js +123 -121
  72. package/dist/oguryBidAdapter.js +1 -1
  73. package/dist/onetagBidAdapter.js +1 -1
  74. package/dist/ooloAnalyticsAdapter.js +1 -1
  75. package/dist/outbrainBidAdapter.js +1 -1
  76. package/dist/parrableIdSystem.js +1 -1
  77. package/dist/pixfutureBidAdapter.js +1 -1
  78. package/dist/prebid-core.js +1 -1
  79. package/dist/prebidServerBidAdapter.js +1 -1
  80. package/dist/publinkIdSystem.js +1 -1
  81. package/dist/pubmaticBidAdapter.js +1 -1
  82. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  83. package/dist/pxyzBidAdapter.js +1 -1
  84. package/dist/quantcastBidAdapter.js +1 -1
  85. package/dist/readpeakBidAdapter.js +1 -1
  86. package/dist/relaidoBidAdapter.js +1 -1
  87. package/dist/rhythmoneBidAdapter.js +1 -1
  88. package/dist/riseBidAdapter.js +1 -1
  89. package/dist/rubiconAnalyticsAdapter.js +1 -1
  90. package/dist/rubiconBidAdapter.js +1 -1
  91. package/dist/seedingAllianceBidAdapter.js +1 -1
  92. package/dist/seedtagBidAdapter.js +1 -1
  93. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  94. package/dist/sharethroughBidAdapter.js +1 -1
  95. package/dist/shinezBidAdapter.js +1 -1
  96. package/dist/smaatoBidAdapter.js +1 -1
  97. package/dist/smartadserverBidAdapter.js +1 -1
  98. package/dist/smartxBidAdapter.js +1 -1
  99. package/dist/smilewantedBidAdapter.js +1 -1
  100. package/dist/sonobiBidAdapter.js +1 -1
  101. package/dist/sovrnAnalyticsAdapter.js +1 -1
  102. package/dist/sovrnBidAdapter.js +1 -1
  103. package/dist/sspBCBidAdapter.js +1 -1
  104. package/dist/sublimeBidAdapter.js +1 -1
  105. package/dist/synacormediaBidAdapter.js +1 -1
  106. package/dist/taboolaBidAdapter.js +1 -1
  107. package/dist/targetVideoBidAdapter.js +1 -1
  108. package/dist/teadsBidAdapter.js +1 -1
  109. package/dist/trionBidAdapter.js +1 -1
  110. package/dist/tripleliftBidAdapter.js +1 -1
  111. package/dist/ttdBidAdapter.js +1 -1
  112. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  113. package/dist/underdogmediaBidAdapter.js +1 -1
  114. package/dist/undertoneBidAdapter.js +1 -1
  115. package/dist/vidazooBidAdapter.js +1 -1
  116. package/dist/videobyteBidAdapter.js +1 -1
  117. package/dist/visxBidAdapter.js +1 -1
  118. package/dist/vuukleBidAdapter.js +1 -1
  119. package/dist/widespaceBidAdapter.js +1 -1
  120. package/dist/winrBidAdapter.js +1 -1
  121. package/dist/yahoosspBidAdapter.js +1 -1
  122. package/dist/yandexBidAdapter.js +1 -1
  123. package/dist/yieldmoBidAdapter.js +1 -1
  124. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  125. package/libraries/fpd/sua.js +98 -0
  126. package/modules/adfBidAdapter.js +1 -1
  127. package/modules/adkernelAdnBidAdapter.js +1 -0
  128. package/modules/adqueryIdSystem.js +8 -8
  129. package/modules/adxcgBidAdapter.js +1 -1
  130. package/modules/amxBidAdapter.js +1 -1
  131. package/modules/{andBeyondMediaBidAdapter.js → beyondmediaBidAdapter.js} +0 -0
  132. package/modules/{andBeyondMediaBidAdapter.md → beyondmediaBidAdapter.md} +1 -1
  133. package/modules/cleanioRtdProvider.js +3 -4
  134. package/modules/colossussspBidAdapter.js +2 -1
  135. package/modules/conversantAnalyticsAdapter.js +560 -0
  136. package/modules/conversantAnalyticsAdapter.md +47 -0
  137. package/modules/criteoBidAdapter.js +1 -1
  138. package/modules/debugging/bidInterceptor.js +2 -2
  139. package/modules/debugging/debugging.js +10 -2
  140. package/modules/dgkeywordRtdProvider.js +21 -3
  141. package/modules/dianomiBidAdapter.js +1 -1
  142. package/modules/enrichmentFpdModule.js +33 -14
  143. package/modules/finativeBidAdapter.js +1 -1
  144. package/modules/gridBidAdapter.js +187 -117
  145. package/modules/improvedigitalBidAdapter.js +2 -2
  146. package/modules/ixBidAdapter.js +94 -23
  147. package/modules/liveIntentIdSystem.js +39 -5
  148. package/modules/mediakeysBidAdapter.js +6 -1
  149. package/modules/mediakeysBidAdapter.md +50 -40
  150. package/modules/nativoBidAdapter.js +1 -1
  151. package/modules/prebidServerBidAdapter/index.js +44 -13
  152. package/modules/readpeakBidAdapter.js +1 -1
  153. package/modules/rubiconBidAdapter.js +2 -3
  154. package/modules/seedingAllianceBidAdapter.js +1 -1
  155. package/modules/sharethroughBidAdapter.js +1 -1
  156. package/modules/taboolaBidAdapter.js +1 -1
  157. package/modules/talkadsBidAdapter.js +1 -0
  158. package/modules/truereachBidAdapter.js +1 -0
  159. package/modules/ttdBidAdapter.js +1 -1
  160. package/modules/vuukleBidAdapter.js +34 -3
  161. package/modules/yahoosspBidAdapter.js +3 -1
  162. package/modules/yandexBidAdapter.js +31 -8
  163. package/package.json +2 -2
  164. package/src/adapterManager.js +2 -4
  165. package/src/cpmBucketManager.js +22 -3
  166. package/src/native.js +1 -5
  167. package/src/prebid.js +3 -3
  168. package/test/spec/cpmBucketManager_spec.js +239 -177
  169. package/test/spec/fpd/sua_spec.js +244 -0
  170. package/test/spec/modules/adfBidAdapter_spec.js +2 -3
  171. package/test/spec/modules/adqueryIdSystem_spec.js +0 -2
  172. package/test/spec/modules/adxcgBidAdapter_spec.js +2 -3
  173. package/test/spec/modules/amxBidAdapter_spec.js +3 -2
  174. package/test/spec/modules/{andBeyondMediaBidAdapter_spec.js → beyondmediaBidAdapter_spec.js} +1 -1
  175. package/test/spec/modules/colossussspBidAdapter_spec.js +4 -2
  176. package/test/spec/modules/conversantAnalyticsAdapter_spec.js +963 -0
  177. package/test/spec/modules/debugging_mod_spec.js +9 -0
  178. package/test/spec/modules/dgkeywordRtdProvider_spec.js +83 -1
  179. package/test/spec/modules/dianomiBidAdapter_spec.js +2 -3
  180. package/test/spec/modules/enrichmentFpdModule_spec.js +50 -7
  181. package/test/spec/modules/fpdModule_spec.js +9 -0
  182. package/test/spec/modules/gridBidAdapter_spec.js +87 -31
  183. package/test/spec/modules/ixBidAdapter_spec.js +221 -2
  184. package/test/spec/modules/liveIntentIdMinimalSystem_spec.js +62 -8
  185. package/test/spec/modules/liveIntentIdSystem_spec.js +62 -8
  186. package/test/spec/modules/mediakeysBidAdapter_spec.js +20 -3
  187. package/test/spec/modules/nativoBidAdapter_spec.js +13 -2
  188. package/test/spec/modules/prebidServerBidAdapter_spec.js +159 -4
  189. package/test/spec/modules/seedtagBidAdapter_spec.js +15 -18
  190. package/test/spec/modules/sharethroughBidAdapter_spec.js +2 -1
  191. package/test/spec/modules/taboolaBidAdapter_spec.js +2 -2
  192. package/test/spec/modules/ttdBidAdapter_spec.js +3 -3
  193. package/test/spec/modules/vuukleBidAdapter_spec.js +87 -0
  194. package/test/spec/modules/yahoosspBidAdapter_spec.js +3 -1
  195. package/test/spec/modules/yandexBidAdapter_spec.js +8 -5
  196. package/test/spec/native_spec.js +5 -0
  197. package/test/spec/unit/pbjs_api_spec.js +44 -0
@@ -1,195 +1,257 @@
1
1
  import { expect } from 'chai';
2
- import {getPriceBucketString, isValidPriceConfig} from 'src/cpmBucketManager.js';
2
+ import { getPriceBucketString, isValidPriceConfig } from 'src/cpmBucketManager.js';
3
+ import { config } from 'src/config.js';
4
+
3
5
  let cpmFixtures = require('test/fixtures/cpmInputsOutputs.json');
4
6
 
5
7
  describe('cpmBucketManager', function () {
6
- it('getPriceBucketString function generates the correct price strings', function () {
7
- let input = cpmFixtures.cpmInputs;
8
- for (let i = 0; i < input.length; i++) {
9
- let output = getPriceBucketString(input[i]);
10
- let jsonOutput = JSON.stringify(output);
11
- expect(jsonOutput).to.deep.equal(JSON.stringify(cpmFixtures.priceStringOutputs[i]));
12
- }
13
- });
14
-
15
- it('gets the correct custom bucket strings', function () {
16
- let cpm = 16.50908;
17
- let customConfig = {
18
- 'buckets': [{
19
- 'precision': 4,
20
- 'max': 3,
21
- 'increment': 0.01,
22
- },
23
- {
24
- 'precision': 4,
25
- 'max': 18,
26
- 'increment': 0.05,
27
- 'cap': true
8
+ describe('getPriceBucketString', function () {
9
+ it('getPriceBucketString function generates the correct price strings', function () {
10
+ let input = cpmFixtures.cpmInputs;
11
+ for (let i = 0; i < input.length; i++) {
12
+ let output = getPriceBucketString(input[i]);
13
+ let jsonOutput = JSON.stringify(output);
14
+ expect(jsonOutput).to.deep.equal(JSON.stringify(cpmFixtures.priceStringOutputs[i]));
28
15
  }
29
- ]
30
- };
31
- let expected = '{"low":"5.00","med":"16.50","high":"16.50","auto":"16.50","dense":"16.50","custom":"16.5000"}';
32
- let output = getPriceBucketString(cpm, customConfig);
33
- expect(JSON.stringify(output)).to.deep.equal(expected);
34
- });
16
+ });
35
17
 
36
- it('gets the correct custom bucket strings with irregular increment', function () {
37
- let cpm = 14.50908;
38
- let customConfig = {
39
- 'buckets': [{
40
- 'precision': 4,
41
- 'max': 4,
42
- 'increment': 0.01,
43
- },
44
- {
45
- 'precision': 4,
46
- 'max': 18,
47
- 'increment': 0.3,
48
- 'cap': true
49
- }
50
- ]
51
- };
52
- let expected = '{"low":"5.00","med":"14.50","high":"14.50","auto":"14.50","dense":"14.50","custom":"14.5000"}';
53
- let output = getPriceBucketString(cpm, customConfig);
54
- expect(JSON.stringify(output)).to.deep.equal(expected);
55
- });
56
-
57
- it('gets the correct custom bucket strings in non-USD currency', function () {
58
- let cpm = 16.50908 * 110.49;
59
- let customConfig = {
60
- 'buckets': [{
61
- 'precision': 4,
62
- 'max': 3,
63
- 'increment': 0.01,
64
- },
65
- {
66
- 'precision': 4,
67
- 'max': 18,
68
- 'increment': 0.05,
69
- 'cap': true
70
- }
71
- ]
72
- };
73
- let expected = '{"low":"552.45","med":"1823.09","high":"1823.09","auto":"1823.09","dense":"1823.09","custom":"1823.0850"}';
74
- let output = getPriceBucketString(cpm, customConfig, 110.49);
75
- expect(JSON.stringify(output)).to.deep.equal(expected);
76
- });
77
-
78
- it('gets the correct custom bucket strings with specific cpms that round oddly with certain increments', function () {
79
- let customConfig = {
80
- 'buckets': [{
81
- 'precision': 4,
82
- 'max': 4,
83
- 'increment': 0.10,
84
- }]
85
- };
86
- let cpm = 2.21;
87
- let expected = '{"low":"2.00","med":"2.20","high":"2.21","auto":"2.20","dense":"2.21","custom":"2.2000"}';
88
- let output = getPriceBucketString(cpm, customConfig);
89
- expect(JSON.stringify(output)).to.deep.equal(expected);
90
-
91
- cpm = 3.15;
92
- expected = '{"low":"3.00","med":"3.10","high":"3.15","auto":"3.15","dense":"3.15","custom":"3.1000"}';
93
- output = getPriceBucketString(cpm, customConfig);
94
- expect(JSON.stringify(output)).to.deep.equal(expected);
95
-
96
- customConfig = {
97
- 'buckets': [{
98
- 'precision': 3,
99
- 'max': 6,
100
- 'increment': 0.08,
101
- }]
102
- };
103
- cpm = 4.89;
104
- expected = '{"low":"4.50","med":"4.80","high":"4.89","auto":"4.85","dense":"4.85","custom":"4.880"}';
105
- output = getPriceBucketString(cpm, customConfig);
106
- expect(JSON.stringify(output)).to.deep.equal(expected);
107
-
108
- customConfig = {
109
- 'buckets': [{
110
- 'precision': 3,
111
- 'max': 6,
112
- 'increment': 0.05,
113
- }]
114
- };
115
- cpm = 2.98;
116
- expected = '{"low":"2.50","med":"2.90","high":"2.98","auto":"2.95","dense":"2.98","custom":"2.950"}';
117
- output = getPriceBucketString(cpm, customConfig);
118
- expect(JSON.stringify(output)).to.deep.equal(expected);
119
-
120
- cpm = 2.99;
121
- expected = '{"low":"2.50","med":"2.90","high":"2.99","auto":"2.95","dense":"2.99","custom":"2.950"}';
122
- output = getPriceBucketString(cpm, customConfig);
123
- expect(JSON.stringify(output)).to.deep.equal(expected);
124
-
125
- customConfig = {
126
- 'buckets': [{
127
- 'precision': 2,
128
- 'max': 6,
129
- 'increment': 0.01,
130
- }]
131
- };
132
- cpm = 4.01;
133
- expected = '{"low":"4.00","med":"4.00","high":"4.01","auto":"4.00","dense":"4.00","custom":"4.01"}';
134
- output = getPriceBucketString(cpm, customConfig);
135
- expect(JSON.stringify(output)).to.deep.equal(expected);
136
-
137
- cpm = 4.68;
138
- expected = '{"low":"4.50","med":"4.60","high":"4.68","auto":"4.65","dense":"4.65","custom":"4.68"}';
139
- output = getPriceBucketString(cpm, customConfig);
140
- expect(JSON.stringify(output)).to.deep.equal(expected);
141
-
142
- cpm = 4.69;
143
- expected = '{"low":"4.50","med":"4.60","high":"4.69","auto":"4.65","dense":"4.65","custom":"4.69"}';
144
- output = getPriceBucketString(cpm, customConfig);
145
- expect(JSON.stringify(output)).to.deep.equal(expected);
146
- });
147
-
148
- it('gets custom bucket strings and it should honor 0', function () {
149
- let cpm = 16.50908;
150
- let customConfig = {
151
- 'buckets': [
18
+ it('gets the correct custom bucket strings', function () {
19
+ let cpm = 16.50908;
20
+ let customConfig = {
21
+ 'buckets': [{
22
+ 'precision': 4,
23
+ 'max': 3,
24
+ 'increment': 0.01,
25
+ },
152
26
  {
153
- 'precision': 0,
27
+ 'precision': 4,
154
28
  'max': 18,
155
29
  'increment': 0.05,
156
- }
157
- ]
158
- };
159
- let expected = '{"low":"5.00","med":"16.50","high":"16.50","auto":"16.50","dense":"16.50","custom":"17"}';
160
- let output = getPriceBucketString(cpm, customConfig);
161
- expect(JSON.stringify(output)).to.deep.equal(expected);
162
- });
30
+ 'cap': true
31
+ }]
32
+ };
33
+ let expected = '{"low":"5.00","med":"16.50","high":"16.50","auto":"16.50","dense":"16.50","custom":"16.5000"}';
34
+ let output = getPriceBucketString(cpm, customConfig);
35
+ expect(JSON.stringify(output)).to.deep.equal(expected);
36
+ });
163
37
 
164
- it('gets the custom bucket strings without passing precision and it should honor the default precision', function () {
165
- let cpm = 16.50908;
166
- let customConfig = {
167
- 'buckets': [
38
+ it('gets the correct custom bucket strings with irregular increment', function () {
39
+ let cpm = 14.50908;
40
+ let customConfig = {
41
+ 'buckets': [{
42
+ 'precision': 4,
43
+ 'max': 4,
44
+ 'increment': 0.01,
45
+ },
168
46
  {
47
+ 'precision': 4,
48
+ 'max': 18,
49
+ 'increment': 0.3,
50
+ 'cap': true
51
+ }]
52
+ };
53
+ let expected = '{"low":"5.00","med":"14.50","high":"14.50","auto":"14.50","dense":"14.50","custom":"14.5000"}';
54
+ let output = getPriceBucketString(cpm, customConfig);
55
+ expect(JSON.stringify(output)).to.deep.equal(expected);
56
+ });
57
+
58
+ it('gets the correct custom bucket strings in non-USD currency', function () {
59
+ let cpm = 16.50908 * 110.49;
60
+ let customConfig = {
61
+ 'buckets': [{
62
+ 'precision': 4,
63
+ 'max': 3,
64
+ 'increment': 0.01,
65
+ },
66
+ {
67
+ 'precision': 4,
169
68
  'max': 18,
170
69
  'increment': 0.05,
171
- }
172
- ]
173
- };
174
- let expected = '{"low":"5.00","med":"16.50","high":"16.50","auto":"16.50","dense":"16.50","custom":"16.50"}';
175
- let output = getPriceBucketString(cpm, customConfig);
176
- expect(JSON.stringify(output)).to.deep.equal(expected);
70
+ 'cap': true
71
+ }]
72
+ };
73
+ let expected = '{"low":"552.45","med":"1823.09","high":"1823.09","auto":"1823.09","dense":"1823.09","custom":"1823.0850"}';
74
+ let output = getPriceBucketString(cpm, customConfig, 110.49);
75
+ expect(JSON.stringify(output)).to.deep.equal(expected);
76
+ });
77
+
78
+ it('gets the correct custom bucket strings with specific cpms that round oddly with certain increments', function () {
79
+ let customConfig = {
80
+ 'buckets': [{
81
+ 'precision': 4,
82
+ 'max': 4,
83
+ 'increment': 0.10,
84
+ }]
85
+ };
86
+ let cpm = 2.21;
87
+ let expected = '{"low":"2.00","med":"2.20","high":"2.21","auto":"2.20","dense":"2.21","custom":"2.2000"}';
88
+ let output = getPriceBucketString(cpm, customConfig);
89
+ expect(JSON.stringify(output)).to.deep.equal(expected);
90
+
91
+ cpm = 3.15;
92
+ expected = '{"low":"3.00","med":"3.10","high":"3.15","auto":"3.15","dense":"3.15","custom":"3.1000"}';
93
+ output = getPriceBucketString(cpm, customConfig);
94
+ expect(JSON.stringify(output)).to.deep.equal(expected);
95
+
96
+ customConfig = {
97
+ 'buckets': [{
98
+ 'precision': 3,
99
+ 'max': 6,
100
+ 'increment': 0.08,
101
+ }]
102
+ };
103
+ cpm = 4.89;
104
+ expected = '{"low":"4.50","med":"4.80","high":"4.89","auto":"4.85","dense":"4.85","custom":"4.880"}';
105
+ output = getPriceBucketString(cpm, customConfig);
106
+ expect(JSON.stringify(output)).to.deep.equal(expected);
107
+
108
+ customConfig = {
109
+ 'buckets': [{
110
+ 'precision': 3,
111
+ 'max': 6,
112
+ 'increment': 0.05,
113
+ }]
114
+ };
115
+ cpm = 2.98;
116
+ expected = '{"low":"2.50","med":"2.90","high":"2.98","auto":"2.95","dense":"2.98","custom":"2.950"}';
117
+ output = getPriceBucketString(cpm, customConfig);
118
+ expect(JSON.stringify(output)).to.deep.equal(expected);
119
+
120
+ cpm = 2.99;
121
+ expected = '{"low":"2.50","med":"2.90","high":"2.99","auto":"2.95","dense":"2.99","custom":"2.950"}';
122
+ output = getPriceBucketString(cpm, customConfig);
123
+ expect(JSON.stringify(output)).to.deep.equal(expected);
124
+
125
+ customConfig = {
126
+ 'buckets': [{
127
+ 'precision': 2,
128
+ 'max': 6,
129
+ 'increment': 0.01,
130
+ }]
131
+ };
132
+ cpm = 4.01;
133
+ expected = '{"low":"4.00","med":"4.00","high":"4.01","auto":"4.00","dense":"4.00","custom":"4.01"}';
134
+ output = getPriceBucketString(cpm, customConfig);
135
+ expect(JSON.stringify(output)).to.deep.equal(expected);
136
+
137
+ cpm = 4.68;
138
+ expected = '{"low":"4.50","med":"4.60","high":"4.68","auto":"4.65","dense":"4.65","custom":"4.68"}';
139
+ output = getPriceBucketString(cpm, customConfig);
140
+ expect(JSON.stringify(output)).to.deep.equal(expected);
141
+
142
+ cpm = 4.69;
143
+ expected = '{"low":"4.50","med":"4.60","high":"4.69","auto":"4.65","dense":"4.65","custom":"4.69"}';
144
+ output = getPriceBucketString(cpm, customConfig);
145
+ expect(JSON.stringify(output)).to.deep.equal(expected);
146
+ });
147
+
148
+ it('gets custom bucket strings and it should honor 0', function () {
149
+ let cpm = 16.50908;
150
+ let customConfig = {
151
+ 'buckets': [
152
+ {
153
+ 'precision': 0,
154
+ 'max': 18,
155
+ 'increment': 0.05,
156
+ }
157
+ ]
158
+ };
159
+ let expected = '{"low":"5.00","med":"16.50","high":"16.50","auto":"16.50","dense":"16.50","custom":"17"}';
160
+ let output = getPriceBucketString(cpm, customConfig);
161
+ expect(JSON.stringify(output)).to.deep.equal(expected);
162
+ });
163
+
164
+ it('gets the custom bucket strings without passing precision and it should honor the default precision', function () {
165
+ let cpm = 16.50908;
166
+ let customConfig = {
167
+ 'buckets': [
168
+ {
169
+ 'max': 18,
170
+ 'increment': 0.05,
171
+ }
172
+ ]
173
+ };
174
+ let expected = '{"low":"5.00","med":"16.50","high":"16.50","auto":"16.50","dense":"16.50","custom":"16.50"}';
175
+ let output = getPriceBucketString(cpm, customConfig);
176
+ expect(JSON.stringify(output)).to.deep.equal(expected);
177
+ });
178
+
179
+ it('defaults to Math.floor if no rounding function is provided', function () {
180
+ let cpm = 6.516;
181
+ let customConfig = {
182
+ 'buckets': [
183
+ {
184
+ 'max': 18,
185
+ 'increment': 0.05,
186
+ }
187
+ ]
188
+ };
189
+ let expected = '{"low":"5.00","med":"6.50","high":"6.51","auto":"6.50","dense":"6.50","custom":"6.50"}';
190
+ let output = getPriceBucketString(cpm, customConfig);
191
+ expect(JSON.stringify(output)).to.deep.equal(expected);
192
+ });
193
+
194
+ it('accepts custom rounding functions', function () {
195
+ let cpm = 6.516;
196
+ let customConfig = {
197
+ 'buckets': [
198
+ {
199
+ 'max': 18,
200
+ 'increment': 0.05,
201
+ }
202
+ ]
203
+ };
204
+ let getConfig = config.getConfig;
205
+ config.getConfig = () => Math.ceil;
206
+ let expected = '{"low":"5.00","med":"6.60","high":"6.52","auto":"6.60","dense":"6.55","custom":"6.55"}';
207
+ let output = getPriceBucketString(cpm, customConfig);
208
+ config.getConfig = getConfig;
209
+ expect(JSON.stringify(output)).to.deep.equal(expected);
210
+ });
211
+
212
+ it('will default to Math.floor if passed an invalid rounding function', function () {
213
+ let cpm = 6.516;
214
+ let customConfig = {
215
+ 'buckets': [
216
+ {
217
+ 'max': 18,
218
+ 'increment': 0.05,
219
+ }
220
+ ]
221
+ };
222
+ let getConfig = config.getConfig;
223
+ config.getConfig = () => Math.ceil(5.3);
224
+ let expected = '{"low":"5.00","med":"6.50","high":"6.51","auto":"6.50","dense":"6.50","custom":"6.50"}';
225
+ let output = getPriceBucketString(cpm, customConfig);
226
+ config.getConfig = getConfig;
227
+ expect(JSON.stringify(output)).to.deep.equal(expected);
228
+ });
177
229
  });
178
230
 
179
- it('checks whether custom config is valid', function () {
180
- let badConfig = {
181
- 'buckets': [{
182
- 'max': 3,
183
- 'increment': 0.01,
184
- },
185
- {
186
- 'max': 18,
187
- // missing increment prop
188
- 'cap': true
189
- }
190
- ]
191
- };
231
+ describe('isValidPriceConfig', function () {
232
+ it('checks whether custom config is valid', function () {
233
+ let badConfig = {
234
+ 'buckets': [{
235
+ 'max': 3,
236
+ 'increment': 0.01,
237
+ },
238
+ {
239
+ 'max': 18,
240
+ // missing increment prop
241
+ 'cap': true
242
+ }]
243
+ };
244
+ expect(isValidPriceConfig(badConfig)).to.be.false;
192
245
 
193
- expect(isValidPriceConfig(badConfig)).to.be.false;
246
+ let customConfig = {
247
+ 'buckets': [
248
+ {
249
+ 'max': 18,
250
+ 'increment': 0.05,
251
+ }
252
+ ]
253
+ };
254
+ expect(isValidPriceConfig(customConfig)).to.be.true;
255
+ });
194
256
  });
195
257
  });
@@ -0,0 +1,244 @@
1
+ import {
2
+ highEntropySUAAccessor,
3
+ lowEntropySUAAccessor,
4
+ SUA_SOURCE_HIGH_ENTROPY,
5
+ SUA_SOURCE_LOW_ENTROPY,
6
+ SUA_SOURCE_UNKNOWN,
7
+ suaFromUAData,
8
+ uaDataToSUA
9
+ } from '../../../libraries/fpd/sua.js';
10
+
11
+ describe('uaDataToSUA', () => {
12
+ Object.entries({
13
+ 'platform': 'platform',
14
+ 'browsers': 'brands',
15
+ 'mobile': 'mobile',
16
+ 'architecture': 'architecture',
17
+ 'model': 'model',
18
+ 'bitness': 'bitness'
19
+ }).forEach(([suaKey, uaKey]) => {
20
+ it(`should not set ${suaKey} if ${uaKey} is missing from UAData`, () => {
21
+ const example = {
22
+ platform: 'Windows',
23
+ brands: [{brand: 'Mock', version: 'mk'}],
24
+ mobile: true,
25
+ model: 'mockModel',
26
+ bitness: '64',
27
+ architecture: 'arm'
28
+ }
29
+ delete example[uaKey];
30
+ const sua = uaDataToSUA(SUA_SOURCE_UNKNOWN, example);
31
+ expect(sua.hasOwnProperty(suaKey)).to.be.false;
32
+ })
33
+ });
34
+
35
+ it('should convert low-entropy userAgentData', () => {
36
+ const sua = uaDataToSUA(SUA_SOURCE_LOW_ENTROPY, {
37
+ 'brands': [
38
+ {
39
+ 'brand': '.Not/A)Brand',
40
+ 'version': '99'
41
+ },
42
+ {
43
+ 'brand': 'Google Chrome',
44
+ 'version': '103'
45
+ },
46
+ {
47
+ 'brand': 'Chromium',
48
+ 'version': '103'
49
+ }
50
+ ],
51
+ 'mobile': false,
52
+ 'platform': 'Linux'
53
+ });
54
+
55
+ expect(sua).to.eql({
56
+ source: SUA_SOURCE_LOW_ENTROPY,
57
+ mobile: 0,
58
+ platform: {
59
+ brand: 'Linux',
60
+ },
61
+ browsers: [
62
+ {
63
+ brand: '.Not/A)Brand',
64
+ version: [
65
+ '99'
66
+ ]
67
+ },
68
+ {
69
+ brand: 'Google Chrome',
70
+ version: [
71
+ '103'
72
+ ]
73
+ },
74
+ {
75
+ brand: 'Chromium',
76
+ version: [
77
+ '103'
78
+ ]
79
+ }
80
+ ]
81
+ })
82
+ });
83
+
84
+ it('should convert high entropy properties', () => {
85
+ const uaData = {
86
+ architecture: 'x86',
87
+ bitness: '64',
88
+ fullVersionList: [
89
+ {
90
+ 'brand': '.Not/A)Brand',
91
+ 'version': '99.0.0.0'
92
+ },
93
+ {
94
+ 'brand': 'Google Chrome',
95
+ 'version': '103.0.5060.134'
96
+ },
97
+ {
98
+ 'brand': 'Chromium',
99
+ 'version': '103.0.5060.134'
100
+ }
101
+ ],
102
+ brands: [
103
+ {
104
+ 'brand': '.Not/A)Brand',
105
+ 'version': '99'
106
+ },
107
+ {
108
+ 'brand': 'Google Chrome',
109
+ 'version': '103'
110
+ },
111
+ {
112
+ 'brand': 'Chromium',
113
+ 'version': '103'
114
+ }
115
+ ],
116
+ model: 'mockModel',
117
+ platform: 'Linux',
118
+ platformVersion: '5.14.0'
119
+ }
120
+
121
+ expect(uaDataToSUA(SUA_SOURCE_HIGH_ENTROPY, uaData)).to.eql({
122
+ source: SUA_SOURCE_HIGH_ENTROPY,
123
+ architecture: 'x86',
124
+ bitness: '64',
125
+ model: 'mockModel',
126
+ platform: {
127
+ brand: 'Linux',
128
+ version: [
129
+ '5',
130
+ '14',
131
+ '0'
132
+ ]
133
+ },
134
+ browsers: [
135
+ {
136
+ brand: '.Not/A)Brand',
137
+ version: [
138
+ '99',
139
+ '0',
140
+ '0',
141
+ '0'
142
+ ]
143
+ },
144
+ {
145
+ brand: 'Google Chrome',
146
+ version: [
147
+ '103',
148
+ '0',
149
+ '5060',
150
+ '134'
151
+ ]
152
+ },
153
+ {
154
+ brand: 'Chromium',
155
+ version: [
156
+ '103',
157
+ '0',
158
+ '5060',
159
+ '134'
160
+ ]
161
+ }
162
+ ]
163
+ })
164
+ })
165
+ });
166
+
167
+ describe('lowEntropySUAAccessor', () => {
168
+ function getSUA(uaData) {
169
+ return lowEntropySUAAccessor(uaData)();
170
+ }
171
+
172
+ it('should not be modifiable', () => {
173
+ const sua = getSUA({});
174
+ expect(() => { sua.prop = 'value'; }).to.throw();
175
+ });
176
+
177
+ it('should return null if no uaData is available', () => {
178
+ expect(getSUA(null)).to.eql(null);
179
+ })
180
+
181
+ it('should return null if uaData is empty', () => {
182
+ expect(getSUA({})).to.eql(null);
183
+ })
184
+ });
185
+
186
+ describe('highEntropySUAAccessor', () => {
187
+ let userAgentData, uaResult, getSUA;
188
+ beforeEach(() => {
189
+ uaResult = {};
190
+ userAgentData = {
191
+ getHighEntropyValues: sinon.stub().callsFake(() => Promise.resolve(uaResult))
192
+ };
193
+ getSUA = highEntropySUAAccessor(userAgentData);
194
+ });
195
+
196
+ describe('should resolve to null if', () => {
197
+ it('uaData is not available', () => {
198
+ getSUA = highEntropySUAAccessor(null);
199
+ return getSUA().then((result) => {
200
+ expect(result).to.eql(null);
201
+ })
202
+ });
203
+ it('getHighEntropyValues is not avialable', () => {
204
+ delete userAgentData.getHighEntropyValues;
205
+ return getSUA().then((result) => {
206
+ expect(result).to.eql(null);
207
+ })
208
+ });
209
+ it('getHighEntropyValues throws', () => {
210
+ userAgentData.getHighEntropyValues.callsFake(() => { throw new Error() });
211
+ return getSUA().then((result) => {
212
+ expect(result).to.eql(null);
213
+ })
214
+ });
215
+ it('getHighEntropyValues rejects', () => {
216
+ userAgentData.getHighEntropyValues.callsFake(() => Promise.reject(new Error()));
217
+ return getSUA().then((result) => {
218
+ expect(result).to.eql(null);
219
+ })
220
+ });
221
+ it('getHighEntropyValues returns an empty object', () => {
222
+ userAgentData.getHighEntropyValues.callsFake(() => Promise.resolve({}));
223
+ return getSUA().then((result) => {
224
+ expect(result).to.eql(null);
225
+ });
226
+ })
227
+ });
228
+ it('should pass hints to userAgentData', () => {
229
+ getSUA(['h1', 'h2']);
230
+ sinon.assert.calledWith(userAgentData.getHighEntropyValues, ['h1', 'h2']);
231
+ });
232
+
233
+ it('should cache results for a set of hints', () => {
234
+ getSUA(['h1', 'h2']);
235
+ getSUA(['h2', 'h1']);
236
+ sinon.assert.calledOnce(userAgentData.getHighEntropyValues);
237
+ });
238
+
239
+ it('should return unmodifiable objects', () => {
240
+ return getSUA().then(result => {
241
+ expect(() => { result.prop = 'value'; }).to.throw();
242
+ })
243
+ })
244
+ })
@@ -170,11 +170,10 @@ describe('Adf adapter', function () {
170
170
  let validBidRequests = [{
171
171
  bidId: 'bidId',
172
172
  params: { siteId: 'siteId' },
173
- transactionId: 'transactionId'
174
173
  }];
175
- let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data);
174
+ let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' }, auctionId: 'tid' }).data);
176
175
 
177
- assert.equal(request.source.tid, validBidRequests[0].transactionId);
176
+ assert.equal(request.source.tid, 'tid');
178
177
  assert.equal(request.source.fd, 1);
179
178
  });
180
179