prebid.js 6.2.0 → 6.6.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 +1 -1
- package/gulpfile.js +87 -82
- package/integrationExamples/gpt/weboramaRtdProvider_example.html +23 -14
- package/karma.conf.maker.js +1 -1
- package/modules/.submodules.json +2 -1
- package/modules/33acrossBidAdapter.js +189 -102
- package/modules/adagioBidAdapter.js +1 -1
- package/modules/addefendBidAdapter.js +1 -0
- package/modules/adkernelBidAdapter.js +148 -62
- package/modules/adlooxAdServerVideo.js +2 -2
- package/modules/adlooxAnalyticsAdapter.js +4 -4
- package/modules/admanBidAdapter.js +11 -4
- package/modules/admixerBidAdapter.js +1 -1
- package/modules/adnuntiusBidAdapter.js +3 -1
- package/modules/adomikAnalyticsAdapter.js +27 -9
- package/modules/adqueryIdSystem.js +103 -0
- package/modules/adqueryIdSystem.md +35 -0
- package/modules/adxcgBidAdapter.js +311 -359
- package/modules/adxcgBidAdapter.md +22 -21
- package/modules/adyoulikeBidAdapter.js +13 -9
- package/modules/aniviewBidAdapter.js +1 -1
- package/modules/appnexusBidAdapter.js +0 -1
- package/modules/beopBidAdapter.js +6 -4
- package/modules/bidViewability.js +3 -3
- package/modules/bidViewabilityIO.js +3 -3
- package/modules/bliinkBidAdapter.js +3 -2
- package/modules/colossussspBidAdapter.js +7 -0
- package/modules/compassBidAdapter.js +208 -0
- package/modules/compassBidAdapter.md +79 -0
- package/modules/consentManagement.js +7 -1
- package/modules/criteoBidAdapter.js +1 -1
- package/modules/criteoIdSystem.js +29 -7
- package/modules/currency.js +2 -2
- package/modules/cwireBidAdapter.js +3 -0
- package/modules/dailyhuntBidAdapter.js +435 -0
- package/modules/dailyhuntBidAdapter.md +4 -0
- package/modules/docereeBidAdapter.js +10 -1
- package/modules/docereeBidAdapter.md +2 -0
- package/modules/dspxBidAdapter.js +1 -1
- package/modules/engageyaBidAdapter.js +1 -1
- package/modules/feedadBidAdapter.js +2 -2
- package/modules/feedadBidAdapter.md +4 -2
- package/modules/futureads.md +48 -0
- package/modules/glimpseBidAdapter.js +82 -47
- package/modules/gptPreAuction.js +55 -7
- package/modules/gridBidAdapter.js +4 -3
- package/modules/gumgumBidAdapter.js +2 -2
- package/modules/idImportLibrary.js +45 -8
- package/modules/idImportLibrary.md +4 -0
- package/modules/improvedigitalBidAdapter.js +42 -4
- package/modules/instreamTracking.js +4 -4
- package/modules/invibesBidAdapter.js +49 -5
- package/modules/invibesBidAdapter.md +2 -1
- package/modules/ixBidAdapter.js +53 -18
- package/modules/kinessoIdSystem.js +1 -1
- package/modules/limelightDigitalBidAdapter.js +2 -1
- package/modules/livewrappedAnalyticsAdapter.js +3 -1
- package/modules/livewrappedBidAdapter.js +8 -2
- package/modules/loglyliftBidAdapter.js +79 -0
- package/modules/loglyliftBidAdapter.md +55 -0
- package/modules/lotamePanoramaIdSystem.js +80 -8
- package/modules/mediasquareBidAdapter.js +1 -9
- package/modules/nextMillenniumBidAdapter.js +39 -7
- package/modules/oguryBidAdapter.js +9 -2
- package/modules/onetagBidAdapter.js +4 -2
- package/modules/optimeraRtdProvider.js +8 -1
- package/modules/ozoneBidAdapter.js +21 -64
- package/modules/prebidServerBidAdapter/index.js +16 -12
- package/modules/proxistoreBidAdapter.js +0 -2
- package/modules/pubgeniusBidAdapter.js +1 -1
- package/modules/pubmaticAnalyticsAdapter.js +16 -0
- package/modules/pubxaiAnalyticsAdapter.js +17 -0
- package/modules/richaudienceBidAdapter.js +4 -4
- package/modules/riseBidAdapter.js +1 -1
- package/modules/rtbhouseBidAdapter.js +14 -4
- package/modules/rtdModule/index.js +49 -18
- package/modules/rubiconBidAdapter.js +31 -19
- package/modules/sharedIdSystem.js +27 -1
- package/modules/showheroes-bsBidAdapter.js +13 -2
- package/modules/tappxBidAdapter.js +8 -5
- package/modules/targetVideoBidAdapter.js +187 -0
- package/modules/targetVideoBidAdapter.md +34 -0
- package/modules/teadsBidAdapter.js +1 -2
- package/modules/telariaBidAdapter.js +2 -2
- package/modules/trustxBidAdapter.js +8 -16
- package/modules/userId/eids.js +7 -1
- package/modules/userId/userId.md +8 -0
- package/modules/vidoomyBidAdapter.js +16 -10
- package/modules/weboramaRtdProvider.js +288 -73
- package/modules/weboramaRtdProvider.md +27 -10
- package/modules/welectBidAdapter.js +106 -0
- package/modules/yahoosspBidAdapter.js +5 -1
- package/modules/yieldmoBidAdapter.js +23 -5
- package/modules/zetaSspBidAdapter.md +33 -1
- package/modules/zeta_global_sspAnalyticsAdapter.js +97 -0
- package/modules/zeta_global_sspAnalyticsAdapter.md +24 -0
- package/modules/zeta_global_sspBidAdapter.js +22 -1
- package/package.json +1 -1
- package/plugins/pbjsGlobals.js +28 -1
- package/src/auction.js +2 -2
- package/src/config.js +27 -3
- package/src/hook.js +5 -1
- package/src/prebid.js +21 -6
- package/src/targeting.js +22 -1
- package/src/utils.js +46 -8
- package/test/helpers/prebidGlobal.js +1 -0
- package/test/spec/config_spec.js +279 -0
- package/test/spec/modules/33acrossBidAdapter_spec.js +300 -78
- package/test/spec/modules/adlooxAnalyticsAdapter_spec.js +6 -6
- package/test/spec/modules/admanBidAdapter_spec.js +2 -2
- package/test/spec/modules/adnuntiusBidAdapter_spec.js +17 -0
- package/test/spec/modules/adomikAnalyticsAdapter_spec.js +9 -1
- package/test/spec/modules/adqueryIdSystem_spec.js +74 -0
- package/test/spec/modules/adxcgBidAdapter_spec.js +820 -571
- package/test/spec/modules/adyoulikeBidAdapter_spec.js +49 -0
- package/test/spec/modules/beopBidAdapter_spec.js +1 -1
- package/test/spec/modules/bidViewabilityIO_spec.js +2 -2
- package/test/spec/modules/bidViewability_spec.js +4 -4
- package/test/spec/modules/bliinkBidAdapter_spec.js +2 -0
- package/test/spec/modules/colossussspBidAdapter_spec.js +9 -0
- package/test/spec/modules/compassBidAdapter_spec.js +398 -0
- package/test/spec/modules/consentManagement_spec.js +20 -0
- package/test/spec/modules/criteoIdSystem_spec.js +6 -3
- package/test/spec/modules/cwireBidAdapter_spec.js +10 -8
- package/test/spec/modules/dailyhuntBidAdapter_spec.js +404 -0
- package/test/spec/modules/docereeBidAdapter_spec.js +9 -1
- package/test/spec/modules/eids_spec.js +15 -0
- package/test/spec/modules/feedadBidAdapter_spec.js +15 -0
- package/test/spec/modules/glimpseBidAdapter_spec.js +0 -18
- package/test/spec/modules/gptPreAuction_spec.js +177 -2
- package/test/spec/modules/idImportLibrary_spec.js +197 -10
- package/test/spec/modules/improvedigitalBidAdapter_spec.js +45 -1
- package/test/spec/modules/invibesBidAdapter_spec.js +119 -0
- package/test/spec/modules/ixBidAdapter_spec.js +112 -62
- package/test/spec/modules/limelightDigitalBidAdapter_spec.js +75 -17
- package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +22 -0
- package/test/spec/modules/livewrappedBidAdapter_spec.js +31 -0
- package/test/spec/modules/loglyliftBidAdapter_spec.js +172 -0
- package/test/spec/modules/lotamePanoramaIdSystem_spec.js +227 -0
- package/test/spec/modules/mediasquareBidAdapter_spec.js +4 -4
- package/test/spec/modules/nextMillenniumBidAdapter_spec.js +26 -1
- package/test/spec/modules/oguryBidAdapter_spec.js +10 -2
- package/test/spec/modules/optimeraRtdProvider_spec.js +14 -1
- package/test/spec/modules/ozoneBidAdapter_spec.js +43 -31
- package/test/spec/modules/prebidServerBidAdapter_spec.js +43 -0
- package/test/spec/modules/pubgeniusBidAdapter_spec.js +3 -3
- package/test/spec/modules/pubmaticAnalyticsAdapter_spec.js +13 -1
- package/test/spec/modules/pubxaiAnalyticsAdapter_spec.js +11 -0
- package/test/spec/modules/realTimeDataModule_spec.js +147 -48
- package/test/spec/modules/richaudienceBidAdapter_spec.js +42 -2
- package/test/spec/modules/riseBidAdapter_spec.js +1 -1
- package/test/spec/modules/rtbhouseBidAdapter_spec.js +20 -0
- package/test/spec/modules/rubiconBidAdapter_spec.js +65 -9
- package/test/spec/modules/sharedIdSystem_spec.js +52 -6
- package/test/spec/modules/showheroes-bsBidAdapter_spec.js +2 -0
- package/test/spec/modules/tappxBidAdapter_spec.js +0 -19
- package/test/spec/modules/targetVideoBidAdapter_spec.js +96 -0
- package/test/spec/modules/teadsBidAdapter_spec.js +14 -59
- package/test/spec/modules/userId_spec.js +68 -19
- package/test/spec/modules/weboramaRtdProvider_spec.js +408 -214
- package/test/spec/modules/welectBidAdapter_spec.js +211 -0
- package/test/spec/modules/yahoosspBidAdapter_spec.js +28 -1
- package/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js +427 -0
- package/test/spec/modules/zeta_global_sspBidAdapter_spec.js +33 -1
- package/test/spec/unit/core/targeting_spec.js +72 -0
- package/test/spec/unit/pbjs_api_spec.js +3 -1
- package/test/spec/utils_spec.js +38 -0
- package/test/test_deps.js +3 -0
- package/test/test_index.js +1 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logError, deepAccess } from '../src/utils.js';
|
|
1
|
+
import { logError, deepAccess, parseSizesInput } from '../src/utils.js';
|
|
2
2
|
import {registerBidder} from '../src/adapters/bidderFactory.js';
|
|
3
3
|
import {BANNER, VIDEO} from '../src/mediaTypes.js';
|
|
4
4
|
import {config} from '../src/config.js';
|
|
@@ -53,7 +53,7 @@ const isBidResponseValid = bid => {
|
|
|
53
53
|
case BANNER:
|
|
54
54
|
return Boolean(bid.width && bid.height && bid.ad);
|
|
55
55
|
case VIDEO:
|
|
56
|
-
return Boolean(bid.vastUrl);
|
|
56
|
+
return Boolean(bid.vastUrl || bid.vastXml);
|
|
57
57
|
default:
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
@@ -62,14 +62,15 @@ const isBidResponseValid = bid => {
|
|
|
62
62
|
const buildRequests = (validBidRequests, bidderRequest) => {
|
|
63
63
|
const serverRequests = validBidRequests.map(bid => {
|
|
64
64
|
let adType = BANNER;
|
|
65
|
-
let
|
|
65
|
+
let sizes;
|
|
66
66
|
if (bid.mediaTypes && bid.mediaTypes[BANNER] && bid.mediaTypes[BANNER].sizes) {
|
|
67
|
-
|
|
67
|
+
sizes = bid.mediaTypes[BANNER].sizes;
|
|
68
68
|
adType = BANNER;
|
|
69
69
|
} else if (bid.mediaTypes && bid.mediaTypes[VIDEO] && bid.mediaTypes[VIDEO].playerSize) {
|
|
70
|
-
|
|
70
|
+
sizes = bid.mediaTypes[VIDEO].playerSize;
|
|
71
71
|
adType = VIDEO;
|
|
72
72
|
}
|
|
73
|
+
const [w, h] = (parseSizesInput(sizes)[0] || '0x0').split('x');
|
|
73
74
|
|
|
74
75
|
const aElement = document.createElement('a');
|
|
75
76
|
aElement.href = (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) || top.location.href;
|
|
@@ -80,6 +81,7 @@ const buildRequests = (validBidRequests, bidderRequest) => {
|
|
|
80
81
|
const queryParams = {
|
|
81
82
|
id: bid.params.id,
|
|
82
83
|
adtype: adType,
|
|
84
|
+
auc: bid.adUnitCode,
|
|
83
85
|
w,
|
|
84
86
|
h,
|
|
85
87
|
pos: parseInt(bid.params.position) || 1,
|
|
@@ -88,7 +90,7 @@ const buildRequests = (validBidRequests, bidderRequest) => {
|
|
|
88
90
|
dt: /Mobi/.test(navigator.userAgent) ? 2 : 1,
|
|
89
91
|
pid: bid.params.pid,
|
|
90
92
|
requestId: bid.bidId,
|
|
91
|
-
d: getDomainWithoutSubdomain(hostname),
|
|
93
|
+
d: getDomainWithoutSubdomain(hostname), // 'vidoomy.com',
|
|
92
94
|
sp: encodeURIComponent(aElement.href),
|
|
93
95
|
usp: bidderRequest.uspConsent || '',
|
|
94
96
|
coppa: !!config.getConfig('coppa'),
|
|
@@ -127,7 +129,7 @@ const interpretResponse = (serverResponse, bidRequest) => {
|
|
|
127
129
|
let responseBody = serverResponse.body;
|
|
128
130
|
if (!responseBody) return;
|
|
129
131
|
if (responseBody.mediaType === 'video') {
|
|
130
|
-
responseBody.ad = responseBody.vastUrl;
|
|
132
|
+
responseBody.ad = responseBody.vastUrl || responseBody.vastXml;
|
|
131
133
|
const videoContext = bidRequest.data.videoContext;
|
|
132
134
|
|
|
133
135
|
if (videoContext === OUTSTREAM) {
|
|
@@ -143,13 +145,12 @@ const interpretResponse = (serverResponse, bidRequest) => {
|
|
|
143
145
|
|
|
144
146
|
responseBody.renderer = renderer;
|
|
145
147
|
} catch (e) {
|
|
146
|
-
responseBody.ad = responseBody.vastUrl;
|
|
148
|
+
responseBody.ad = responseBody.vastUrl || responseBody.vastXml;
|
|
147
149
|
logError(BIDDER_CODE + ': error while installing renderer to show outstream ad');
|
|
148
150
|
}
|
|
149
151
|
}
|
|
150
152
|
}
|
|
151
153
|
const bid = {
|
|
152
|
-
vastUrl: responseBody.vastUrl,
|
|
153
154
|
ad: responseBody.ad,
|
|
154
155
|
renderer: responseBody.renderer,
|
|
155
156
|
mediaType: responseBody.mediaType,
|
|
@@ -178,6 +179,11 @@ const interpretResponse = (serverResponse, bidRequest) => {
|
|
|
178
179
|
secondaryCatIds: responseBody.meta.secondaryCatIds
|
|
179
180
|
}
|
|
180
181
|
};
|
|
182
|
+
if (responseBody.vastUrl) {
|
|
183
|
+
bid.vastUrl = responseBody.vastUrl;
|
|
184
|
+
} else if (responseBody.vastXml) {
|
|
185
|
+
bid.vastXml = responseBody.vastXml;
|
|
186
|
+
}
|
|
181
187
|
|
|
182
188
|
const bids = [];
|
|
183
189
|
|
|
@@ -202,7 +208,7 @@ function getUserSyncs (syncOptions, responses, gdprConsent, uspConsent) {
|
|
|
202
208
|
return [].concat(urls).map(url => ({
|
|
203
209
|
type: pixelType,
|
|
204
210
|
url: url
|
|
205
|
-
.replace('{{GDPR}}', gdprConsent ? gdprConsent.gdprApplies : '0')
|
|
211
|
+
.replace('{{GDPR}}', gdprConsent ? (gdprConsent.gdprApplies ? '1' : '0') : '0')
|
|
206
212
|
.replace('{{GDPR_CONSENT}}', gdprConsent ? encodeURIComponent(gdprConsent.consentString) : '')
|
|
207
213
|
.replace('{{USP_CONSENT}}', uspConsent ? encodeURIComponent(uspConsent) : '')
|
|
208
214
|
}));
|
|
@@ -2,90 +2,326 @@
|
|
|
2
2
|
* This module adds Weborama provider to the real time data module
|
|
3
3
|
* The {@link module:modules/realTimeData} module is required
|
|
4
4
|
* The module will fetch contextual data (page-centric) from Weborama server
|
|
5
|
+
* and may access user-centric data from local storage
|
|
5
6
|
* @module modules/weboramaRtdProvider
|
|
6
7
|
* @requires module:modules/realTimeData
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
* @typedef {Object} ModuleParams
|
|
11
|
-
* @property {WeboCtxConf} weboCtxConf
|
|
12
|
-
|
|
11
|
+
* @typedef {Object} ModuleParams
|
|
12
|
+
* @property {WeboCtxConf} weboCtxConf
|
|
13
|
+
* @property {WeboUserDataConf} weboUserDataConf
|
|
14
|
+
*/
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
|
-
* @typedef {Object} WeboCtxConf
|
|
16
|
-
* @property {string} token required token to be used on bigsea contextual API requests
|
|
17
|
-
* @property {?string} targetURL specify the target url instead use the referer
|
|
18
|
-
* @property {?
|
|
19
|
-
* @property {?
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
* @typedef {Object} WeboCtxConf
|
|
18
|
+
* @property {string} token required token to be used on bigsea contextual API requests
|
|
19
|
+
* @property {?string} targetURL specify the target url instead use the referer
|
|
20
|
+
* @property {?Boolean} setPrebidTargeting if true will set the GAM targeting (default true)
|
|
21
|
+
* @property {?Boolean} sendToBidders if true, will send the contextual profile to all bidders (default true)
|
|
22
|
+
* @property {?object} defaultProfile to be used if the profile is not found
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {Object} WeboUserDataConf
|
|
27
|
+
* @property {?string} localStorageProfileKey can be used to customize the local storage key (default is 'webo_wam2gam_entry')
|
|
28
|
+
* @property {?Boolean} setPrebidTargeting if true will set the GAM targeting (default true)
|
|
29
|
+
* @property {?Boolean} sendToBidders if true, will send the contextual profile to all bidders (default true)
|
|
30
|
+
* @property {?object} defaultProfile to be used if the profile is not found
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import {
|
|
34
|
+
getGlobal
|
|
35
|
+
} from '../src/prebidGlobal.js';
|
|
36
|
+
import {
|
|
37
|
+
deepSetValue,
|
|
38
|
+
deepAccess,
|
|
39
|
+
isEmpty,
|
|
40
|
+
mergeDeep,
|
|
41
|
+
logError,
|
|
42
|
+
tryAppendQueryString,
|
|
43
|
+
logMessage
|
|
44
|
+
} from '../src/utils.js';
|
|
45
|
+
import {
|
|
46
|
+
submodule
|
|
47
|
+
} from '../src/hook.js';
|
|
48
|
+
import {
|
|
49
|
+
ajax
|
|
50
|
+
} from '../src/ajax.js';
|
|
51
|
+
import {
|
|
52
|
+
getStorageManager
|
|
53
|
+
} from '../src/storageManager.js';
|
|
54
|
+
|
|
55
|
+
const adapterManager = require('../src/adapterManager.js').default;
|
|
26
56
|
|
|
27
57
|
/** @type {string} */
|
|
28
58
|
const MODULE_NAME = 'realTimeData';
|
|
29
59
|
/** @type {string} */
|
|
30
60
|
const SUBMODULE_NAME = 'weborama';
|
|
31
61
|
/** @type {string} */
|
|
32
|
-
const
|
|
62
|
+
export const DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY = 'webo_wam2gam_entry';
|
|
33
63
|
/** @type {string} */
|
|
34
|
-
const
|
|
64
|
+
const LOCAL_STORAGE_USER_TARGETING_SECTION = 'targeting';
|
|
65
|
+
/** @type {number} */
|
|
66
|
+
const GVLID = 284;
|
|
67
|
+
/** @type {object} */
|
|
68
|
+
export const storage = getStorageManager(GVLID, SUBMODULE_NAME);
|
|
35
69
|
|
|
36
70
|
/** @type {null|Object} */
|
|
37
|
-
let
|
|
71
|
+
let _weboContextualProfile = null;
|
|
38
72
|
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
73
|
+
/** @type {Boolean} */
|
|
74
|
+
let _weboCtxInitialized = false;
|
|
75
|
+
|
|
76
|
+
/** @type {null|Object} */
|
|
77
|
+
let _weboUserDataUserProfile = null;
|
|
78
|
+
|
|
79
|
+
/** @type {Boolean} */
|
|
80
|
+
let _weboUserDataInitialized = false;
|
|
81
|
+
|
|
82
|
+
/** Initialize module
|
|
83
|
+
* @param {object} moduleConfig
|
|
84
|
+
* @return {Boolean} true if module was initialized with success
|
|
43
85
|
*/
|
|
44
|
-
function
|
|
86
|
+
function init(moduleConfig) {
|
|
45
87
|
moduleConfig = moduleConfig || {};
|
|
46
88
|
const moduleParams = moduleConfig.params || {};
|
|
47
89
|
const weboCtxConf = moduleParams.weboCtxConf || {};
|
|
48
|
-
const
|
|
49
|
-
const profile = _bigseaContextualProfile || defaultContextualProfiles;
|
|
90
|
+
const weboUserDataConf = moduleParams.weboUserDataConf;
|
|
50
91
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (profile[WEBO_CTX]) {
|
|
54
|
-
deepSetValue(ortb2, 'site.ext.data.webo_ctx', profile[WEBO_CTX]);
|
|
55
|
-
}
|
|
56
|
-
if (profile[WEBO_DS]) {
|
|
57
|
-
deepSetValue(ortb2, 'site.ext.data.webo_ds', profile[WEBO_DS]);
|
|
58
|
-
}
|
|
59
|
-
config.setConfig({ortb2: ortb2});
|
|
60
|
-
}
|
|
92
|
+
_weboCtxInitialized = initWeboCtx(weboCtxConf);
|
|
93
|
+
_weboUserDataInitialized = initWeboUserData(weboUserDataConf);
|
|
61
94
|
|
|
62
|
-
|
|
63
|
-
|
|
95
|
+
return _weboCtxInitialized || _weboUserDataInitialized;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Initialize contextual sub module
|
|
99
|
+
* @param {WeboCtxConf} weboCtxConf
|
|
100
|
+
* @return {Boolean} true if sub module was initialized with success
|
|
101
|
+
*/
|
|
102
|
+
function initWeboCtx(weboCtxConf) {
|
|
103
|
+
_weboCtxInitialized = false;
|
|
104
|
+
_weboContextualProfile = null;
|
|
105
|
+
|
|
106
|
+
if (!weboCtxConf.token) {
|
|
107
|
+
logError('missing param "token" for weborama contextual sub module initialization');
|
|
108
|
+
return false;
|
|
64
109
|
}
|
|
65
110
|
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Initialize weboUserData sub module
|
|
115
|
+
* @param {WeboUserDataConf} weboUserDataConf
|
|
116
|
+
* @return {Boolean} true if sub module was initialized with success
|
|
117
|
+
*/
|
|
118
|
+
function initWeboUserData(weboUserDataConf) {
|
|
119
|
+
_weboUserDataInitialized = false;
|
|
120
|
+
_weboUserDataUserProfile = null;
|
|
121
|
+
|
|
122
|
+
return !!weboUserDataConf;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** function that provides ad server targeting data to RTD-core
|
|
126
|
+
* @param {Array} adUnitsCodes
|
|
127
|
+
* @param {Object} moduleConfig
|
|
128
|
+
* @returns {Object} target data
|
|
129
|
+
*/
|
|
130
|
+
function getTargetingData(adUnitsCodes, moduleConfig) {
|
|
131
|
+
moduleConfig = moduleConfig || {};
|
|
132
|
+
const moduleParams = moduleConfig.params || {};
|
|
133
|
+
const weboCtxConf = moduleParams.weboCtxConf || {};
|
|
134
|
+
const weboUserDataConf = moduleParams.weboUserDataConf || {};
|
|
135
|
+
const weboCtxConfTargeting = weboCtxConf.setPrebidTargeting !== false;
|
|
136
|
+
const weboUserDataConfTargeting = weboUserDataConf.setPrebidTargeting !== false;
|
|
137
|
+
|
|
66
138
|
try {
|
|
67
|
-
const
|
|
68
|
-
|
|
139
|
+
const profile = getCompleteProfile(moduleParams, weboCtxConfTargeting, weboUserDataConfTargeting);
|
|
140
|
+
|
|
141
|
+
if (isEmpty(profile)) {
|
|
142
|
+
return {};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const td = adUnitsCodes.reduce((data, adUnitCode) => {
|
|
69
146
|
if (adUnitCode) {
|
|
70
|
-
|
|
147
|
+
data[adUnitCode] = profile;
|
|
71
148
|
}
|
|
72
|
-
return
|
|
149
|
+
return data;
|
|
73
150
|
}, {});
|
|
74
|
-
|
|
151
|
+
|
|
152
|
+
return td;
|
|
75
153
|
} catch (e) {
|
|
76
154
|
logError('unable to format weborama rtd targeting data', e);
|
|
77
155
|
return {};
|
|
78
156
|
}
|
|
79
157
|
}
|
|
80
158
|
|
|
159
|
+
/** function that provides complete profile formatted to be used
|
|
160
|
+
* @param {ModuleParams} moduleParams
|
|
161
|
+
* @param {Boolean} weboCtxConfTargeting
|
|
162
|
+
* @param {Boolean} weboUserDataConfTargeting
|
|
163
|
+
* @returns {Object} complete profile
|
|
164
|
+
*/
|
|
165
|
+
function getCompleteProfile(moduleParams, weboCtxConfTargeting, weboUserDataConfTargeting) {
|
|
166
|
+
const profile = {};
|
|
167
|
+
|
|
168
|
+
if (weboCtxConfTargeting) {
|
|
169
|
+
const contextualProfile = getContextualProfile(moduleParams.weboCtxConf || {});
|
|
170
|
+
mergeDeep(profile, contextualProfile);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (weboUserDataConfTargeting) {
|
|
174
|
+
const weboUserDataProfile = getWeboUserDataProfile(moduleParams.weboUserDataConf || {});
|
|
175
|
+
mergeDeep(profile, weboUserDataProfile);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return profile;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** return contextual profile
|
|
182
|
+
* @param {WeboCtxConf} weboCtxConf
|
|
183
|
+
* @returns {Object} contextual profile
|
|
184
|
+
*/
|
|
185
|
+
function getContextualProfile(weboCtxConf) {
|
|
186
|
+
const defaultContextualProfile = weboCtxConf.defaultProfile || {};
|
|
187
|
+
return _weboContextualProfile || defaultContextualProfile;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** return weboUserData profile
|
|
191
|
+
* @param {WeboUserDataConf} weboUserDataConf
|
|
192
|
+
* @returns {Object} weboUserData profile
|
|
193
|
+
*/
|
|
194
|
+
function getWeboUserDataProfile(weboUserDataConf) {
|
|
195
|
+
const weboUserDataDefaultUserProfile = weboUserDataConf.defaultProfile || {};
|
|
196
|
+
|
|
197
|
+
if (storage.localStorageIsEnabled() && !_weboUserDataUserProfile) {
|
|
198
|
+
const localStorageProfileKey = weboUserDataConf.localStorageProfileKey || DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY;
|
|
199
|
+
|
|
200
|
+
const entry = storage.getDataFromLocalStorage(localStorageProfileKey);
|
|
201
|
+
if (entry) {
|
|
202
|
+
const data = JSON.parse(entry);
|
|
203
|
+
if (data && Object.keys(data).length > 0) {
|
|
204
|
+
_weboUserDataUserProfile = data[LOCAL_STORAGE_USER_TARGETING_SECTION];
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return _weboUserDataUserProfile || weboUserDataDefaultUserProfile;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** function that will allow RTD sub-modules to modify the AdUnit object for each auction
|
|
213
|
+
* @param {Object} reqBidsConfigObj
|
|
214
|
+
* @param {doneCallback} onDone
|
|
215
|
+
* @param {Object} moduleConfig
|
|
216
|
+
* @returns {void}
|
|
217
|
+
*/
|
|
218
|
+
export function getBidRequestData(reqBidsConfigObj, onDone, moduleConfig) {
|
|
219
|
+
moduleConfig = moduleConfig || {};
|
|
220
|
+
const moduleParams = moduleConfig.params || {};
|
|
221
|
+
const weboCtxConf = moduleParams.weboCtxConf || {};
|
|
222
|
+
|
|
223
|
+
const adUnits = reqBidsConfigObj.adUnits || getGlobal().adUnits;
|
|
224
|
+
|
|
225
|
+
if (!_weboCtxInitialized) {
|
|
226
|
+
handleBidRequestData(adUnits, moduleParams);
|
|
227
|
+
|
|
228
|
+
onDone();
|
|
229
|
+
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
fetchContextualProfile(weboCtxConf, (data) => {
|
|
234
|
+
logMessage('fetchContextualProfile on getBidRequestData is done');
|
|
235
|
+
|
|
236
|
+
setWeboContextualProfile(data);
|
|
237
|
+
}, () => {
|
|
238
|
+
handleBidRequestData(adUnits, moduleParams);
|
|
239
|
+
|
|
240
|
+
onDone();
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** function that handles bid request data
|
|
245
|
+
* @param {Object[]} adUnits
|
|
246
|
+
* @param {ModuleParams} moduleParams
|
|
247
|
+
* @returns {void}
|
|
248
|
+
*/
|
|
249
|
+
|
|
250
|
+
function handleBidRequestData(adUnits, moduleParams) {
|
|
251
|
+
const weboCtxConf = moduleParams.weboCtxConf || {};
|
|
252
|
+
const weboUserDataConf = moduleParams.weboUserDataConf || {};
|
|
253
|
+
const weboCtxConfTargeting = weboCtxConf.sendToBidders !== false;
|
|
254
|
+
const weboUserDataConfTargeting = weboUserDataConf.sendToBidders !== false;
|
|
255
|
+
const profile = getCompleteProfile(moduleParams, weboCtxConfTargeting, weboUserDataConfTargeting);
|
|
256
|
+
|
|
257
|
+
if (isEmpty(profile)) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
adUnits.forEach(adUnit => {
|
|
262
|
+
if (adUnit.hasOwnProperty('bids')) {
|
|
263
|
+
adUnit.bids.forEach(bid => handleBid(adUnit, profile, bid));
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** @type {string} */
|
|
269
|
+
const SMARTADSERVER = 'smartadserver';
|
|
270
|
+
|
|
271
|
+
/** @type {Object} */
|
|
272
|
+
const bidderAliasRegistry = adapterManager.aliasRegistry || {};
|
|
273
|
+
|
|
274
|
+
/** handle individual bid
|
|
275
|
+
* @param {Object} adUnit
|
|
276
|
+
* @param {Object} profile
|
|
277
|
+
* @param {Object} bid
|
|
278
|
+
* @returns {void}
|
|
279
|
+
*/
|
|
280
|
+
function handleBid(adUnit, profile, bid) {
|
|
281
|
+
const bidder = bidderAliasRegistry[bid.bidder] || bid.bidder;
|
|
282
|
+
|
|
283
|
+
logMessage('handle bidder', bidder, bid);
|
|
284
|
+
|
|
285
|
+
switch (bidder) {
|
|
286
|
+
case SMARTADSERVER:
|
|
287
|
+
handleSmartadserverBid(adUnit, profile, bid);
|
|
288
|
+
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** handle smartadserver bid
|
|
294
|
+
* @param {Object} adUnit
|
|
295
|
+
* @param {Object} profile
|
|
296
|
+
* @param {Object} bid
|
|
297
|
+
* @returns {void}
|
|
298
|
+
*/
|
|
299
|
+
function handleSmartadserverBid(adUnit, profile, bid) {
|
|
300
|
+
const target = [];
|
|
301
|
+
|
|
302
|
+
if (deepAccess(bid, 'params.target')) {
|
|
303
|
+
target.push(bid.params.target.split(';'));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
Object.keys(profile).forEach(key => {
|
|
307
|
+
profile[key].forEach(value => {
|
|
308
|
+
const keyword = `${key}=${value}`;
|
|
309
|
+
if (target.indexOf(keyword) === -1) {
|
|
310
|
+
target.push(keyword);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
deepSetValue(bid, 'params.target', target.join(';'));
|
|
316
|
+
}
|
|
317
|
+
|
|
81
318
|
/** set bigsea contextual profile on module state
|
|
82
|
-
* if the profile is empty, will store the default profile
|
|
83
319
|
* @param {null|Object} data
|
|
84
320
|
* @returns {void}
|
|
85
321
|
*/
|
|
86
|
-
export function
|
|
322
|
+
export function setWeboContextualProfile(data) {
|
|
87
323
|
if (data && Object.keys(data).length > 0) {
|
|
88
|
-
|
|
324
|
+
_weboContextualProfile = data;
|
|
89
325
|
}
|
|
90
326
|
}
|
|
91
327
|
|
|
@@ -96,9 +332,9 @@ export function setBigseaContextualProfile(data) {
|
|
|
96
332
|
*/
|
|
97
333
|
|
|
98
334
|
/** onDone callback type
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
335
|
+
* @callback doneCallback
|
|
336
|
+
* @returns {void}
|
|
337
|
+
*/
|
|
102
338
|
|
|
103
339
|
/** Fetch Bigsea Contextual Profile
|
|
104
340
|
* @param {WeboCtxConf} weboCtxConf
|
|
@@ -117,7 +353,7 @@ function fetchContextualProfile(weboCtxConf, onSuccess, onDone) {
|
|
|
117
353
|
const url = 'https://ctx.weborama.com/api/profile?' + queryString;
|
|
118
354
|
|
|
119
355
|
ajax(url, {
|
|
120
|
-
success: function
|
|
356
|
+
success: function(response, req) {
|
|
121
357
|
if (req.status === 200) {
|
|
122
358
|
try {
|
|
123
359
|
const data = JSON.parse(response);
|
|
@@ -126,49 +362,28 @@ function fetchContextualProfile(weboCtxConf, onSuccess, onDone) {
|
|
|
126
362
|
} catch (e) {
|
|
127
363
|
onDone();
|
|
128
364
|
logError('unable to parse weborama data', e);
|
|
365
|
+
throw e;
|
|
129
366
|
}
|
|
130
367
|
} else if (req.status === 204) {
|
|
131
368
|
onDone();
|
|
132
369
|
}
|
|
133
370
|
},
|
|
134
|
-
error: function
|
|
371
|
+
error: function() {
|
|
135
372
|
onDone();
|
|
136
373
|
logError('unable to get weborama data');
|
|
137
374
|
}
|
|
138
375
|
},
|
|
139
|
-
null,
|
|
140
|
-
{
|
|
376
|
+
null, {
|
|
141
377
|
method: 'GET',
|
|
142
378
|
withCredentials: false,
|
|
143
379
|
});
|
|
144
380
|
}
|
|
145
381
|
|
|
146
|
-
/** Initialize module
|
|
147
|
-
* @param {object} moduleConfig
|
|
148
|
-
* @return {boolean} true if module was initialized with success
|
|
149
|
-
*/
|
|
150
|
-
function init(moduleConfig) {
|
|
151
|
-
_bigseaContextualProfile = null;
|
|
152
|
-
|
|
153
|
-
moduleConfig = moduleConfig || {};
|
|
154
|
-
const moduleParams = moduleConfig.params || {};
|
|
155
|
-
const weboCtxConf = moduleParams.weboCtxConf || {};
|
|
156
|
-
|
|
157
|
-
if (weboCtxConf.token) {
|
|
158
|
-
fetchContextualProfile(weboCtxConf, setBigseaContextualProfile,
|
|
159
|
-
() => logMessage('fetchContextualProfile on init is done'));
|
|
160
|
-
} else {
|
|
161
|
-
logError('missing param "token" for weborama rtd module initialization');
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
382
|
export const weboramaSubmodule = {
|
|
169
383
|
name: SUBMODULE_NAME,
|
|
170
384
|
init: init,
|
|
171
385
|
getTargetingData: getTargetingData,
|
|
386
|
+
getBidRequestData: getBidRequestData,
|
|
172
387
|
};
|
|
173
388
|
|
|
174
389
|
submodule(MODULE_NAME, weboramaSubmodule);
|
|
@@ -10,8 +10,6 @@ Maintainer: prebid-support@weborama.com
|
|
|
10
10
|
|
|
11
11
|
Weborama provides a Semantic AI Contextual API that classifies in Real-time a web page seen by a web user within generic and custom topics. It enables publishers to better monetize their inventory and unlock it to programmatic.
|
|
12
12
|
|
|
13
|
-
ORTB2 compliant and FPD support for Prebid versions < 4.29
|
|
14
|
-
|
|
15
13
|
Contact prebid-support@weborama.com for information.
|
|
16
14
|
|
|
17
15
|
### Publisher Usage
|
|
@@ -32,17 +30,31 @@ pbjs.setConfig(
|
|
|
32
30
|
name: "weborama",
|
|
33
31
|
waitForIt: true,
|
|
34
32
|
params: {
|
|
35
|
-
weboCtxConf: {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
weboCtxConf: { // contextual configuration
|
|
34
|
+
token: "<<provided by weborama>>", // mandatory
|
|
35
|
+
targetURL: "...", // default is document.URL
|
|
36
|
+
setPrebidTargeting: true, // default
|
|
37
|
+
sendToBidders: true, // default
|
|
38
|
+
defaultProfile: { // optional, default is none
|
|
39
|
+
webo_ctx: ['foo'],
|
|
40
|
+
webo_ds: ['bar']
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
weboUserDataConf: { // user-centric configuration
|
|
44
|
+
setPrebidTargeting: true, // default
|
|
45
|
+
sendToBidders: true, // default
|
|
46
|
+
defaultProfile: { // optional, default is none
|
|
47
|
+
webo_cs: ['baz'],
|
|
48
|
+
webo_audiences: ['bam']
|
|
49
|
+
},
|
|
50
|
+
localStorageProfileKey: 'webo_wam2gam_entry' // default
|
|
39
51
|
}
|
|
40
52
|
}
|
|
41
53
|
}
|
|
42
54
|
]
|
|
43
55
|
}
|
|
44
56
|
...
|
|
45
|
-
|
|
57
|
+
);
|
|
46
58
|
```
|
|
47
59
|
|
|
48
60
|
### Parameter Descriptions for the Weborama Configuration Section
|
|
@@ -55,15 +67,20 @@ pbjs.setConfig(
|
|
|
55
67
|
| params.weboCtxConf | Object | Weborama Contextual Configuration | Optional |
|
|
56
68
|
| params.weboCtxConf.token | String | Security Token provided by Weborama, unique per client | Mandatory |
|
|
57
69
|
| params.weboCtxConf.targetURL | String | Url to be profiled in the contextual api | Optional. Defaults to `document.URL` |
|
|
70
|
+
| params.weboCtxConf.setPrebidTargeting|Boolean|If true, will use the contextual profile to set the prebid (GPT/GAM or AST) targeting of all adunits managed by prebid.js| Optional. Default is *true*.|
|
|
71
|
+
| params.weboCtxConf.sendToBidders|Boolean|If true, will send the contextual profile to all bidders (only smartadserver is supported now)| Optional. Default is *true*.|
|
|
58
72
|
| params.weboCtxConf.defaultProfile | Object | default value of the profile to be used when there are no response from contextual api (such as timeout)| Optional. Default is `{}` |
|
|
59
|
-
| params.
|
|
60
|
-
| params.
|
|
73
|
+
| params.weboUserDataConf | Object | WeboUserData Configuration | Optional |
|
|
74
|
+
| params.weboUserDataConf.setPrebidTargeting|Boolean|If true, will use the contextual profile to set the prebid (GPT/GAM or AST) targeting of all adunits managed by prebid.js| Optional. Default is *true*.|
|
|
75
|
+
| params.weboUserDataConf.sendToBidders|Boolean|If true, will send the contextual profile to all bidders (only smartadserver is supported now)| Optional. Default is *true*.|
|
|
76
|
+
| params.weboUserDataConf.defaultProfile | Object | default value of the profile to be used when there are no response from contextual api (such as timeout)| Optional. Default is `{}` |
|
|
77
|
+
| params.weboUserDataConf.localStorageProfileKey| String | can be used to customize the local storage key | Optional |
|
|
61
78
|
|
|
62
79
|
### Testing
|
|
63
80
|
|
|
64
81
|
To view an example of available segments returned by Weborama's backends:
|
|
65
82
|
|
|
66
|
-
`gulp serve --modules=rtdModule,weboramaRtdProvider,
|
|
83
|
+
`gulp serve --modules=rtdModule,weboramaRtdProvider,smartadserverBidAdapter`
|
|
67
84
|
|
|
68
85
|
and then point your browser at:
|
|
69
86
|
|