prebid.js 7.34.0 → 7.35.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 (169) hide show
  1. package/.devcontainer/devcontainer.json +2 -1
  2. package/.github/workflows/issue_tracker.yml +1 -1
  3. package/dist/33acrossBidAdapter.js +1 -1
  4. package/dist/33acrossIdSystem.js +1 -1
  5. package/dist/adagioBidAdapter.js +1 -1
  6. package/dist/adbookpspBidAdapter.js +1 -1
  7. package/dist/adgenerationBidAdapter.js +1 -1
  8. package/dist/adrelevantisBidAdapter.js +1 -1
  9. package/dist/adtrgtmeBidAdapter.js +1 -1
  10. package/dist/adxcgBidAdapter.js +1 -1
  11. package/dist/adyoulikeBidAdapter.js +1 -1
  12. package/dist/ajaBidAdapter.js +1 -1
  13. package/dist/amxBidAdapter.js +1 -1
  14. package/dist/amxIdSystem.js +1 -1
  15. package/dist/appierAnalyticsAdapter.js +1 -1
  16. package/dist/appnexusBidAdapter.js +1 -1
  17. package/dist/asoBidAdapter.js +1 -1
  18. package/dist/axonixBidAdapter.js +1 -1
  19. package/dist/bidglassBidAdapter.js +1 -1
  20. package/dist/big-richmediaBidAdapter.js +1 -1
  21. package/dist/bridgewellBidAdapter.js +1 -1
  22. package/dist/brightMountainMediaBidAdapter.js +1 -1
  23. package/dist/carodaBidAdapter.js +1 -1
  24. package/dist/chtnwBidAdapter.js +1 -1
  25. package/dist/concertBidAdapter.js +1 -1
  26. package/dist/connectadBidAdapter.js +1 -1
  27. package/dist/consentManagement.js +1 -1
  28. package/dist/consumableBidAdapter.js +1 -1
  29. package/dist/conversantBidAdapter.js +1 -1
  30. package/dist/craftBidAdapter.js +1 -1
  31. package/dist/criteoBidAdapter.js +1 -1
  32. package/dist/cwireBidAdapter.js +1 -1
  33. package/dist/dspxBidAdapter.js +1 -1
  34. package/dist/eplanningBidAdapter.js +1 -1
  35. package/dist/feedadBidAdapter.js +1 -1
  36. package/dist/finativeBidAdapter.js +1 -1
  37. package/dist/glimpseBidAdapter.js +1 -1
  38. package/dist/gmosspBidAdapter.js +1 -1
  39. package/dist/goldbachBidAdapter.js +1 -1
  40. package/dist/gridBidAdapter.js +1 -1
  41. package/dist/gridNMBidAdapter.js +1 -1
  42. package/dist/gumgumBidAdapter.js +1 -1
  43. package/dist/h12mediaBidAdapter.js +1 -1
  44. package/dist/hadronIdSystem.js +1 -1
  45. package/dist/id5IdSystem.js +1 -1
  46. package/dist/improvedigitalBidAdapter.js +1 -1
  47. package/dist/inmarBidAdapter.js +1 -1
  48. package/dist/insticatorBidAdapter.js +1 -1
  49. package/dist/ixBidAdapter.js +1 -1
  50. package/dist/justpremiumBidAdapter.js +1 -1
  51. package/dist/konduitAnalyticsAdapter.js +1 -1
  52. package/dist/kueezBidAdapter.js +1 -1
  53. package/dist/kueezRtbBidAdapter.js +1 -1
  54. package/dist/lassoBidAdapter.js +1 -1
  55. package/dist/lifestreetBidAdapter.js +1 -1
  56. package/dist/liveyieldAnalyticsAdapter.js +1 -1
  57. package/dist/logicadBidAdapter.js +1 -1
  58. package/dist/loglyliftBidAdapter.js +1 -1
  59. package/dist/magniteAnalyticsAdapter.js +1 -1
  60. package/dist/malltvAnalyticsAdapter.js +1 -1
  61. package/dist/marsmediaBidAdapter.js +1 -1
  62. package/dist/mediafuseBidAdapter.js +1 -1
  63. package/dist/mediasquareBidAdapter.js +1 -1
  64. package/dist/mgidBidAdapter.js +1 -1
  65. package/dist/minutemediaBidAdapter.js +1 -1
  66. package/dist/nexx360BidAdapter.js +1 -1
  67. package/dist/not-for-prod/prebid.js +127 -137
  68. package/dist/oguryBidAdapter.js +1 -1
  69. package/dist/onetagBidAdapter.js +1 -1
  70. package/dist/ooloAnalyticsAdapter.js +1 -1
  71. package/dist/outbrainBidAdapter.js +1 -1
  72. package/dist/parrableIdSystem.js +1 -1
  73. package/dist/permutiveRtdProvider.js +1 -1
  74. package/dist/pixfutureBidAdapter.js +1 -1
  75. package/dist/prebid-core.js +1 -1
  76. package/dist/priceFloors.js +1 -1
  77. package/dist/publinkIdSystem.js +1 -1
  78. package/dist/pubmaticBidAdapter.js +1 -1
  79. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  80. package/dist/pulsepointBidAdapter.js +1 -1
  81. package/dist/pxyzBidAdapter.js +1 -1
  82. package/dist/quantcastBidAdapter.js +1 -1
  83. package/dist/readpeakBidAdapter.js +1 -1
  84. package/dist/relaidoBidAdapter.js +1 -1
  85. package/dist/rhythmoneBidAdapter.js +1 -1
  86. package/dist/riseBidAdapter.js +1 -1
  87. package/dist/rubiconAnalyticsAdapter.js +1 -1
  88. package/dist/rubiconBidAdapter.js +1 -1
  89. package/dist/seedingAllianceBidAdapter.js +1 -1
  90. package/dist/seedtagBidAdapter.js +1 -1
  91. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  92. package/dist/sharethroughBidAdapter.js +1 -1
  93. package/dist/shinezBidAdapter.js +1 -1
  94. package/dist/smaatoBidAdapter.js +1 -1
  95. package/dist/smartadserverBidAdapter.js +1 -1
  96. package/dist/smartxBidAdapter.js +1 -1
  97. package/dist/smartytechBidAdapter.js +1 -1
  98. package/dist/smilewantedBidAdapter.js +1 -1
  99. package/dist/sonobiBidAdapter.js +1 -1
  100. package/dist/sovrnAnalyticsAdapter.js +1 -1
  101. package/dist/sovrnBidAdapter.js +1 -1
  102. package/dist/sspBCBidAdapter.js +1 -1
  103. package/dist/sublimeBidAdapter.js +1 -1
  104. package/dist/synacormediaBidAdapter.js +1 -1
  105. package/dist/taboolaBidAdapter.js +1 -1
  106. package/dist/targetVideoBidAdapter.js +1 -1
  107. package/dist/teadsBidAdapter.js +1 -1
  108. package/dist/trionBidAdapter.js +1 -1
  109. package/dist/tripleliftBidAdapter.js +1 -1
  110. package/dist/ttdBidAdapter.js +1 -1
  111. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  112. package/dist/uid2IdSystem.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/yieldmoBidAdapter.js +1 -1
  123. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  124. package/dist/zeta_global_sspBidAdapter.js +1 -1
  125. package/dist/zeusPrimeRtdProvider.js +4 -14
  126. package/integrationExamples/gpt/hello_world.html +0 -0
  127. package/modules/adyoulikeBidAdapter.js +2 -0
  128. package/modules/consentManagement.js +33 -5
  129. package/modules/cwireBidAdapter.js +169 -242
  130. package/modules/cwireBidAdapter.md +15 -14
  131. package/modules/hadronIdSystem.js +37 -32
  132. package/modules/nexx360BidAdapter.js +1 -2
  133. package/modules/onetagBidAdapter.js +12 -1
  134. package/modules/outbrainBidAdapter.js +103 -6
  135. package/modules/permutiveRtdProvider.js +17 -12
  136. package/modules/priceFloors.js +7 -8
  137. package/modules/pulsepointBidAdapter.js +2 -0
  138. package/modules/smartadserverBidAdapter.js +39 -28
  139. package/modules/smartyadsBidAdapter.md +9 -0
  140. package/modules/smartytechBidAdapter.js +67 -10
  141. package/modules/smartytechBidAdapter.md +44 -33
  142. package/modules/sonobiBidAdapter.js +17 -10
  143. package/modules/taboolaBidAdapter.js +2 -1
  144. package/modules/vidazooBidAdapter.js +56 -22
  145. package/modules/zeta_global_sspBidAdapter.js +15 -0
  146. package/modules/zeusPrimeRtdProvider.js +3 -323
  147. package/modules/zeusPrimeRtdProvider.md +3 -0
  148. package/package.json +1 -1
  149. package/src/auction.js +2 -11
  150. package/src/prebid.js +8 -0
  151. package/src/utils/cpm.js +17 -0
  152. package/test/spec/modules/adyoulikeBidAdapter_spec.js +3 -0
  153. package/test/spec/modules/consentManagement_spec.js +49 -1
  154. package/test/spec/modules/cwireBidAdapter_spec.js +249 -335
  155. package/test/spec/modules/hadronIdSystem_spec.js +4 -6
  156. package/test/spec/modules/nexx360BidAdapter_spec.js +0 -4
  157. package/test/spec/modules/onetagBidAdapter_spec.js +43 -0
  158. package/test/spec/modules/outbrainBidAdapter_spec.js +182 -18
  159. package/test/spec/modules/pulsepointBidAdapter_spec.js +11 -1
  160. package/test/spec/modules/smartadserverBidAdapter_spec.js +116 -5
  161. package/test/spec/modules/smartytechBidAdapter_spec.js +172 -14
  162. package/test/spec/modules/sonobiBidAdapter_spec.js +2 -1
  163. package/test/spec/modules/taboolaBidAdapter_spec.js +12 -3
  164. package/test/spec/modules/userId_spec.js +19 -14
  165. package/test/spec/modules/vidazooBidAdapter_spec.js +61 -22
  166. package/test/spec/modules/zeta_global_sspBidAdapter_spec.js +8 -0
  167. package/test/spec/unit/pbjs_api_spec.js +14 -0
  168. package/test/spec/unit/utils/cpm_spec.js +64 -0
  169. package/test/spec/modules/zeusPrimeRtdProvider_spec.js +0 -410
