prebid.js 7.14.0 → 7.16.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 (239) hide show
  1. package/.circleci/config.yml +3 -0
  2. package/dist/1plusXRtdProvider.js +1 -1
  3. package/dist/33acrossBidAdapter.js +1 -1
  4. package/dist/adagioBidAdapter.js +1 -1
  5. package/dist/adbookpspBidAdapter.js +1 -1
  6. package/dist/adfBidAdapter.js +1 -1
  7. package/dist/adgenerationBidAdapter.js +1 -1
  8. package/dist/adkernelAdnBidAdapter.js +1 -1
  9. package/dist/adkernelBidAdapter.js +1 -1
  10. package/dist/adlooxAdServerVideo.js +1 -1
  11. package/dist/adlooxRtdProvider.js +1 -1
  12. package/dist/adrelevantisBidAdapter.js +1 -1
  13. package/dist/adtrgtmeBidAdapter.js +1 -1
  14. package/dist/adtrueBidAdapter.js +1 -1
  15. package/dist/adxcgBidAdapter.js +1 -1
  16. package/dist/airgridRtdProvider.js +1 -1
  17. package/dist/ajaBidAdapter.js +1 -1
  18. package/dist/amxBidAdapter.js +1 -1
  19. package/dist/amxIdSystem.js +1 -1
  20. package/dist/aolBidAdapter.js +1 -1
  21. package/dist/appierAnalyticsAdapter.js +1 -1
  22. package/dist/appnexusBidAdapter.js +1 -1
  23. package/dist/asoBidAdapter.js +1 -1
  24. package/dist/axonixBidAdapter.js +1 -1
  25. package/dist/beachfrontBidAdapter.js +1 -1
  26. package/dist/bidglassBidAdapter.js +1 -1
  27. package/dist/big-richmediaBidAdapter.js +1 -1
  28. package/dist/bizzclickBidAdapter.js +1 -1
  29. package/dist/bliinkBidAdapter.js +1 -1
  30. package/dist/bluebillywigBidAdapter.js +1 -1
  31. package/dist/brandmetricsRtdProvider.js +1 -1
  32. package/dist/bridgewellBidAdapter.js +1 -1
  33. package/dist/brightMountainMediaBidAdapter.js +1 -1
  34. package/dist/brightcomBidAdapter.js +1 -1
  35. package/dist/browsiRtdProvider.js +1 -1
  36. package/dist/categoryTranslation.js +1 -1
  37. package/dist/concertBidAdapter.js +1 -1
  38. package/dist/connectadBidAdapter.js +1 -1
  39. package/dist/consentManagement.js +1 -1
  40. package/dist/consentManagementUsp.js +1 -1
  41. package/dist/consumableBidAdapter.js +1 -1
  42. package/dist/conversantBidAdapter.js +1 -1
  43. package/dist/cpmstarBidAdapter.js +1 -1
  44. package/dist/craftBidAdapter.js +1 -1
  45. package/dist/criteoBidAdapter.js +1 -1
  46. package/dist/currency.js +1 -1
  47. package/dist/dataControllerModule.js +1 -1
  48. package/dist/dchain.js +1 -1
  49. package/dist/deepintentBidAdapter.js +1 -1
  50. package/dist/dependencies.json +3 -0
  51. package/dist/dgkeywordRtdProvider.js +1 -1
  52. package/dist/dianomiBidAdapter.js +1 -1
  53. package/dist/distroscaleBidAdapter.js +1 -1
  54. package/dist/dspxBidAdapter.js +1 -1
  55. package/dist/eplanningBidAdapter.js +1 -1
  56. package/dist/etargetBidAdapter.js +1 -1
  57. package/dist/feedadBidAdapter.js +1 -1
  58. package/dist/finativeBidAdapter.js +1 -1
  59. package/dist/fpdModule.js +1 -1
  60. package/dist/gamoshiBidAdapter.js +1 -1
  61. package/dist/glimpseBidAdapter.js +1 -1
  62. package/dist/gmosspBidAdapter.js +1 -1
  63. package/dist/goldbachBidAdapter.js +1 -1
  64. package/dist/gothamadsBidAdapter.js +1 -1
  65. package/dist/gridBidAdapter.js +1 -1
  66. package/dist/gridNMBidAdapter.js +1 -1
  67. package/dist/gumgumBidAdapter.js +1 -1
  68. package/dist/h12mediaBidAdapter.js +1 -1
  69. package/dist/iasRtdProvider.js +1 -1
  70. package/dist/id5IdSystem.js +1 -1
  71. package/dist/imRtdProvider.js +1 -1
  72. package/dist/impactifyBidAdapter.js +1 -1
  73. package/dist/improvedigitalBidAdapter.js +1 -1
  74. package/dist/inmarBidAdapter.js +1 -1
  75. package/dist/insticatorBidAdapter.js +1 -1
  76. package/dist/ixBidAdapter.js +1 -1
  77. package/dist/justpremiumBidAdapter.js +1 -1
  78. package/dist/konduitAnalyticsAdapter.js +1 -1
  79. package/dist/kueezBidAdapter.js +1 -1
  80. package/dist/lassoBidAdapter.js +1 -1
  81. package/dist/lifestreetBidAdapter.js +1 -1
  82. package/dist/liveIntentAnalyticsAdapter.js +1 -0
  83. package/dist/liveyieldAnalyticsAdapter.js +1 -1
  84. package/dist/logicadBidAdapter.js +1 -1
  85. package/dist/loglyliftBidAdapter.js +1 -1
  86. package/dist/luponmediaBidAdapter.js +1 -1
  87. package/dist/malltvAnalyticsAdapter.js +1 -1
  88. package/dist/marsmediaBidAdapter.js +1 -1
  89. package/dist/mass.js +1 -1
  90. package/dist/mediafuseBidAdapter.js +1 -1
  91. package/dist/mediakeysBidAdapter.js +1 -1
  92. package/dist/mediasniperBidAdapter.js +1 -1
  93. package/dist/mediasquareBidAdapter.js +1 -1
  94. package/dist/mgidBidAdapter.js +1 -1
  95. package/dist/minutemediaBidAdapter.js +1 -1
  96. package/dist/multibid.js +1 -1
  97. package/dist/naveggIdSystem.js +1 -1
  98. package/dist/newspassidBidAdapter.js +1 -1
  99. package/dist/nextMillenniumBidAdapter.js +1 -1
  100. package/dist/not-for-prod/prebid.js +172 -171
  101. package/dist/oguryBidAdapter.js +1 -1
  102. package/dist/oneKeyRtdProvider.js +1 -1
  103. package/dist/onetagBidAdapter.js +1 -1
  104. package/dist/ooloAnalyticsAdapter.js +1 -1
  105. package/dist/openxBidAdapter.js +1 -1
  106. package/dist/openxOrtbBidAdapter.js +1 -1
  107. package/dist/operaadsBidAdapter.js +1 -1
  108. package/dist/outbrainBidAdapter.js +1 -1
  109. package/dist/ozoneBidAdapter.js +1 -1
  110. package/dist/parrableIdSystem.js +1 -1
  111. package/dist/permutiveRtdProvider.js +1 -1
  112. package/dist/pixfutureBidAdapter.js +1 -1
  113. package/dist/prebid-core.js +2 -2
  114. package/dist/prebidServerBidAdapter.js +1 -1
  115. package/dist/priceFloors.js +1 -1
  116. package/dist/pubCommonId.js +1 -1
  117. package/dist/pubgeniusBidAdapter.js +1 -1
  118. package/dist/publinkIdSystem.js +1 -1
  119. package/dist/pubmaticBidAdapter.js +1 -1
  120. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  121. package/dist/pubwiseBidAdapter.js +1 -1
  122. package/dist/pubxBidAdapter.js +1 -1
  123. package/dist/pxyzBidAdapter.js +1 -1
  124. package/dist/quantcastBidAdapter.js +1 -1
  125. package/dist/readpeakBidAdapter.js +1 -1
  126. package/dist/relaidoBidAdapter.js +1 -1
  127. package/dist/rhythmoneBidAdapter.js +1 -1
  128. package/dist/riseBidAdapter.js +1 -1
  129. package/dist/rtdModule.js +1 -1
  130. package/dist/rubiconAnalyticsAdapter.js +1 -1
  131. package/dist/rubiconBidAdapter.js +1 -1
  132. package/dist/seedingAllianceBidAdapter.js +1 -1
  133. package/dist/seedtagBidAdapter.js +1 -1
  134. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  135. package/dist/sharethroughBidAdapter.js +1 -1
  136. package/dist/shinezBidAdapter.js +1 -1
  137. package/dist/sirdataRtdProvider.js +1 -1
  138. package/dist/smaatoBidAdapter.js +1 -1
  139. package/dist/smartadserverBidAdapter.js +1 -1
  140. package/dist/smartxBidAdapter.js +1 -1
  141. package/dist/smilewantedBidAdapter.js +1 -1
  142. package/dist/sonobiBidAdapter.js +1 -1
  143. package/dist/sovrnAnalyticsAdapter.js +1 -1
  144. package/dist/sovrnBidAdapter.js +1 -1
  145. package/dist/spotxBidAdapter.js +1 -1
  146. package/dist/sspBCBidAdapter.js +1 -1
  147. package/dist/stroeerCoreBidAdapter.js +1 -1
  148. package/dist/sublimeBidAdapter.js +1 -1
  149. package/dist/synacormediaBidAdapter.js +1 -1
  150. package/dist/targetVideoBidAdapter.js +1 -1
  151. package/dist/teadsBidAdapter.js +1 -1
  152. package/dist/trionBidAdapter.js +1 -1
  153. package/dist/tripleliftBidAdapter.js +1 -1
  154. package/dist/ttdBidAdapter.js +1 -1
  155. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  156. package/dist/ucfunnelBidAdapter.js +1 -1
  157. package/dist/underdogmediaBidAdapter.js +1 -1
  158. package/dist/undertoneBidAdapter.js +1 -1
  159. package/dist/userId.js +1 -1
  160. package/dist/vidazooBidAdapter.js +1 -1
  161. package/dist/videobyteBidAdapter.js +1 -1
  162. package/dist/viewability.js +1 -1
  163. package/dist/visxBidAdapter.js +1 -1
  164. package/dist/vuukleBidAdapter.js +1 -1
  165. package/dist/weboramaRtdProvider.js +1 -1
  166. package/dist/widespaceBidAdapter.js +1 -1
  167. package/dist/winrBidAdapter.js +1 -1
  168. package/dist/yahoosspBidAdapter.js +1 -1
  169. package/dist/yieldliftBidAdapter.js +1 -1
  170. package/dist/yieldmoBidAdapter.js +1 -1
  171. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  172. package/dist/zeta_global_sspBidAdapter.js +1 -1
  173. package/modules/amxBidAdapter.js +98 -78
  174. package/modules/appnexusBidAdapter.js +73 -12
  175. package/modules/categoryTranslation.js +9 -8
  176. package/modules/consentManagement.js +4 -2
  177. package/modules/consentManagementUsp.js +17 -14
  178. package/modules/cpmstarBidAdapter.js +2 -1
  179. package/modules/currency.js +4 -3
  180. package/modules/dataControllerModule/index.js +4 -3
  181. package/modules/dchain.js +3 -2
  182. package/modules/dianomiBidAdapter.js +17 -14
  183. package/modules/dianomiBidAdapter.md +1 -1
  184. package/modules/feedadBidAdapter.js +40 -8
  185. package/modules/fpdModule/index.js +3 -2
  186. package/modules/iasRtdProvider.js +17 -3
  187. package/modules/ixBidAdapter.js +2 -5
  188. package/modules/liveIntentAnalyticsAdapter.js +148 -0
  189. package/modules/liveIntentAnalyticsAdapter.md +22 -0
  190. package/modules/mass.js +5 -3
  191. package/modules/multibid/index.js +4 -2
  192. package/modules/naveggIdSystem.js +53 -22
  193. package/modules/nextMillenniumBidAdapter.js +168 -55
  194. package/modules/openxOrtbBidAdapter.js +1 -1
  195. package/modules/prebidServerBidAdapter/index.js +18 -4
  196. package/modules/priceFloors.js +5 -4
  197. package/modules/pubCommonId.js +3 -2
  198. package/modules/rtdModule/index.js +3 -2
  199. package/modules/sharethroughBidAdapter.js +8 -6
  200. package/modules/spotxBidAdapter.js +1 -0
  201. package/modules/stroeerCoreBidAdapter.js +129 -92
  202. package/modules/stroeerCoreBidAdapter.md +52 -14
  203. package/modules/teadsBidAdapter.js +32 -10
  204. package/modules/ucfunnelBidAdapter.js +9 -10
  205. package/modules/userId/index.js +73 -48
  206. package/modules/viewability.js +2 -170
  207. package/package.json +3 -3
  208. package/src/adapterManager.js +21 -13
  209. package/src/adapters/bidderFactory.js +28 -6
  210. package/src/auction.js +17 -4
  211. package/src/auctionManager.js +5 -0
  212. package/src/constants.json +2 -0
  213. package/src/native.js +5 -2
  214. package/src/prebid.js +52 -23
  215. package/src/secureCreatives.js +1 -1
  216. package/src/utils/perfMetrics.js +386 -0
  217. package/src/utils.js +1 -1
  218. package/test/helpers/testing-utils.js +4 -3
  219. package/test/spec/modules/adriverIdSystem_spec.js +7 -3
  220. package/test/spec/modules/amxBidAdapter_spec.js +250 -192
  221. package/test/spec/modules/appnexusBidAdapter_spec.js +61 -6
  222. package/test/spec/modules/consentManagementUsp_spec.js +6 -2
  223. package/test/spec/modules/dianomiBidAdapter_spec.js +326 -6
  224. package/test/spec/modules/feedadBidAdapter_spec.js +147 -11
  225. package/test/spec/modules/iasRtdProvider_spec.js +3 -1
  226. package/test/spec/modules/ixBidAdapter_spec.js +0 -64
  227. package/test/spec/modules/liveIntentAnalyticsAdapter_spec.js +297 -0
  228. package/test/spec/modules/nextMillenniumBidAdapter_spec.js +103 -1
  229. package/test/spec/modules/openxOrtbBidAdapter_spec.js +31 -0
  230. package/test/spec/modules/sharethroughBidAdapter_spec.js +23 -2
  231. package/test/spec/modules/spotxBidAdapter_spec.js +6 -0
  232. package/test/spec/modules/stroeerCoreBidAdapter_spec.js +315 -33
  233. package/test/spec/modules/teadsBidAdapter_spec.js +65 -11
  234. package/test/spec/modules/ucfunnelBidAdapter_spec.js +24 -10
  235. package/test/spec/native_spec.js +11 -0
  236. package/test/spec/unit/utils/perfMetrics_spec.js +394 -0
  237. package/wdio.conf.js +1 -0
  238. package/modules/viewability.md +0 -87
  239. package/test/spec/modules/viewability_spec.js +0 -280
