prebid.js 6.4.0 → 6.5.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 (32) hide show
  1. package/modules/adyoulikeBidAdapter.js +13 -9
  2. package/modules/bliinkBidAdapter.js +1 -1
  3. package/modules/consentManagement.js +7 -1
  4. package/modules/docereeBidAdapter.js +10 -1
  5. package/modules/docereeBidAdapter.md +2 -0
  6. package/modules/gptPreAuction.js +55 -7
  7. package/modules/ixBidAdapter.js +29 -12
  8. package/modules/limelightDigitalBidAdapter.js +2 -1
  9. package/modules/livewrappedAnalyticsAdapter.js +3 -1
  10. package/modules/loglyliftBidAdapter.js +79 -0
  11. package/modules/loglyliftBidAdapter.md +55 -0
  12. package/modules/optimeraRtdProvider.js +8 -1
  13. package/modules/ozoneBidAdapter.js +21 -64
  14. package/modules/yieldmoBidAdapter.js +23 -5
  15. package/modules/zeta_global_sspAnalyticsAdapter.js +97 -0
  16. package/modules/zeta_global_sspAnalyticsAdapter.md +24 -0
  17. package/package.json +1 -1
  18. package/src/config.js +27 -3
  19. package/src/prebid.js +2 -0
  20. package/src/utils.js +12 -1
  21. package/test/spec/config_spec.js +279 -0
  22. package/test/spec/modules/adyoulikeBidAdapter_spec.js +49 -0
  23. package/test/spec/modules/consentManagement_spec.js +20 -0
  24. package/test/spec/modules/docereeBidAdapter_spec.js +9 -1
  25. package/test/spec/modules/gptPreAuction_spec.js +177 -2
  26. package/test/spec/modules/ixBidAdapter_spec.js +104 -62
  27. package/test/spec/modules/limelightDigitalBidAdapter_spec.js +75 -17
  28. package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +22 -0
  29. package/test/spec/modules/loglyliftBidAdapter_spec.js +172 -0
  30. package/test/spec/modules/optimeraRtdProvider_spec.js +14 -1
  31. package/test/spec/modules/ozoneBidAdapter_spec.js +43 -31
  32. package/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js +427 -0
@@ -69,8 +69,6 @@ var validBidRequestsMulti = [
69
69
  transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87'
70
70
  }
71
71
  ];
