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.
- package/.circleci/config.yml +3 -0
- package/dist/1plusXRtdProvider.js +1 -1
- package/dist/33acrossBidAdapter.js +1 -1
- package/dist/adagioBidAdapter.js +1 -1
- package/dist/adbookpspBidAdapter.js +1 -1
- package/dist/adfBidAdapter.js +1 -1
- package/dist/adgenerationBidAdapter.js +1 -1
- package/dist/adkernelAdnBidAdapter.js +1 -1
- package/dist/adkernelBidAdapter.js +1 -1
- package/dist/adlooxAdServerVideo.js +1 -1
- package/dist/adlooxRtdProvider.js +1 -1
- package/dist/adrelevantisBidAdapter.js +1 -1
- package/dist/adtrgtmeBidAdapter.js +1 -1
- package/dist/adtrueBidAdapter.js +1 -1
- package/dist/adxcgBidAdapter.js +1 -1
- package/dist/airgridRtdProvider.js +1 -1
- package/dist/ajaBidAdapter.js +1 -1
- package/dist/amxBidAdapter.js +1 -1
- package/dist/amxIdSystem.js +1 -1
- package/dist/aolBidAdapter.js +1 -1
- package/dist/appierAnalyticsAdapter.js +1 -1
- package/dist/appnexusBidAdapter.js +1 -1
- package/dist/asoBidAdapter.js +1 -1
- package/dist/axonixBidAdapter.js +1 -1
- package/dist/beachfrontBidAdapter.js +1 -1
- package/dist/bidglassBidAdapter.js +1 -1
- package/dist/big-richmediaBidAdapter.js +1 -1
- package/dist/bizzclickBidAdapter.js +1 -1
- package/dist/bliinkBidAdapter.js +1 -1
- package/dist/bluebillywigBidAdapter.js +1 -1
- package/dist/brandmetricsRtdProvider.js +1 -1
- package/dist/bridgewellBidAdapter.js +1 -1
- package/dist/brightMountainMediaBidAdapter.js +1 -1
- package/dist/brightcomBidAdapter.js +1 -1
- package/dist/browsiRtdProvider.js +1 -1
- package/dist/categoryTranslation.js +1 -1
- package/dist/concertBidAdapter.js +1 -1
- package/dist/connectadBidAdapter.js +1 -1
- package/dist/consentManagement.js +1 -1
- package/dist/consentManagementUsp.js +1 -1
- package/dist/consumableBidAdapter.js +1 -1
- package/dist/conversantBidAdapter.js +1 -1
- package/dist/cpmstarBidAdapter.js +1 -1
- package/dist/craftBidAdapter.js +1 -1
- package/dist/criteoBidAdapter.js +1 -1
- package/dist/currency.js +1 -1
- package/dist/dataControllerModule.js +1 -1
- package/dist/dchain.js +1 -1
- package/dist/deepintentBidAdapter.js +1 -1
- package/dist/dependencies.json +3 -0
- package/dist/dgkeywordRtdProvider.js +1 -1
- package/dist/dianomiBidAdapter.js +1 -1
- package/dist/distroscaleBidAdapter.js +1 -1
- package/dist/dspxBidAdapter.js +1 -1
- package/dist/eplanningBidAdapter.js +1 -1
- package/dist/etargetBidAdapter.js +1 -1
- package/dist/feedadBidAdapter.js +1 -1
- package/dist/finativeBidAdapter.js +1 -1
- package/dist/fpdModule.js +1 -1
- package/dist/gamoshiBidAdapter.js +1 -1
- package/dist/glimpseBidAdapter.js +1 -1
- package/dist/gmosspBidAdapter.js +1 -1
- package/dist/goldbachBidAdapter.js +1 -1
- package/dist/gothamadsBidAdapter.js +1 -1
- package/dist/gridBidAdapter.js +1 -1
- package/dist/gridNMBidAdapter.js +1 -1
- package/dist/gumgumBidAdapter.js +1 -1
- package/dist/h12mediaBidAdapter.js +1 -1
- package/dist/iasRtdProvider.js +1 -1
- package/dist/id5IdSystem.js +1 -1
- package/dist/imRtdProvider.js +1 -1
- package/dist/impactifyBidAdapter.js +1 -1
- package/dist/improvedigitalBidAdapter.js +1 -1
- package/dist/inmarBidAdapter.js +1 -1
- package/dist/insticatorBidAdapter.js +1 -1
- package/dist/ixBidAdapter.js +1 -1
- package/dist/justpremiumBidAdapter.js +1 -1
- package/dist/konduitAnalyticsAdapter.js +1 -1
- package/dist/kueezBidAdapter.js +1 -1
- package/dist/lassoBidAdapter.js +1 -1
- package/dist/lifestreetBidAdapter.js +1 -1
- package/dist/liveIntentAnalyticsAdapter.js +1 -0
- package/dist/liveyieldAnalyticsAdapter.js +1 -1
- package/dist/logicadBidAdapter.js +1 -1
- package/dist/loglyliftBidAdapter.js +1 -1
- package/dist/luponmediaBidAdapter.js +1 -1
- package/dist/malltvAnalyticsAdapter.js +1 -1
- package/dist/marsmediaBidAdapter.js +1 -1
- package/dist/mass.js +1 -1
- package/dist/mediafuseBidAdapter.js +1 -1
- package/dist/mediakeysBidAdapter.js +1 -1
- package/dist/mediasniperBidAdapter.js +1 -1
- package/dist/mediasquareBidAdapter.js +1 -1
- package/dist/mgidBidAdapter.js +1 -1
- package/dist/minutemediaBidAdapter.js +1 -1
- package/dist/multibid.js +1 -1
- package/dist/naveggIdSystem.js +1 -1
- package/dist/newspassidBidAdapter.js +1 -1
- package/dist/nextMillenniumBidAdapter.js +1 -1
- package/dist/not-for-prod/prebid.js +172 -171
- package/dist/oguryBidAdapter.js +1 -1
- package/dist/oneKeyRtdProvider.js +1 -1
- package/dist/onetagBidAdapter.js +1 -1
- package/dist/ooloAnalyticsAdapter.js +1 -1
- package/dist/openxBidAdapter.js +1 -1
- package/dist/openxOrtbBidAdapter.js +1 -1
- package/dist/operaadsBidAdapter.js +1 -1
- package/dist/outbrainBidAdapter.js +1 -1
- package/dist/ozoneBidAdapter.js +1 -1
- package/dist/parrableIdSystem.js +1 -1
- package/dist/permutiveRtdProvider.js +1 -1
- package/dist/pixfutureBidAdapter.js +1 -1
- package/dist/prebid-core.js +2 -2
- package/dist/prebidServerBidAdapter.js +1 -1
- package/dist/priceFloors.js +1 -1
- package/dist/pubCommonId.js +1 -1
- package/dist/pubgeniusBidAdapter.js +1 -1
- package/dist/publinkIdSystem.js +1 -1
- package/dist/pubmaticBidAdapter.js +1 -1
- package/dist/pubwiseAnalyticsAdapter.js +1 -1
- package/dist/pubwiseBidAdapter.js +1 -1
- package/dist/pubxBidAdapter.js +1 -1
- package/dist/pxyzBidAdapter.js +1 -1
- package/dist/quantcastBidAdapter.js +1 -1
- package/dist/readpeakBidAdapter.js +1 -1
- package/dist/relaidoBidAdapter.js +1 -1
- package/dist/rhythmoneBidAdapter.js +1 -1
- package/dist/riseBidAdapter.js +1 -1
- package/dist/rtdModule.js +1 -1
- package/dist/rubiconAnalyticsAdapter.js +1 -1
- package/dist/rubiconBidAdapter.js +1 -1
- package/dist/seedingAllianceBidAdapter.js +1 -1
- package/dist/seedtagBidAdapter.js +1 -1
- package/dist/sharethroughAnalyticsAdapter.js +1 -1
- package/dist/sharethroughBidAdapter.js +1 -1
- package/dist/shinezBidAdapter.js +1 -1
- package/dist/sirdataRtdProvider.js +1 -1
- package/dist/smaatoBidAdapter.js +1 -1
- package/dist/smartadserverBidAdapter.js +1 -1
- package/dist/smartxBidAdapter.js +1 -1
- package/dist/smilewantedBidAdapter.js +1 -1
- package/dist/sonobiBidAdapter.js +1 -1
- package/dist/sovrnAnalyticsAdapter.js +1 -1
- package/dist/sovrnBidAdapter.js +1 -1
- package/dist/spotxBidAdapter.js +1 -1
- package/dist/sspBCBidAdapter.js +1 -1
- package/dist/stroeerCoreBidAdapter.js +1 -1
- package/dist/sublimeBidAdapter.js +1 -1
- package/dist/synacormediaBidAdapter.js +1 -1
- package/dist/targetVideoBidAdapter.js +1 -1
- package/dist/teadsBidAdapter.js +1 -1
- package/dist/trionBidAdapter.js +1 -1
- package/dist/tripleliftBidAdapter.js +1 -1
- package/dist/ttdBidAdapter.js +1 -1
- package/dist/ucfunnelAnalyticsAdapter.js +1 -1
- package/dist/ucfunnelBidAdapter.js +1 -1
- package/dist/underdogmediaBidAdapter.js +1 -1
- package/dist/undertoneBidAdapter.js +1 -1
- package/dist/userId.js +1 -1
- package/dist/vidazooBidAdapter.js +1 -1
- package/dist/videobyteBidAdapter.js +1 -1
- package/dist/viewability.js +1 -1
- package/dist/visxBidAdapter.js +1 -1
- package/dist/vuukleBidAdapter.js +1 -1
- package/dist/weboramaRtdProvider.js +1 -1
- package/dist/widespaceBidAdapter.js +1 -1
- package/dist/winrBidAdapter.js +1 -1
- package/dist/yahoosspBidAdapter.js +1 -1
- package/dist/yieldliftBidAdapter.js +1 -1
- package/dist/yieldmoBidAdapter.js +1 -1
- package/dist/yieldoneAnalyticsAdapter.js +1 -1
- package/dist/zeta_global_sspBidAdapter.js +1 -1
- package/modules/amxBidAdapter.js +98 -78
- package/modules/appnexusBidAdapter.js +73 -12
- package/modules/categoryTranslation.js +9 -8
- package/modules/consentManagement.js +4 -2
- package/modules/consentManagementUsp.js +17 -14
- package/modules/cpmstarBidAdapter.js +2 -1
- package/modules/currency.js +4 -3
- package/modules/dataControllerModule/index.js +4 -3
- package/modules/dchain.js +3 -2
- package/modules/dianomiBidAdapter.js +17 -14
- package/modules/dianomiBidAdapter.md +1 -1
- package/modules/feedadBidAdapter.js +40 -8
- package/modules/fpdModule/index.js +3 -2
- package/modules/iasRtdProvider.js +17 -3
- package/modules/ixBidAdapter.js +2 -5
- package/modules/liveIntentAnalyticsAdapter.js +148 -0
- package/modules/liveIntentAnalyticsAdapter.md +22 -0
- package/modules/mass.js +5 -3
- package/modules/multibid/index.js +4 -2
- package/modules/naveggIdSystem.js +53 -22
- package/modules/nextMillenniumBidAdapter.js +168 -55
- package/modules/openxOrtbBidAdapter.js +1 -1
- package/modules/prebidServerBidAdapter/index.js +18 -4
- package/modules/priceFloors.js +5 -4
- package/modules/pubCommonId.js +3 -2
- package/modules/rtdModule/index.js +3 -2
- package/modules/sharethroughBidAdapter.js +8 -6
- package/modules/spotxBidAdapter.js +1 -0
- package/modules/stroeerCoreBidAdapter.js +129 -92
- package/modules/stroeerCoreBidAdapter.md +52 -14
- package/modules/teadsBidAdapter.js +32 -10
- package/modules/ucfunnelBidAdapter.js +9 -10
- package/modules/userId/index.js +73 -48
- package/modules/viewability.js +2 -170
- package/package.json +3 -3
- package/src/adapterManager.js +21 -13
- package/src/adapters/bidderFactory.js +28 -6
- package/src/auction.js +17 -4
- package/src/auctionManager.js +5 -0
- package/src/constants.json +2 -0
- package/src/native.js +5 -2
- package/src/prebid.js +52 -23
- package/src/secureCreatives.js +1 -1
- package/src/utils/perfMetrics.js +386 -0
- package/src/utils.js +1 -1
- package/test/helpers/testing-utils.js +4 -3
- package/test/spec/modules/adriverIdSystem_spec.js +7 -3
- package/test/spec/modules/amxBidAdapter_spec.js +250 -192
- package/test/spec/modules/appnexusBidAdapter_spec.js +61 -6
- package/test/spec/modules/consentManagementUsp_spec.js +6 -2
- package/test/spec/modules/dianomiBidAdapter_spec.js +326 -6
- package/test/spec/modules/feedadBidAdapter_spec.js +147 -11
- package/test/spec/modules/iasRtdProvider_spec.js +3 -1
- package/test/spec/modules/ixBidAdapter_spec.js +0 -64
- package/test/spec/modules/liveIntentAnalyticsAdapter_spec.js +297 -0
- package/test/spec/modules/nextMillenniumBidAdapter_spec.js +103 -1
- package/test/spec/modules/openxOrtbBidAdapter_spec.js +31 -0
- package/test/spec/modules/sharethroughBidAdapter_spec.js +23 -2
- package/test/spec/modules/spotxBidAdapter_spec.js +6 -0
- package/test/spec/modules/stroeerCoreBidAdapter_spec.js +315 -33
- package/test/spec/modules/teadsBidAdapter_spec.js +65 -11
- package/test/spec/modules/ucfunnelBidAdapter_spec.js +24 -10
- package/test/spec/native_spec.js +11 -0
- package/test/spec/unit/utils/perfMetrics_spec.js +394 -0
- package/wdio.conf.js +1 -0
- package/modules/viewability.md +0 -87
- 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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
76
|
+
* used to link submodule with config
|
|
77
|
+
* @type {string}
|
|
78
|
+
*/
|
|
43
79
|
name: MODULE_NAME,
|
|
44
80
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
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 {
|