@@ -41,6 +41,7 @@ describe('Zeta Ssp Bid Adapter', function () {
41
41
  app: {
42
42
  bundle: 'testBundle'
43
43
  },
44
+ bidfloor: 0.2,
44
45
  test: 1
45
46
  };
46
47
 
@@ -359,4 +360,11 @@ describe('Zeta Ssp Bid Adapter', function () {
359
360
 
360
361
  expect(payload.tmax).to.be.undefined;
361
362
  });
363
+
364
+ it('Test provide bidfloor', function () {
365
+ const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
366
+ const payload = JSON.parse(request.data);
367
+
368
+ expect(payload.imp[0].bidfloor).to.eql(params.bidfloor);
369
+ });
362
370
  });
@@ -3017,6 +3017,20 @@ describe('Unit: Prebid Module', function () {
3017
3017
  });
3018
3018
  });
3019
3019
 
3020
+ describe('aliasRegistry', function () {
3021
+ it('should return the same value as adapterManager.aliasRegistry by default', function () {
3022
+ const adapterManagerAliasRegistry = adapterManager.aliasRegistry;
3023
+ const pbjsAliasRegistry = $$PREBID_GLOBAL$$.aliasRegistry;
3024
+ assert.equal(adapterManagerAliasRegistry, pbjsAliasRegistry);
3025
+ });
3026
+
3027
+ it('should return undefined if the aliasRegistry config option is set to private', function () {
3028
+ configObj.setConfig({ aliasRegistry: 'private' });
3029
+ const pbjsAliasRegistry = $$PREBID_GLOBAL$$.aliasRegistry;
3030
+ assert.equal(pbjsAliasRegistry, undefined);
3031
+ });
3032
+ });
3033
+
3020
3034
  describe('setPriceGranularity', function () {
3021
3035
  it('should log error when not passed granularity', function () {
3022
3036
  const logErrorSpy = sinon.spy(utils, 'logError');
@@ -0,0 +1,64 @@
1
+ import {adjustCpm} from '../../../../src/utils/cpm.js';
2
+
3
+ describe('adjustCpm', () => {
4
+ const bidderCode = 'mockBidder';
5
+ let adjustmentFn, bs, index;
6
+ beforeEach(() => {
7
+ bs = {
8
+ get: sinon.stub()
9
+ }
10
+ index = {
11
+ getBidRequest: sinon.stub()
12
+ }
13
+ adjustmentFn = sinon.stub().callsFake((cpm) => cpm * 2);
14
+ })
15
+
16
+ it('throws when neither bidRequest nor bidResponse are provided', () => {
17
+ expect(() => adjustCpm(1)).to.throw();
18
+ })
19
+
20
+ it('always provides an object as bidResponse for the adjustment fn', () => {
21
+ bs.get.callsFake(() => adjustmentFn);
22
+ adjustCpm(1, null, {bidder: bidderCode}, {index, bs});
23
+ sinon.assert.calledWith(adjustmentFn, 1, {});
24
+ });
25
+
26
+ describe('when no bidRequest is provided', () => {
27
+ Object.entries({
28
+ 'unavailable': undefined,
29
+ 'found': {foo: 'bar'}
30
+ }).forEach(([t, req]) => {
31
+ describe(`and it is ${t} in the index`, () => {
32
+ beforeEach(() => {
33
+ bs.get.callsFake(() => adjustmentFn);
34
+ index.getBidRequest.callsFake(() => req)
35
+ });
36
+
37
+ it('provides it to the adjustment fn', () => {
38
+ const bidResponse = {bidderCode};
39
+ adjustCpm(1, bidResponse, undefined, {index, bs});
40
+ sinon.assert.calledWith(index.getBidRequest, bidResponse);
41
+ sinon.assert.calledWith(adjustmentFn, 1, bidResponse, req);
42
+ })
43
+ })
44
+ })
45
+ });
46
+
47
+ Object.entries({
48
+ 'bidResponse': [{bidderCode}],
49
+ 'bidRequest': [null, {bidder: bidderCode}],
50
+ }).forEach(([t, [bidResp, bidReq]]) => {
51
+ describe(`when passed ${t}`, () => {
52
+ beforeEach(() => {
53
+ bs.get.callsFake((bidder) => { if (bidder === bidderCode) return adjustmentFn });
54
+ });
55
+ it('retrieves the correct bidder code', () => {
56
+ expect(adjustCpm(1, bidResp, bidReq, {bs, index})).to.eql(2);
57
+ });
58
+ it('passes them to the adjustment fn', () => {
59
+ adjustCpm(1, bidResp, bidReq, {bs, index});
60
+ sinon.assert.calledWith(adjustmentFn, 1, bidResp == null ? sinon.match.any : bidResp, bidReq);
61
+ });
62
+ });
63
+ })
64
+ });
@@ -1,410 +0,0 @@
1
- import { zeusPrimeSubmodule } from 'modules/zeusPrimeRtdProvider';
2
- import { server } from 'test/mocks/xhr.js';
3
- import * as utils from 'src/utils';
4
-
5
- async function waitForStatus(statusVar) {
6
- const MAX_COUNT = 20;
7
- let count = 0;
8
- while (
9
- count <= MAX_COUNT &&
10
- window.zeusPrime.status &&
11
- window.zeusPrime.status[statusVar] !== true
12
- ) {
13
- count += 1;
14
- await new Promise((resolve) => setTimeout(resolve, 10));
15
- }
16
-
17
- if (count === MAX_COUNT) {
18
- throw new Error('Timeout waiting for zeusPrimeRtdProvider to complete');
19
- }
20
- }
21
-
22
- /**
23
- * Execute all the commands in the googletag.cmd queue.
24
- */
25
- function executeGoogletagTargeting() {
26
- window.googletag.cmd.forEach((cmd) => cmd());
27
- }
28
-
29
- describe('Zeus Prime RTD submodule', () => {
30
- let logErrorSpy;
31
- let logMessageSpy;
32
- let setTargetingStub;
33
- let originalGtag;
34
-
35
- beforeEach(() => {
36
- logErrorSpy = sinon.spy(utils, 'logError');
37
- logMessageSpy = sinon.spy(utils, 'logMessage');
38
- setTargetingStub = sinon.stub();
39
- window.zeusPrime = { cmd: [] };
40
- originalGtag = window.googletag;
41
- window.googletag = {
42
- cmd: [],
43
- pubads: () => ({
44
- setTargeting: setTargetingStub,
45
- }),
46
- };
47
-
48
- // Mock subtle since this doesnt exists in some test environments due to security in newer browsers.
49
- if (typeof window.crypto.subtle === 'undefined') {
50
- Object.defineProperty(crypto, 'subtle', { value: { digest: () => 'mockHash' } })
51
- }
52
- });
53
-
54
- afterEach(() => {
55
- logErrorSpy.restore();
56
- logMessageSpy.restore();
57
- window.googletag = originalGtag;
58
- });
59
-
60
- it('should init and set key-value for zeus_<gamId>', async () => {
61
- zeusPrimeSubmodule.init({
62
- params: {
63
- gamId: '1234',
64
- hostname: 'www.example.com',
65
- pathname: '/',
66
- },
67
- });
68
-
69
- // wait for the script to finish
70
- await waitForStatus('scriptComplete');
71
-
72
- // execute any googletag commands added to the queue during execution
73
- executeGoogletagTargeting();
74
-
75
- expect(window.googletag.cmd).to.have.length(1);
76
- sinon.assert.callCount(setTargetingStub, 1);
77
- sinon.assert.calledWith(setTargetingStub, 'zeus_1234', 'www.example.com');
78
- });
79
-
80
- it('should init and set key-value for zeus_<gamId> from command queue', async () => {
81
- window.zeusPrime.cmd.push((prime) => (prime.gamId = '9876'));
82
- zeusPrimeSubmodule.init({
83
- params: {
84
- hostname: 'www.example.com',
85
- pathname: '/',
86
- },
87
- });
88
-
89
- // wait for the script to finish
90
- await waitForStatus('scriptComplete');
91
-
92
- // execute any googletag commands added to the queue during execution
93
- executeGoogletagTargeting();
94
-
95
- expect(window.googletag.cmd).to.have.length(1);
96
- sinon.assert.callCount(setTargetingStub, 1);
97
- sinon.assert.calledWith(setTargetingStub, 'zeus_9876', 'www.example.com');
98
- });
99
-
100
- it('should init with values from location and set key-value for zeus_<gamId>', async () => {
101
- zeusPrimeSubmodule.init({ params: { gamId: '1234' } });
102
-
103
- // wait for the script to finish
104
- await waitForStatus('scriptComplete');
105
-
106
- // execute any googletag commands added to the queue during execution
107
- executeGoogletagTargeting();
108
-
109
- expect(window.googletag.cmd).to.have.length(1);
110
- sinon.assert.callCount(setTargetingStub, 1);
111
- sinon.assert.calledWith(setTargetingStub, 'zeus_1234', 'localhost');
112
- expect(window.zeusPrime.pathname).to.equal('/context.html');
113
- });
114
-
115
- it('should emit error when gamId is not set', async () => {
116
- zeusPrimeSubmodule.init({});
117
-
118
- // wait for the script to finish
119
- await waitForStatus('scriptComplete');
120
-
121
- // execute any googletag commands added to the queue during execution
122
- executeGoogletagTargeting();
123
-
124
- expect(window.googletag.cmd).to.have.length(0);
125
- sinon.assert.callCount(setTargetingStub, 0);
126
- sinon.assert.calledWith(
127
- logErrorSpy,
128
- 'zeusPrimeRtdProvider: ',
129
- 'Failed to run.',
130
- 'window.zeusPrime.gamId must be a string. Received: undefined'
131
- );
132
- });
133
-
134
- it('should not make a call to the server when url is a homepage', async () => {
135
- zeusPrimeSubmodule.init({
136
- params: {
137
- gamId: '1234',
138
- hostname: 'www.example.com',
139
- pathname: '/',
140
- },
141
- });
142
-
143
- // wait for the script to finish
144
- await waitForStatus('scriptComplete');
145
-
146
- expect(server.requests).to.have.length(0);
147
- });
148
-
149
- it('should make a call to the server and set key-vlaue when url is an article page and returns topics', async () => {
150
- zeusPrimeSubmodule.init({
151
- params: {
152
- gamId: '1234',
153
- hostname: 'www.example.com',
154
- pathname: '/article/some-article',
155
- },
156
- });
157
-
158
- // Wait for request to be sent
159
- await waitForStatus('insightsReqReceived');
160
-
161
- // Response
162
- server.requests[0].respond(
163
- 200,
164
- { 'Content-Type': 'application/json' },
165
- '{"topics": ["bs0"]}'
166
- );
167
-
168
- // Wait for the script to process the response
169
- await waitForStatus('scriptComplete');
170
-
171
- // execute any googletag commands added to the queue during execution
172
- executeGoogletagTargeting();
173
-
174
- expect(server.requestCount).to.be.equal(1);
175
- expect(window.googletag.cmd).to.have.length(2);
176
- sinon.assert.calledTwice(setTargetingStub);
177
- sinon.assert.calledWith(
178
- setTargetingStub.firstCall,
179
- 'zeus_1234',
180
- 'www.example.com'
181
- );
182
- sinon.assert.calledWith(setTargetingStub.secondCall, 'zeus_insights', [
183
- 'bs0',
184
- ]);
185
- sinon.assert.notCalled(logErrorSpy);
186
- });
187
-
188
- it('should not set insights keyvalue when server returns 204', async () => {
189
- zeusPrimeSubmodule.init({
190
- params: {
191
- gamId: '1234',
192
- hostname: 'www.example.com',
193
- pathname: '/article/some-article',
194
- },
195
- });
196
-
197
- // Wait for request to be sent
198
- await waitForStatus('insightsReqReceived');
199
-
200
- // Response
201
- server.requests[0].respond(204, { 'Content-Type': 'application/json' });
202
-
203
- // Wait for the script to process the response
204
- await waitForStatus('scriptComplete');
205
-
206
- // execute any googletag commands added to the queue during execution
207
- executeGoogletagTargeting();
208
-
209
- expect(server.requestCount).to.be.equal(1);
210
- expect(window.googletag.cmd).to.have.length(1);
211
- sinon.assert.calledOnce(setTargetingStub);
212
- sinon.assert.calledWith(
213
- setTargetingStub.firstCall,
214
- 'zeus_1234',
215
- 'www.example.com'
216
- );
217
- sinon.assert.notCalled(logErrorSpy);
218
- });
219
-
220
- it('should not set insights keyvalue when server returns empty topics array', async () => {
221
- zeusPrimeSubmodule.init({
222
- params: {
223
- gamId: '1234',
224
- hostname: 'www.example.com',
225
- pathname: '/article/some-article',
226
- },
227
- });
228
-
229
- // Wait for request to be sent
230
- await waitForStatus('insightsReqReceived');
231
-
232
- // Respond
233
- server.requests[0].respond(
234
- 200,
235
- { 'Content-Type': 'application/json' },
236
- '{ "topics": [] }'
237
- );
238
-
239
- // Wait for the script to process the response
240
- await waitForStatus('scriptComplete');
241
-
242
- // execute any googletag commands added to the queue during execution
243
- executeGoogletagTargeting();
244
-
245
- expect(server.requestCount).to.be.equal(1);
246
- expect(window.googletag.cmd).to.have.length(1);
247
- sinon.assert.calledOnce(setTargetingStub);
248
- sinon.assert.calledWith(
249
- setTargetingStub.firstCall,
250
- 'zeus_1234',
251
- 'www.example.com'
252
- );
253
- sinon.assert.notCalled(logErrorSpy);
254
- });
255
-
256
- it('should not set insights keyvalue and emit error when server returns error status (400)', async () => {
257
- zeusPrimeSubmodule.init({
258
- params: {
259
- gamId: '1234',
260
- hostname: 'www.example.com',
261
- pathname: '/article/some-article',
262
- },
263
- });
264
-
265
- // Wait for request to be sent
266
- await waitForStatus('insightsReqReceived');
267
-
268
- // Response
269
- server.requests[0].respond(
270
- 404,
271
- { 'Content-Type': 'application/json' },
272
- '{"message": "Not found"}'
273
- );
274
-
275
- // Wait for the script to process the response
276
- await waitForStatus('scriptComplete');
277
-
278
- // execute any googletag commands added to the queue during execution
279
- executeGoogletagTargeting();
280
-
281
- expect(server.requestCount).to.be.equal(1);
282
- expect(window.googletag.cmd).to.have.length(1);
283
- sinon.assert.calledOnce(setTargetingStub);
284
- sinon.assert.calledWith(
285
- setTargetingStub.firstCall,
286
- 'zeus_1234',
287
- 'www.example.com'
288
- );
289
- sinon.assert.calledWith(
290
- logErrorSpy,
291
- 'zeusPrimeRtdProvider: ',
292
- 'Topics request returned error: 404'
293
- );
294
- });
295
-
296
- it('should not set insights keyvalue and emit error when response is not received (network request)', async () => {
297
- zeusPrimeSubmodule.init({
298
- params: {
299
- gamId: '1234',
300
- hostname: 'www.example.com',
301
- pathname: '/article/some-article',
302
- },
303
- });
304
-
305
- // Wait for request to be sent
306
- await waitForStatus('insightsReqReceived');
307
-
308
- // Response
309
- server.requests[0].error();
310
-
311
- // Wait for the script to process the response
312
- await waitForStatus('scriptComplete');
313
-
314
- // execute any googletag commands added to the queue during execution
315
- executeGoogletagTargeting();
316
-
317
- expect(server.requestCount).to.be.equal(1);
318
- expect(window.googletag.cmd).to.have.length(1);
319
- sinon.assert.calledOnce(setTargetingStub);
320
- sinon.assert.calledWith(
321
- setTargetingStub.firstCall,
322
- 'zeus_1234',
323
- 'www.example.com'
324
- );
325
- sinon.assert.calledWith(
326
- logErrorSpy,
327
- 'zeusPrimeRtdProvider: ',
328
- 'failed to request topics'
329
- );
330
- });
331
-
332
- it('fails gracefully when crypto fails', async () => {
333
- const digestStub = sinon.stub(window.crypto.subtle, 'digest');
334
- digestStub.throwsException('Failed to generate digest.');
335
-
336
- zeusPrimeSubmodule.init({
337
- params: {
338
- gamId: '1234',
339
- hostname: 'www.example.com',
340
- pathname: '/article/some-article',
341
- },
342
- });
343
-
344
- // Wait for request to be sent
345
- await waitForStatus('scriptComplete');
346
-
347
- sinon.assert.calledWith(
348
- logErrorSpy,
349
- 'zeusPrimeRtdProvider: ',
350
- 'Failed to load hash'
351
- );
352
-
353
- digestStub.restore();
354
- });
355
-
356
- it('script should add zeus_prime key and not send request when disabled is set', async () => {
357
- zeusPrimeSubmodule.init({
358
- params: {
359
- gamId: '1234',
360
- disabled: true,
361
- hostname: 'www.example.com',
362
- pathname: '/article/some-article',
363
- },
364
- });
365
-
366
- // Wait for request to be sent
367
- await waitForStatus('scriptComplete');
368
-
369
- // execute any googletag commands added to the queue during execution
370
- executeGoogletagTargeting();
371
-
372
- expect(server.requestCount).to.be.equal(0);
373
- expect(window.googletag.cmd).to.have.length(1);
374
- sinon.assert.calledWith(setTargetingStub, 'zeus_prime', 'false');
375
- });
376
-
377
- it('debug true enables debug logging', async () => {
378
- zeusPrimeSubmodule.init({
379
- params: {
380
- gamId: '1234',
381
- debug: true,
382
- hostname: 'www.example.com',
383
- pathname: '/article/some-article',
384
- },
385
- });
386
-
387
- // Wait for request to be sent
388
- await waitForStatus('scriptComplete');
389
-
390
- sinon.assert.called(logMessageSpy);
391
- sinon.assert.notCalled(logErrorSpy);
392
- });
393
-
394
- it('debug false disables debug logging', async () => {
395
- window.zeusPrime.disabled = false;
396
- zeusPrimeSubmodule.init({
397
- params: {
398
- gamId: '1234',
399
- hostname: 'www.example.com',
400
- pathname: '/article/some-article',
401
- },
402
- });
403
-
404
- // Wait for request to be sent
405
- await waitForStatus('scriptComplete');
406
-
407
- sinon.assert.notCalled(logMessageSpy);
408
- sinon.assert.notCalled(logErrorSpy);
409
- });
410
- });