72
- // use 'pubcid', 'tdid', 'id5id', 'parrableId', 'idl_env', 'criteoId'
73
- // see http://prebid.org/dev-docs/modules/userId.html
74
72
  var validBidRequestsWithUserIdData = [
75
73
  {
76
74
  adUnitCode: 'div-gpt-ad-1460505748561-0',
@@ -291,7 +289,6 @@ var validBidRequests1OutstreamVideo2020 = [
291
289
  }
292
290
  ];
293
291
 
294
- // WHEN sent as bidderRequest to buildRequests you should send the child: .bidderRequest
295
292
  var validBidderRequest1OutstreamVideo2020 = {
296
293
  bidderRequest: {
297
294
  auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99',
@@ -394,7 +391,6 @@ var validBidderRequest1OutstreamVideo2020 = {
394
391
  timeout: 3000
395
392
  }
396
393
  };
397
- // WHEN sent as bidderRequest to buildRequests you should send the child: .bidderRequest
398
394
  var validBidderRequest = {
399
395
  bidderRequest: {
400
396
  auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99',
@@ -419,11 +415,6 @@ var validBidderRequest = {
419
415
  }
420
416
  };
421
417
 
422
- // bidder request with GDPR - change the values for testing:
423
- // gdprConsent.gdprApplies (true/false)
424
- // gdprConsent.vendorData.purposeConsents (make empty, make null, remove it)
425
- // gdprConsent.vendorData.vendorConsents (remove 524, remove all, make the element null, remove it)
426
- // WHEN sent as bidderRequest to buildRequests you should send the child: .bidderRequest
427
418
  var bidderRequestWithFullGdpr = {
428
419
  bidderRequest: {
429
420
  auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99',
@@ -512,7 +503,6 @@ var gdpr1 = {
512
503
  'gdprApplies': true
513
504
  };
514
505
 
515
- // simulating the Mirror
516
506
  var bidderRequestWithPartialGdpr = {
517
507
  bidderRequest: {
518
508
  auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99',
@@ -558,7 +548,6 @@ var bidderRequestWithPartialGdpr = {
558
548
  }
559
549
  };
560
550
 
561
- // make sure the impid matches the request bidId
562
551
  var validResponse = {
563
552
  'body': {
564
553
  'id': 'd6198807-7a53-4141-b2db-d2cb754d68ba',
@@ -1113,7 +1102,6 @@ var multiRequest1 = [
1113
1102
  }
1114
1103
  ];
1115
1104
 
1116
- // WHEN sent as bidderRequest to buildRequests you should send the child: .bidderRequest
1117
1105
  var multiBidderRequest1 = {
1118
1106
  bidderRequest: {
1119
1107
  'bidderCode': 'ozone',
@@ -1507,7 +1495,6 @@ var multiResponse1 = {
1507
1495
 
1508
1496
  describe('ozone Adapter', function () {
1509
1497
  describe('isBidRequestValid', function () {
1510
- // A test ad unit that will consistently return test creatives
1511
1498
  let validBidReq = {
1512
1499
  bidder: BIDDER_CODE,
1513
1500
  params: {
@@ -1941,7 +1928,6 @@ describe('ozone Adapter', function () {
1941
1928
  const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest.bidderRequest);
1942
1929
  expect(request).to.be.a('array');
1943
1930
  expect(request[0]).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']);
1944
- // need to reset the singleRequest config flag:
1945
1931
  config.setConfig({'ozone': {'singleRequest': true}});
1946
1932
  });
1947
1933
 
@@ -1965,7 +1951,6 @@ describe('ozone Adapter', function () {
1965
1951
  expect(payload.user.ext.consent).to.equal(consentString);
1966
1952
  });
1967
1953
 
1968
- // mirror
1969
1954
  it('should add gdpr consent information to the request when vendorData is missing vendorConsents (Mirror)', function () {
1970
1955
  let consentString = 'BOcocyaOcocyaAfEYDENCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NphLgA==';
1971
1956
  let bidderRequest = validBidderRequest.bidderRequest;
@@ -2018,7 +2003,6 @@ describe('ozone Adapter', function () {
2018
2003
  };
2019
2004
 
2020
2005
  let bidRequests = validBidRequests;
2021
- // values from http://prebid.org/dev-docs/modules/userId.html#pubcommon-id
2022
2006
  bidRequests[0]['userId'] = {
2023
2007
  'digitrustid': {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}},
2024
2008
  'id5id': { uid: '1111', ext: { linkType: 2, abTestingControlGroup: false } },
@@ -2038,13 +2022,11 @@ describe('ozone Adapter', function () {
2038
2022
 
2039
2023
  it('should pick up the value of pubcid when built using the pubCommonId module (not userId)', function () {
2040
2024
  let bidRequests = validBidRequests;
2041
- // values from http://prebid.org/dev-docs/modules/userId.html#pubcommon-id
2042
2025
  bidRequests[0]['userId'] = {
2043
2026
  'digitrustid': {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}},
2044
2027
  'id5id': { uid: '1111', ext: { linkType: 2, abTestingControlGroup: false } },
2045
2028
  'idl_env': '3333',
2046
2029
  'parrableid': 'eidVersion.encryptionKeyReference.encryptedValue',
2047
- // 'pubcid': '5555', // remove pubcid from here to emulate the OLD module & cause the failover code to kick in
2048
2030
  'tdid': '6666',
2049
2031
  'sharedid': {'id': '01EAJWWNEPN3CYMM5N8M5VXY22', 'third': '01EAJWWNEPN3CYMM5N8M5VXY22'}
2050
2032
  };
@@ -2170,7 +2152,6 @@ describe('ozone Adapter', function () {
2170
2152
  });
2171
2153
  it('should use oztestmode GET value if set', function() {
2172
2154
  var specMock = utils.deepClone(spec);
2173
- // mock the getGetParametersAsObject function to simulate GET parameters for oztestmode:
2174
2155
  specMock.getGetParametersAsObject = function() {
2175
2156
  return {'oztestmode': 'mytestvalue_123'};
2176
2157
  };
@@ -2181,7 +2162,6 @@ describe('ozone Adapter', function () {
2181
2162
  });
2182
2163
  it('should pass through GET params if present: ozf, ozpf, ozrp, ozip', function() {
2183
2164
  var specMock = utils.deepClone(spec);
2184
- // mock the getGetParametersAsObject function to simulate GET parameters :
2185
2165
  specMock.getGetParametersAsObject = function() {
2186
2166
  return {ozf: '1', ozpf: '0', ozrp: '2', ozip: '123'};
2187
2167
  };
@@ -2194,7 +2174,6 @@ describe('ozone Adapter', function () {
2194
2174
  });
2195
2175
  it('should pass through GET params if present: ozf, ozpf, ozrp, ozip with alternative values', function() {
2196
2176
  var specMock = utils.deepClone(spec);
2197
- // mock the getGetParametersAsObject function to simulate GET parameters :
2198
2177
  specMock.getGetParametersAsObject = function() {
2199
2178
  return {ozf: 'false', ozpf: 'true', ozrp: 'xyz', ozip: 'hello'};
2200
2179
  };
@@ -2207,7 +2186,6 @@ describe('ozone Adapter', function () {
2207
2186
  });
2208
2187
  it('should use oztestmode GET value if set, even if there is no customdata in config', function() {
2209
2188
  var specMock = utils.deepClone(spec);
2210
- // mock the getGetParametersAsObject function to simulate GET parameters for oztestmode:
2211
2189
  specMock.getGetParametersAsObject = function() {
2212
2190
  return {'oztestmode': 'mytestvalue_123'};
2213
2191
  };
@@ -2217,7 +2195,6 @@ describe('ozone Adapter', function () {
2217
2195
  expect(data.imp[0].ext.ozone.customData[0].targeting.oztestmode).to.equal('mytestvalue_123');
2218
2196
  });
2219
2197
  it('should use GET values auction=dev & cookiesync=dev if set', function() {
2220
- // mock the getGetParametersAsObject function to simulate GET parameters for oztestmode:
2221
2198
  var specMock = utils.deepClone(spec);
2222
2199
  specMock.getGetParametersAsObject = function() {
2223
2200
  return {};
@@ -2228,8 +2205,6 @@ describe('ozone Adapter', function () {
2228
2205
  let cookieUrl = specMock.getCookieSyncUrl();
2229
2206
  expect(cookieUrl).to.equal('https://elb.the-ozone-project.com/static/load-cookie.html');
2230
2207
 
2231
- // now mock the response from getGetParametersAsObject & do the request again
2232
-
2233
2208
  specMock = utils.deepClone(spec);
2234
2209
  specMock.getGetParametersAsObject = function() {
2235
2210
  return {'auction': 'dev', 'cookiesync': 'dev'};
@@ -2241,7 +2216,6 @@ describe('ozone Adapter', function () {
2241
2216
  expect(cookieUrl).to.equal('https://test.ozpr.net/static/load-cookie.html');
2242
2217
  });
2243
2218
  it('should use a valid ozstoredrequest GET value if set to override the placementId values, and set oz_rw if we find it', function() {
2244
- // mock the getGetParametersAsObject function to simulate GET parameters for ozstoredrequest:
2245
2219
  var specMock = utils.deepClone(spec);
2246
2220
  specMock.getGetParametersAsObject = function() {
2247
2221
  return {'ozstoredrequest': '1122334455'}; // 10 digits are valid
@@ -2252,7 +2226,6 @@ describe('ozone Adapter', function () {
2252
2226
  expect(data.imp[0].ext.prebid.storedrequest.id).to.equal('1122334455');
2253
2227
  });
2254
2228
  it('should NOT use an invalid ozstoredrequest GET value if set to override the placementId values, and set oz_rw to 0', function() {
2255
- // mock the getGetParametersAsObject function to simulate GET parameters for ozstoredrequest:
2256
2229
  var specMock = utils.deepClone(spec);
2257
2230
  specMock.getGetParametersAsObject = function() {
2258
2231
  return {'ozstoredrequest': 'BADVAL'}; // 10 digits are valid
@@ -2424,6 +2397,26 @@ describe('ozone Adapter', function () {
2424
2397
  expect(utils.deepAccess(payload, 'imp.0.floor.banner.floor')).to.equal(0.8);
2425
2398
  config.resetConfig();
2426
2399
  });
2400
+
2401
+ it('handles schain object in each bidrequest (will be the same in each br)', function () {
2402
+ let br = JSON.parse(JSON.stringify(validBidRequests));
2403
+ let schainConfigObject = {
2404
+ 'ver': '1.0',
2405
+ 'complete': 1,
2406
+ 'nodes': [
2407
+ {
2408
+ 'asi': 'bidderA.com',
2409
+ 'sid': '00001',
2410
+ 'hp': 1
2411
+ }
2412
+ ]
2413
+ };
2414
+ br[0]['schain'] = schainConfigObject;
2415
+ const request = spec.buildRequests(br, validBidderRequest.bidderRequest);
2416
+ const data = JSON.parse(request.data);
2417
+ expect(data.source.ext).to.haveOwnProperty('schain');
2418
+ expect(data.source.ext.schain).to.deep.equal(schainConfigObject); // .deep.equal() : Target object deeply (but not strictly) equals `{a: 1}`
2419
+ });
2427
2420
  });
2428
2421
 
2429
2422
  describe('interpretResponse', function () {
@@ -2624,7 +2617,6 @@ describe('ozone Adapter', function () {
2624
2617
  expect(result[1]['impid']).to.equal('3025f169863b7f8');
2625
2618
  expect(result[1]['id']).to.equal('18552976939844999');
2626
2619
  expect(result[1]['adserverTargeting']['oz_ozappnexus_adId']).to.equal('3025f169863b7f8-0-oz-2');
2627
- // change the bid values so a different second bid for an impid by the same bidder gets dropped
2628
2620
  validres = JSON.parse(JSON.stringify(multiResponse1));
2629
2621
  validres.body.seatbid[0].bid[1].price = 1.1;
2630
2622
  validres.body.seatbid[0].bid[1].cpm = 1.1;
@@ -2647,7 +2639,6 @@ describe('ozone Adapter', function () {
2647
2639
  expect(result).to.be.empty;
2648
2640
  });
2649
2641
  it('should append the various values if they exist', function() {
2650
- // get the cookie bag populated
2651
2642
  spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest);
2652
2643
  const result = spec.getUserSyncs({iframeEnabled: true}, 'good server response', gdpr1);
2653
2644
  expect(result).to.be.an('array');
@@ -2657,14 +2648,12 @@ describe('ozone Adapter', function () {
2657
2648
  expect(result[0].url).to.include('gdpr_consent=BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA');
2658
2649
  });
2659
2650
  it('should append ccpa (usp data)', function() {
2660
- // get the cookie bag populated
2661
2651
  spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest);
2662
2652
  const result = spec.getUserSyncs({iframeEnabled: true}, 'good server response', gdpr1, '1YYN');
2663
2653
  expect(result).to.be.an('array');
2664
2654
  expect(result[0].url).to.include('usp_consent=1YYN');
2665
2655
  });
2666
2656
  it('should use "" if no usp is sent to cookieSync', function() {
2667
- // get the cookie bag populated
2668
2657
  spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest);
2669
2658
  const result = spec.getUserSyncs({iframeEnabled: true}, 'good server response', gdpr1);
2670
2659
  expect(result).to.be.an('array');
@@ -2887,4 +2876,27 @@ describe('ozone Adapter', function () {
2887
2876
  expect(response[1].bid.length).to.equal(2);
2888
2877
  });
2889
2878
  });
2879
+ /**
2880
+ * spec.getWhitelabelConfigItem test - get a config value for a whitelabelled bidder,
2881
+ * from a standard ozone.oz_xxxx_yyy string
2882
+ */
2883
+ describe('getWhitelabelConfigItem', function() {
2884
+ it('should fetch the whitelabelled equivalent config value correctly', function () {
2885
+ var specMock = utils.deepClone(spec);
2886
+ config.setConfig({'ozone': {'oz_omp_floor': 'ozone-floor-value'}});
2887
+ config.setConfig({'markbidder': {'mb_omp_floor': 'markbidder-floor-value'}});
2888
+ specMock.propertyBag.whitelabel = {bidder: 'ozone', keyPrefix: 'oz'};
2889
+ let testKey = 'ozone.oz_omp_floor';
2890
+ let ozone_value = specMock.getWhitelabelConfigItem(testKey);
2891
+ expect(ozone_value).to.equal('ozone-floor-value');
2892
+ specMock.propertyBag.whitelabel = {bidder: 'markbidder', keyPrefix: 'mb'};
2893
+ let markbidder_config = specMock.getWhitelabelConfigItem(testKey);
2894
+ expect(markbidder_config).to.equal('markbidder-floor-value');
2895
+ config.setConfig({'markbidder': {'singleRequest': 'markbidder-singlerequest-value'}});
2896
+ let testKey2 = 'ozone.singleRequest';
2897
+ let markbidder_config2 = specMock.getWhitelabelConfigItem(testKey2);
2898
+ expect(markbidder_config2).to.equal('markbidder-singlerequest-value');
2899
+ config.resetConfig();
2900
+ });
2901
+ });
2890
2902
  });
@@ -0,0 +1,427 @@
1
+ import zetaAnalyticsAdapter from 'modules/zeta_global_sspAnalyticsAdapter.js';
2
+ import {config} from 'src/config';
3
+ import CONSTANTS from 'src/constants.json';
4
+ import {logError} from '../../../src/utils';
5
+
6
+ let utils = require('src/utils');
7
+ let events = require('src/events');
8
+
9
+ const MOCK = {
10
+ STUB: {
11
+ 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa'
12
+ },
13
+ AUCTION_END: {
14
+ 'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
15
+ 'timestamp': 1638441234544,
16
+ 'auctionEnd': 1638441234784,
17
+ 'auctionStatus': 'completed',
18
+ 'adUnits': [
19
+ {
20
+ 'code': '/19968336/header-bid-tag-0',
21
+ 'mediaTypes': {
22
+ 'banner': {
23
+ 'sizes': [
24
+ [
25
+ 300,
26
+ 250
27
+ ],
28
+ [
29
+ 300,
30
+ 600
31
+ ]
32
+ ]
33
+ }
34
+ },
35
+ 'bids': [
36
+ {
37
+ 'bidder': 'zeta_global_ssp',
38
+ 'params': {
39
+ 'sid': 111,
40
+ 'tags': {
41
+ 'shortname': 'prebid_analytics_event_test_shortname',
42
+ 'position': 'test_position'
43
+ }
44
+ }
45
+ },
46
+ {
47
+ 'bidder': 'appnexus',
48
+ 'params': {
49
+ 'placementId': 13232385
50
+ }
51
+ }
52
+ ],
53
+ 'sizes': [
54
+ [
55
+ 300,
56
+ 250
57
+ ],
58
+ [
59
+ 300,
60
+ 600
61
+ ]
62
+ ],
63
+ 'transactionId': '6b29369c-0c2e-414e-be1f-5867aec18d83'
64
+ }
65
+ ],
66
+ 'adUnitCodes': [
67
+ '/19968336/header-bid-tag-0'
68
+ ],
69
+ 'bidderRequests': [
70
+ {
71
+ 'bidderCode': 'zeta_global_ssp',
72
+ 'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
73
+ 'bidderRequestId': '1207cb49191887',
74
+ 'bids': [
75
+ {
76
+ 'bidder': 'zeta_global_ssp',
77
+ 'params': {
78
+ 'sid': 111,
79
+ 'tags': {
80
+ 'shortname': 'prebid_analytics_event_test_shortname',
81
+ 'position': 'test_position'
82
+ }
83
+ },
84
+ 'mediaTypes': {
85
+ 'banner': {
86
+ 'sizes': [
87
+ [
88
+ 300,
89
+ 250
90
+ ],
91
+ [
92
+ 300,
93
+ 600
94
+ ]
95
+ ]
96
+ }
97
+ },
98
+ 'adUnitCode': '/19968336/header-bid-tag-0',
99
+ 'transactionId': '6b29369c-0c2e-414e-be1f-5867aec18d83',
100
+ 'sizes': [
101
+ [
102
+ 300,
103
+ 250
104
+ ],
105
+ [
106
+ 300,
107
+ 600
108
+ ]
109
+ ],
110
+ 'bidId': '206be9a13236af',
111
+ 'bidderRequestId': '1207cb49191887',
112
+ 'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
113
+ 'src': 'client',
114
+ 'bidRequestsCount': 1,
115
+ 'bidderRequestsCount': 1,
116
+ 'bidderWinsCount': 0
117
+ }
118
+ ],
119
+ 'auctionStart': 1638441234544,
120
+ 'timeout': 400,
121
+ 'refererInfo': {
122
+ 'referer': 'http://test-zeta-ssp.net:63342/zeta-ssp/ssp/_dev/examples/page_banner.html',
123
+ 'reachedTop': true,
124
+ 'isAmp': false,
125
+ 'numIframes': 0,
126
+ 'stack': [
127
+ 'http://test-zeta-ssp.net:63342/zeta-ssp/ssp/_dev/examples/page_banner.html'
128
+ ],
129
+ 'canonicalUrl': null
130
+ },
131
+ 'start': 1638441234547
132
+ },
133
+ {
134
+ 'bidderCode': 'appnexus',
135
+ 'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
136
+ 'bidderRequestId': '32b97f0a935422',
137
+ 'bids': [
138
+ {
139
+ 'bidder': 'appnexus',
140
+ 'params': {
141
+ 'placementId': 13232385
142
+ },
143
+ 'mediaTypes': {
144
+ 'banner': {
145
+ 'sizes': [
146
+ [
147
+ 300,
148
+ 250
149
+ ],
150
+ [
151
+ 300,
152
+ 600
153
+ ]
154
+ ]
155
+ }
156
+ },
157
+ 'adUnitCode': '/19968336/header-bid-tag-0',
158
+ 'transactionId': '6b29369c-0c2e-414e-be1f-5867aec18d83',
159
+ 'sizes': [
160
+ [
161
+ 300,
162
+ 250
163
+ ],
164
+ [
165
+ 300,
166
+ 600
167
+ ]
168
+ ],
169
+ 'bidId': '41badc0e164c758',
170
+ 'bidderRequestId': '32b97f0a935422',
171
+ 'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
172
+ 'src': 'client',
173
+ 'bidRequestsCount': 1,
174
+ 'bidderRequestsCount': 1,
175
+ 'bidderWinsCount': 0
176
+ }
177
+ ],
178
+ 'auctionStart': 1638441234544,
179
+ 'timeout': 400,
180
+ 'refererInfo': {
181
+ 'referer': 'http://test-zeta-ssp.net:63342/zeta-ssp/ssp/_dev/examples/page_banner.html',
182
+ 'reachedTop': true,
183
+ 'isAmp': false,
184
+ 'numIframes': 0,
185
+ 'stack': [
186
+ 'http://test-zeta-ssp.net:63342/zeta-ssp/ssp/_dev/examples/page_banner.html'
187
+ ],
188
+ 'canonicalUrl': null
189
+ },
190
+ 'start': 1638441234550
191
+ }
192
+ ],
193
+ 'noBids': [
194
+ {
195
+ 'bidder': 'appnexus',
196
+ 'params': {
197
+ 'placementId': 13232385
198
+ },
199
+ 'mediaTypes': {
200
+ 'banner': {
201
+ 'sizes': [
202
+ [
203
+ 300,
204
+ 250
205
+ ],
206
+ [
207
+ 300,
208
+ 600
209
+ ]
210
+ ]
211
+ }
212
+ },
213
+ 'adUnitCode': '/19968336/header-bid-tag-0',
214
+ 'transactionId': '6b29369c-0c2e-414e-be1f-5867aec18d83',
215
+ 'sizes': [
216
+ [
217
+ 300,
218
+ 250
219
+ ],
220
+ [
221
+ 300,
222
+ 600
223
+ ]
224
+ ],
225
+ 'bidId': '41badc0e164c758',
226
+ 'bidderRequestId': '32b97f0a935422',
227
+ 'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
228
+ 'src': 'client',
229
+ 'bidRequestsCount': 1,
230
+ 'bidderRequestsCount': 1,
231
+ 'bidderWinsCount': 0
232
+ }
233
+ ],
234
+ 'bidsReceived': [
235
+ {
236
+ 'bidderCode': 'zeta_global_ssp',
237
+ 'width': 480,
238
+ 'height': 320,
239
+ 'statusMessage': 'Bid available',
240
+ 'adId': '5759bb3ef7be1e8',
241
+ 'requestId': '206be9a13236af',
242
+ 'mediaType': 'banner',
243
+ 'source': 'client',
244
+ 'cpm': 2.258302852806723,
245
+ 'currency': 'USD',
246
+ 'ad': 'test_ad',
247
+ 'ttl': 200,
248
+ 'creativeId': '456456456',
249
+ 'netRevenue': true,
250
+ 'meta': {
251
+ 'advertiserDomains': [
252
+ 'viaplay.fi'
253
+ ]
254
+ },
255
+ 'originalCpm': 2.258302852806723,
256
+ 'originalCurrency': 'USD',
257
+ 'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
258
+ 'responseTimestamp': 1638441234670,
259
+ 'requestTimestamp': 1638441234547,
260
+ 'bidder': 'zeta_global_ssp',
261
+ 'adUnitCode': '/19968336/header-bid-tag-0',
262
+ 'timeToRespond': 123,
263
+ 'pbLg': '2.00',
264
+ 'pbMg': '2.20',
265
+ 'pbHg': '2.25',
266
+ 'pbAg': '2.25',
267
+ 'pbDg': '2.25',
268
+ 'pbCg': '',
269
+ 'size': '480x320',
270
+ 'adserverTargeting': {
271
+ 'hb_bidder': 'zeta_global_ssp',
272
+ 'hb_adid': '5759bb3ef7be1e8',
273
+ 'hb_pb': '2.20',
274
+ 'hb_size': '480x320',
275
+ 'hb_source': 'client',
276
+ 'hb_format': 'banner',
277
+ 'hb_adomain': 'viaplay.fi'
278
+ }
279
+ }
280
+ ],
281
+ 'winningBids': [],
282
+ 'timeout': 400
283
+ },
284
+ AD_RENDER_SUCCEEDED: {
285
+ 'doc': {
286
+ 'location': {
287
+ 'href': 'http://test-zeta-ssp.net:63342/zeta-ssp/ssp/_dev/examples/page_banner.html',
288
+ 'protocol': 'http:',
289
+ 'host': 'localhost:63342',
290
+ 'hostname': 'localhost',
291
+ 'port': '63342',
292
+ 'pathname': '/zeta-ssp/ssp/_dev/examples/page_banner.html',
293
+ 'hash': '',
294
+ 'origin': 'http://test-zeta-ssp.net:63342',
295
+ 'ancestorOrigins': {
296
+ '0': 'http://test-zeta-ssp.net:63342'
297
+ }
298
+ }
299
+ },
300
+ 'bid': {
301
+ 'bidderCode': 'zeta_global_ssp',
302
+ 'width': 480,
303
+ 'height': 320,
304
+ 'statusMessage': 'Bid available',
305
+ 'adId': '5759bb3ef7be1e8',
306
+ 'requestId': '206be9a13236af',
307
+ 'mediaType': 'banner',
308
+ 'source': 'client',
309
+ 'cpm': 2.258302852806723,
310
+ 'currency': 'USD',
311
+ 'ad': 'test_ad',
312
+ 'ttl': 200,
313
+ 'creativeId': '456456456',
314
+ 'netRevenue': true,
315
+ 'meta': {
316
+ 'advertiserDomains': [
317
+ 'viaplay.fi'
318
+ ]
319
+ },
320
+ 'originalCpm': 2.258302852806723,
321
+ 'originalCurrency': 'USD',
322
+ 'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1',
323
+ 'responseTimestamp': 1638441234670,
324
+ 'requestTimestamp': 1638441234547,
325
+ 'bidder': 'zeta_global_ssp',
326
+ 'adUnitCode': '/19968336/header-bid-tag-0',
327
+ 'timeToRespond': 123,
328
+ 'pbLg': '2.00',
329
+ 'pbMg': '2.20',
330
+ 'pbHg': '2.25',
331
+ 'pbAg': '2.25',
332
+ 'pbDg': '2.25',
333
+ 'pbCg': '',
334
+ 'size': '480x320',
335
+ 'adserverTargeting': {
336
+ 'hb_bidder': 'zeta_global_ssp',
337
+ 'hb_adid': '5759bb3ef7be1e8',
338
+ 'hb_pb': '2.20',
339
+ 'hb_size': '480x320',
340
+ 'hb_source': 'client',
341
+ 'hb_format': 'banner',
342
+ 'hb_adomain': 'viaplay.fi'
343
+ },
344
+ 'status': 'rendered',
345
+ 'params': [
346
+ {
347
+ 'sid': 111,
348
+ 'tags': {
349
+ 'shortname': 'prebid_analytics_event_test_shortname',
350
+ 'position': 'test_position'
351
+ }
352
+ }
353
+ ]
354
+ },
355
+ 'adId': '5759bb3ef7be1e8'
356
+ }
357
+ }
358
+
359
+ describe('Zeta Global SSP Analytics Adapter', function() {
360
+ let sandbox;
361
+ let xhr;
362
+ let requests;
363
+
364
+ beforeEach(function() {
365
+ sandbox = sinon.sandbox.create();
366
+ requests = [];
367
+ xhr = sandbox.useFakeXMLHttpRequest();
368
+ xhr.onCreate = request => requests.push(request);
369
+ sandbox.stub(events, 'getEvents').returns([]);
370
+ });
371
+
372
+ afterEach(function () {
373
+ sandbox.restore();
374
+ config.resetConfig();
375
+ });
376
+
377
+ it('should require publisherId', function () {
378
+ sandbox.stub(utils, 'logError');
379
+ zetaAnalyticsAdapter.enableAnalytics({
380
+ options: {}
381
+ });
382
+ expect(utils.logError.called).to.equal(true);
383
+ });
384
+
385
+ describe('handle events', function() {
386
+ beforeEach(function() {
387
+ zetaAnalyticsAdapter.enableAnalytics({
388
+ options: {
389
+ sid: 111
390
+ }
391
+ });
392
+ });
393
+
394
+ afterEach(function () {
395
+ zetaAnalyticsAdapter.disableAnalytics();
396
+ });
397
+
398
+ it('events are sent', function() {
399
+ this.timeout(5000);
400
+ events.emit(CONSTANTS.EVENTS.AUCTION_INIT, MOCK.STUB);
401
+ events.emit(CONSTANTS.EVENTS.AUCTION_END, MOCK.AUCTION_END);
402
+ events.emit(CONSTANTS.EVENTS.BID_ADJUSTMENT, MOCK.STUB);
403
+ events.emit(CONSTANTS.EVENTS.BID_TIMEOUT, MOCK.STUB);
404
+ events.emit(CONSTANTS.EVENTS.BID_REQUESTED, MOCK.STUB);
405
+ events.emit(CONSTANTS.EVENTS.BID_RESPONSE, MOCK.STUB);
406
+ events.emit(CONSTANTS.EVENTS.NO_BID, MOCK.STUB);
407
+ events.emit(CONSTANTS.EVENTS.BID_WON, MOCK.STUB);
408
+ events.emit(CONSTANTS.EVENTS.BIDDER_DONE, MOCK.STUB);
409
+ events.emit(CONSTANTS.EVENTS.BIDDER_ERROR, MOCK.STUB);
410
+ events.emit(CONSTANTS.EVENTS.SET_TARGETING, MOCK.STUB);
411
+ events.emit(CONSTANTS.EVENTS.BEFORE_REQUEST_BIDS, MOCK.STUB);
412
+ events.emit(CONSTANTS.EVENTS.BEFORE_BIDDER_HTTP, MOCK.STUB);
413
+ events.emit(CONSTANTS.EVENTS.REQUEST_BIDS, MOCK.STUB);
414
+ events.emit(CONSTANTS.EVENTS.ADD_AD_UNITS, MOCK.STUB);
415
+ events.emit(CONSTANTS.EVENTS.AD_RENDER_FAILED, MOCK.STUB);
416
+ events.emit(CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED, MOCK.AD_RENDER_SUCCEEDED);
417
+ events.emit(CONSTANTS.EVENTS.TCF2_ENFORCEMENT, MOCK.STUB);
418
+ events.emit(CONSTANTS.EVENTS.AUCTION_DEBUG, MOCK.STUB);
419
+ events.emit(CONSTANTS.EVENTS.BID_VIEWABLE, MOCK.STUB);
420
+ events.emit(CONSTANTS.EVENTS.STALE_RENDER, MOCK.STUB);
421
+
422
+ expect(requests.length).to.equal(2);
423
+ expect(JSON.parse(requests[0].requestBody)).to.deep.equal(MOCK.AUCTION_END);
424
+ expect(JSON.parse(requests[1].requestBody)).to.deep.equal(MOCK.AD_RENDER_SUCCEEDED);
425
+ });
426
+ });
427
+ });