@@ -0,0 +1,148 @@
1
+ import {ajax} from '../src/ajax.js';
2
+ import { generateUUID, logInfo, logWarn } from '../src/utils.js';
3
+ import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js';
4
+ import CONSTANTS from '../src/constants.json';
5
+ import adapterManager from '../src/adapterManager.js';
6
+ import { auctionManager } from '../src/auctionManager.js';
7
+ import { getRefererInfo } from '../src/refererDetection.js';
8
+
9
+ const ANALYTICS_TYPE = 'endpoint';
10
+ const URL = 'https://wba.liadm.com/analytic-events';
11
+ const GVL_ID = 148;
12
+ const ADAPTER_CODE = 'liveintent';
13
+ const DEFAULT_SAMPLING = 0.1;
14
+ const DEFAULT_BID_WON_TIMEOUT = 2000;
15
+ const { EVENTS: { AUCTION_END } } = CONSTANTS;
16
+ let initOptions = {};
17
+ let isSampled;
18
+ let bidWonTimeout;
19
+
20
+ function handleAuctionEnd(args) {
21
+ setTimeout(() => {
22
+ const auction = auctionManager.index.getAuction(args.auctionId);
23
+ const winningBids = (auction) ? auction.getWinningBids() : [];
24
+ const data = createAnalyticsEvent(args, winningBids);
25
+ sendAnalyticsEvent(data);
26
+ }, bidWonTimeout);
27
+ }
28
+
29
+ function getAnalyticsEventBids(bidsReceived) {
30
+ return bidsReceived.map(bid => {
31
+ return {
32
+ adUnitCode: bid.adUnitCode,
33
+ timeToRespond: bid.timeToRespond,
34
+ cpm: bid.cpm,
35
+ currency: bid.currency,
36
+ ttl: bid.ttl,
37
+ bidder: bid.bidder
38
+ };
39
+ });
40
+ }
41
+
42
+ function getBannerSizes(banner) {
43
+ if (banner && banner.sizes) {
44
+ return banner.sizes.map(size => {
45
+ const [width, height] = size;
46
+ return {w: width, h: height};
47
+ });
48
+ } else return [];
49
+ }
50
+
51
+ function getUniqueBy(arr, key) {
52
+ return [...new Map(arr.map(item => [item[key], item])).values()]
53
+ }
54
+
55
+ function createAnalyticsEvent(args, winningBids) {
56
+ let payload = {
57
+ instanceId: generateUUID(),
58
+ url: getRefererInfo().page,
59
+ bidsReceived: getAnalyticsEventBids(args.bidsReceived),
60
+ auctionStart: args.timestamp,
61
+ auctionEnd: args.auctionEnd,
62
+ adUnits: [],
63
+ userIds: [],
64
+ bidders: []
65
+ }
66
+ let allUserIds = [];
67
+
68
+ if (args.adUnits) {
69
+ args.adUnits.forEach(unit => {
70
+ if (unit.mediaTypes && unit.mediaTypes.banner) {
71
+ payload['adUnits'].push({
72
+ code: unit.code,
73
+ mediaType: 'banner',
74
+ sizes: getBannerSizes(unit.mediaTypes.banner),
75
+ ortb2Imp: unit.ortb2Imp
76
+ });
77
+ }
78
+ if (unit.bids) {
79
+ let userIds = unit.bids.flatMap(getAnalyticsEventUserIds);
80
+ allUserIds.push(...userIds);
81
+ let bidders = unit.bids.map(({bidder, params}) => {
82
+ return { bidder, params }
83
+ });
84
+
85
+ payload['bidders'].push(...bidders);
86
+ }
87
+ })
88
+ let uniqueUserIds = getUniqueBy(allUserIds, 'source');
89
+ payload['userIds'] = uniqueUserIds;
90
+ }
91
+ payload['winningBids'] = getAnalyticsEventBids(winningBids);
92
+ payload['auctionId'] = args.auctionId;
93
+ return payload;
94
+ }
95
+
96
+ function getAnalyticsEventUserIds(bid) {
97
+ if (bid && bid.userIdAsEids) {
98
+ return bid.userIdAsEids.map(({source, uids, ext}) => {
99
+ let analyticsEventUserId = {source, uids, ext};
100
+ return ignoreUndefined(analyticsEventUserId)
101
+ });
102
+ } else { return []; }
103
+ }
104
+
105
+ function sendAnalyticsEvent(data) {
106
+ ajax(URL, {
107
+ success: function () {
108
+ logInfo('LiveIntent Prebid Analytics: send data success');
109
+ },
110
+ error: function (e) {
111
+ logWarn('LiveIntent Prebid Analytics: send data error' + e);
112
+ }
113
+ }, JSON.stringify(data), {
114
+ contentType: 'application/json',
115
+ method: 'POST'
116
+ })
117
+ }
118
+
119
+ function ignoreUndefined(data) {
120
+ const filteredData = Object.entries(data).filter(([key, value]) => value)
121
+ return Object.fromEntries(filteredData)
122
+ }
123
+
124
+ let liAnalytics = Object.assign(adapter({URL, ANALYTICS_TYPE}), {
125
+ track({ eventType, args }) {
126
+ if (eventType == AUCTION_END && args && isSampled) { handleAuctionEnd(args); }
127
+ }
128
+ });
129
+
130
+ // save the base class function
131
+ liAnalytics.originEnableAnalytics = liAnalytics.enableAnalytics;
132
+
133
+ // override enableAnalytics so we can get access to the config passed in from the page
134
+ liAnalytics.enableAnalytics = function (config) {
135
+ initOptions = config.options;
136
+ const sampling = (initOptions && initOptions.sampling) ?? DEFAULT_SAMPLING;
137
+ isSampled = Math.random() < parseFloat(sampling);
138
+ bidWonTimeout = (initOptions && initOptions.bidWonTimeout) ?? DEFAULT_BID_WON_TIMEOUT;
139
+ liAnalytics.originEnableAnalytics(config); // call the base class function
140
+ };
141
+
142
+ adapterManager.registerAnalyticsAdapter({
143
+ adapter: liAnalytics,
144
+ code: ADAPTER_CODE,
145
+ gvlid: GVL_ID
146
+ });
147
+
148
+ export default liAnalytics;
@@ -0,0 +1,22 @@
1
+ # Overview
2
+ Module Name: LiveIntent Analytics Adapter
3
+
4
+ Module Type: Analytics Adapter
5
+
6
+ Maintainer: product@liveintent.com
7
+
8
+ # Description
9
+
10
+ Analytics adapter for [LiveIntent](https://www.liveintent.com/). Contact product@liveintent.com for information.
11
+
12
+ # Test Parameters
13
+
14
+ ```
15
+ {
16
+ provider: 'liveintent',
17
+ options: {
18
+ bidWonTimeout: 2000,
19
+ sampling: 0.5 // the tracked event percentage, a number between 0 to 1
20
+ }
21
+ }
22
+ ```
package/modules/mass.js CHANGED
@@ -5,6 +5,7 @@
5
5
  import {config} from '../src/config.js';
6
6
  import {getHook} from '../src/hook.js';
7
7
  import {auctionManager} from '../src/auctionManager.js';
8
+ import {timedBidResponseHook} from '../src/utils/perfMetrics.js';
8
9
 
9
10
  const defaultCfg = {
10
11
  dealIdPattern: /^MASS/i
@@ -17,7 +18,6 @@ export let isEnabled = false;
17
18
  const matchedBids = {};
18
19
  let renderers;
19
20
 
20
- init();
21
21
  config.getConfig('mass', config => init(config.mass));
22
22
 
23
23
  /**
@@ -78,7 +78,7 @@ export function updateRenderers() {
78
78
  /**
79
79
  * Before hook for 'addBidResponse'.
80
80
  */
81
- export function addBidResponseHook(next, adUnitCode, bid, {index = auctionManager.index} = {}) {
81
+ export const addBidResponseHook = timedBidResponseHook('mass', function addBidResponseHook(next, adUnitCode, bid, {index = auctionManager.index} = {}) {
82
82
  let renderer;
83
83
  for (let i = 0; i < renderers.length; i++) {
84
84
  if (renderers[i].match(bid)) {
@@ -105,7 +105,7 @@ export function addBidResponseHook(next, adUnitCode, bid, {index = auctionManage
105
105
  }
106
106
 
107
107
  next(adUnitCode, bid);
108
- }
108
+ });
109
109
 
110
110
  /**
111
111
  * Add listener for the "message" event sent by the winning bid
@@ -180,3 +180,5 @@ export function useDefaultRender(renderUrl, namespace) {
180
180
  }
181
181
  };
182
182
  }
183
+
184
+ init();
@@ -12,6 +12,7 @@ import * as events from '../../src/events.js';
12
12
  import CONSTANTS from '../../src/constants.json';
13
13
  import {addBidderRequests} from '../../src/auction.js';
14
14
  import {getHighestCpmBidsFromBidPool, sortByDealAndPriceBucketOrCpm} from '../../src/targeting.js';
15
+ import {timedBidResponseHook} from '../../src/utils/perfMetrics.js';
15
16
 
16
17
  const MODULE_NAME = 'multibid';
17
18
  let hasMultibid = false;
@@ -98,7 +99,7 @@ export function adjustBidderRequestsHook(fn, bidderRequests) {
98
99
  * @param {String} ad unit code for bid
99
100
  * @param {Object} bid object
100
101
  */
101
- export function addBidResponseHook(fn, adUnitCode, bid) {
102
+ export const addBidResponseHook = timedBidResponseHook('multibid', function addBidResponseHook(fn, adUnitCode, bid) {
102
103
  let floor = deepAccess(bid, 'floorData.floorValue');
103
104
 
104
105
  if (!config.getConfig('multibid')) resetMultiConfig();
@@ -141,7 +142,7 @@ export function addBidResponseHook(fn, adUnitCode, bid) {
141
142
  } else {
142
143
  fn.call(this, adUnitCode, bid);
143
144
  }
144
- }
145
+ });
145
146
 
146
147
  /**
147
148
  * A descending sort function that will sort the list of objects based on the following:
@@ -227,6 +228,7 @@ export const resetMultibidUnits = () => multibidUnits = {};
227
228
  * Set up hooks on init
228
229
  */
229
230
  function init() {
231
+ // TODO: does this reset logic make sense - what about simultaneous auctions?
230
232
  events.on(CONSTANTS.EVENTS.AUCTION_INIT, resetMultibidUnits);
231
233
  setupBeforeHookFnOnce(addBidderRequests, adjustBidderRequestsHook);
232
234
  getHook('addBidResponse').before(addBidResponseHook, 3);
@@ -6,16 +6,52 @@
6
6
  */
7
7
  import { isStr, isPlainObject, logError } from '../src/utils.js';
8
8
  import { submodule } from '../src/hook.js';
9
+ import { ajax } from '../src/ajax.js';
9
10
  import { getStorageManager } from '../src/storageManager.js';
10
11
 
11
12
  const MODULE_NAME = 'naveggId';
12
13
  const OLD_NAVEGG_ID = 'nid';
13
- const NAVEGG_ID = 'nvggid'
14
+ const NAVEGG_ID = 'nvggid';
15
+ const BASE_URL = 'https://id.navegg.com/uid/';
16
+ const DEFAULT_EXPIRE = 8 * 24 * 3600 * 1000;
17
+ const INVALID_EXPIRE = 3600 * 1000;
14
18
 
15
19
  export const storage = getStorageManager();
16
20
 
21
+ function getNaveggIdFromApi() {
22
+ const callbacks = {
23
+ success: response => {
24
+ if (response) {
25
+ try {
26
+ const responseObj = JSON.parse(response);
27
+ writeCookie(NAVEGG_ID, responseObj[NAVEGG_ID]);
28
+ } catch (error) {
29
+ logError(error);
30
+ }
31
+ }
32
+ },
33
+ error: error => {
34
+ logError('Navegg ID fetch encountered an error', error);
35
+ }
36
+ };
37
+ ajax(BASE_URL, callbacks, undefined, { method: 'GET', withCredentials: false });
38
+ }
39
+
40
+ function writeCookie(key, value) {
41
+ try {
42
+ if (storage.cookiesAreEnabled) {
43
+ let expTime = new Date();
44
+ const expires = value ? DEFAULT_EXPIRE : INVALID_EXPIRE;
45
+ expTime.setTime(expTime.getTime() + expires);
46
+ storage.setCookie(key, value, expTime.toUTCString(), 'none');
47
+ }
48
+ } catch (e) {
49
+ logError(e);
50
+ }
51
+ }
52
+
17
53
  function readnaveggIdFromLocalStorage() {
18
- return storage.getDataFromLocalStorage(NAVEGG_ID);
54
+ return storage.localStorageIsEnabled ? storage.getDataFromLocalStorage(NAVEGG_ID) : null;
19
55
  }
20
56
 
21
57
  function readnaveggIDFromCookie() {
@@ -37,35 +73,30 @@ function readnavIDFromCookie() {
37
73
  /** @type {Submodule} */
38
74
  export const naveggIdSubmodule = {
39
75
  /**
40
- * used to link submodule with config
41
- * @type {string}
42
- */
76
+ * used to link submodule with config
77
+ * @type {string}
78
+ */
43
79
  name: MODULE_NAME,
44
80
  /**
45
- * decode the stored id value for passing to bid requests
46
- * @function
47
- * @param { Object | string | undefined } value
48
- * @return { Object | string | undefined }
49
- */
81
+ * decode the stored id value for passing to bid requests
82
+ * @function
83
+ * @param { Object | string | undefined } value
84
+ * @return { Object | string | undefined }
85
+ */
50
86
  decode(value) {
51
87
  const naveggIdVal = value ? isStr(value) ? value : isPlainObject(value) ? value.id : undefined : undefined;
52
88
  return naveggIdVal ? {
53
- 'naveggId': naveggIdVal
89
+ 'naveggId': naveggIdVal.split('|')[0]
54
90
  } : undefined;
55
91
  },
56
92
  /**
57
- * performs action to obtain id and return a value in the callback's response argument
58
- * @function
59
- * @param {SubmoduleConfig} config
60
- * @return {{id: string | undefined } | undefined}
61
- */
93
+ * performs action to obtain id and return a value in the callback's response argument
94
+ * @function
95
+ * @param {SubmoduleConfig} config
96
+ * @return {{id: string | undefined } | undefined}
97
+ */
62
98
  getId() {
63
- let naveggIdStringFromLocalStorage = null;
64
- if (storage.localStorageIsEnabled) {
65
- naveggIdStringFromLocalStorage = readnaveggIdFromLocalStorage();
66
- }
67
-
68
- const naveggIdString = naveggIdStringFromLocalStorage || readnaveggIDFromCookie() || readoldnaveggIDFromCookie() || readnvgIDFromCookie() || readnavIDFromCookie();
99
+ const naveggIdString = readnaveggIdFromLocalStorage() || readnaveggIDFromCookie() || getNaveggIdFromApi() || readoldnaveggIDFromCookie() || readnvgIDFromCookie() || readnavIDFromCookie();
69
100
 
70
101
  if (typeof naveggIdString == 'string' && naveggIdString) {
71
102
  try {