prebid.js 7.22.0 → 7.24.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/dist/33acrossBidAdapter.js +1 -1
- package/dist/aaxBlockmeterRtdProvider.js +1 -0
- package/dist/adagioBidAdapter.js +1 -1
- package/dist/adbookpspBidAdapter.js +1 -1
- package/dist/adgenerationBidAdapter.js +1 -1
- package/dist/admaticBidAdapter.js +1 -0
- package/dist/adrelevantisBidAdapter.js +1 -1
- package/dist/adtrgtmeBidAdapter.js +1 -1
- package/dist/adxcgBidAdapter.js +1 -1
- package/dist/adyoulikeBidAdapter.js +1 -1
- package/dist/ajaBidAdapter.js +1 -1
- package/dist/amxBidAdapter.js +1 -1
- package/dist/amxIdSystem.js +1 -1
- package/dist/analyticsAdapter.js +1 -1
- package/dist/appierAnalyticsAdapter.js +1 -1
- package/dist/appnexusBidAdapter.js +1 -1
- package/dist/asoBidAdapter.js +1 -1
- package/dist/audiencerunBidAdapter.js +1 -1
- package/dist/axonixBidAdapter.js +1 -1
- package/dist/bidViewability.js +1 -1
- package/dist/bidViewabilityIO.js +1 -1
- package/dist/bidglassBidAdapter.js +1 -1
- package/dist/big-richmediaBidAdapter.js +1 -1
- package/dist/bluebillywigBidAdapter.js +1 -1
- package/dist/bridgewellBidAdapter.js +1 -1
- package/dist/brightMountainMediaBidAdapter.js +1 -1
- package/dist/browsiRtdProvider.js +1 -1
- package/dist/carodaBidAdapter.js +1 -1
- package/dist/chtnwBidAdapter.js +1 -0
- package/dist/cleanioRtdProvider.js +1 -1
- package/dist/concertBidAdapter.js +1 -1
- package/dist/connectIdSystem.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/craftBidAdapter.js +1 -1
- package/dist/criteoBidAdapter.js +1 -1
- package/dist/currency.js +1 -1
- package/dist/dependencies.json +19 -0
- package/dist/dfpAdServerVideo.js +1 -1
- package/dist/dgkeywordRtdProvider.js +1 -1
- package/dist/dspxBidAdapter.js +1 -1
- package/dist/eplanningBidAdapter.js +1 -1
- package/dist/finativeBidAdapter.js +1 -1
- package/dist/gdprEnforcement.js +1 -1
- package/dist/glimpseBidAdapter.js +1 -1
- package/dist/gmosspBidAdapter.js +1 -1
- package/dist/goldbachBidAdapter.js +1 -1
- package/dist/googleAnalyticsAdapter.js +1 -1
- package/dist/gridBidAdapter.js +1 -1
- package/dist/gridNMBidAdapter.js +1 -1
- package/dist/growthCodeIdSystem.js +1 -1
- package/dist/gumgumBidAdapter.js +1 -1
- package/dist/h12mediaBidAdapter.js +1 -1
- package/dist/id5AnalyticsAdapter.js +1 -1
- package/dist/id5IdSystem.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/instreamTracking.js +1 -1
- package/dist/ixBidAdapter.js +1 -1
- package/dist/jixieBidAdapter.js +1 -1
- package/dist/justpremiumBidAdapter.js +1 -1
- package/dist/jwplayerVideoProvider.js +1 -0
- package/dist/kargoBidAdapter.js +1 -1
- package/dist/konduitAnalyticsAdapter.js +1 -1
- package/dist/kueezBidAdapter.js +1 -1
- package/dist/kueezRtbBidAdapter.js +1 -0
- package/dist/lassoBidAdapter.js +1 -1
- package/dist/lifestreetBidAdapter.js +1 -1
- package/dist/liveyieldAnalyticsAdapter.js +1 -1
- package/dist/logicadBidAdapter.js +1 -1
- package/dist/loglyliftBidAdapter.js +1 -1
- package/dist/magniteAnalyticsAdapter.js +1 -1
- package/dist/malltvAnalyticsAdapter.js +1 -1
- package/dist/marsmediaBidAdapter.js +1 -1
- package/dist/mediafuseBidAdapter.js +1 -1
- package/dist/mediakeysBidAdapter.js +1 -1
- package/dist/mediasquareBidAdapter.js +1 -1
- package/dist/mgidBidAdapter.js +1 -1
- package/dist/mgidRtdProvider.js +1 -0
- package/dist/minutemediaBidAdapter.js +1 -1
- package/dist/multibid.js +1 -1
- package/dist/not-for-prod/prebid.js +153 -141
- package/dist/oguryBidAdapter.js +1 -1
- package/dist/onetagBidAdapter.js +1 -1
- package/dist/ooloAnalyticsAdapter.js +1 -1
- package/dist/openxOrtbBidAdapter.js +1 -1
- package/dist/ortbConverter.js +1 -0
- package/dist/outbrainBidAdapter.js +1 -1
- package/dist/oxxionRtdProvider.js +1 -0
- package/dist/parrableIdSystem.js +1 -1
- package/dist/pbsExtensions.js +1 -0
- package/dist/permutiveRtdProvider.js +1 -1
- package/dist/pixfutureBidAdapter.js +1 -1
- package/dist/prebid-core.js +1 -1
- package/dist/prebidServerBidAdapter.js +1 -1
- package/dist/priceFloors.js +1 -1
- package/dist/pubCommonId.js +1 -1
- package/dist/publinkIdSystem.js +1 -1
- package/dist/pubmaticBidAdapter.js +1 -1
- package/dist/pubwiseAnalyticsAdapter.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/schain.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/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/sublimeBidAdapter.js +1 -1
- package/dist/synacormediaBidAdapter.js +1 -1
- package/dist/targetVideoBidAdapter.js +1 -1
- package/dist/teadsBidAdapter.js +1 -1
- package/dist/teadsIdSystem.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/underdogmediaBidAdapter.js +1 -1
- package/dist/undertoneBidAdapter.js +1 -1
- package/dist/userId.js +1 -1
- package/dist/vidazooBidAdapter.js +1 -1
- package/dist/video.js +1 -0
- package/dist/videoModule.js +1 -0
- package/dist/videobyteBidAdapter.js +1 -1
- package/dist/videojsVideoProvider.js +1 -0
- package/dist/visxBidAdapter.js +1 -1
- package/dist/vuukleBidAdapter.js +1 -1
- package/dist/widespaceBidAdapter.js +1 -1
- package/dist/winrBidAdapter.js +1 -1
- package/dist/yahoosspBidAdapter.js +1 -1
- package/dist/yieldmoBidAdapter.js +1 -1
- package/dist/yieldoneAnalyticsAdapter.js +1 -1
- package/integrationExamples/gpt/mgidRtdProvider_example.html +143 -0
- package/integrationExamples/videoModule/jwplayer/bidMarkedAsUsed.html +98 -0
- package/integrationExamples/videoModule/jwplayer/bidRequestScheduling.html +89 -0
- package/integrationExamples/videoModule/jwplayer/eventListeners.html +244 -0
- package/integrationExamples/videoModule/jwplayer/gamAdServerMediation.html +122 -0
- package/integrationExamples/videoModule/jwplayer/mediaMetadata.html +80 -0
- package/integrationExamples/videoModule/jwplayer/playlist.html +122 -0
- package/integrationExamples/videoModule/videojs/bidMarkedAsUsed.html +126 -0
- package/integrationExamples/videoModule/videojs/bidRequestScheduling.html +132 -0
- package/integrationExamples/videoModule/videojs/eventListeners.html +238 -0
- package/integrationExamples/videoModule/videojs/gamAdServerMediation.html +138 -0
- package/integrationExamples/videoModule/videojs/mediaMetadata.html +103 -0
- package/integrationExamples/videoModule/videojs/playlist.html +151 -0
- package/libraries/ortbConverter/README.md +378 -0
- package/libraries/ortbConverter/converter.js +135 -0
- package/libraries/ortbConverter/lib/composer.js +43 -0
- package/libraries/ortbConverter/lib/mergeProcessors.js +9 -0
- package/libraries/ortbConverter/lib/sizes.js +14 -0
- package/libraries/ortbConverter/processors/banner.js +40 -0
- package/libraries/ortbConverter/processors/default.js +167 -0
- package/libraries/ortbConverter/processors/mediaType.js +21 -0
- package/libraries/ortbConverter/processors/native.js +37 -0
- package/libraries/ortbConverter/processors/video.js +66 -0
- package/libraries/pbsExtensions/pbsExtensions.js +12 -0
- package/libraries/pbsExtensions/processors/aliases.js +17 -0
- package/libraries/pbsExtensions/processors/mediaType.js +23 -0
- package/libraries/pbsExtensions/processors/params.js +22 -0
- package/libraries/pbsExtensions/processors/pbs.js +99 -0
- package/libraries/pbsExtensions/processors/requestExtPrebid.js +30 -0
- package/libraries/pbsExtensions/processors/video.js +23 -0
- package/libraries/video/constants/enums.js +5 -0
- package/libraries/video/constants/events.js +97 -0
- package/libraries/video/constants/ortb.js +169 -0
- package/libraries/video/constants/vendorCodes.js +6 -0
- package/libraries/video/shared/eventHandler.js +18 -0
- package/libraries/video/shared/parentModule.js +82 -0
- package/libraries/video/shared/state.js +47 -0
- package/libraries/video/shared/vastXmlBuilder.js +77 -0
- package/libraries/video/shared/vastXmlEditor.js +115 -0
- package/modules/.submodules.json +7 -1
- package/modules/aaxBlockmeterRtdProvider.js +59 -0
- package/modules/aaxBlockmeterRtdProvider.md +48 -0
- package/modules/admaticBidAdapter.js +147 -0
- package/modules/admaticBidAdapter.md +48 -0
- package/modules/amxBidAdapter.js +1 -0
- package/modules/appnexusBidAdapter.js +38 -1
- package/modules/chtnwBidAdapter.js +110 -0
- package/modules/chtnwBidAdapter.md +31 -0
- package/modules/concertBidAdapter.js +44 -2
- package/modules/connectIdSystem.js +36 -23
- package/modules/connectIdSystem.md +3 -2
- package/modules/consentManagement.js +22 -1
- package/modules/consentManagementUsp.js +29 -7
- package/modules/criteoBidAdapter.js +25 -5
- package/modules/currency.js +9 -0
- package/modules/dgkeywordRtdProvider.js +3 -3
- package/modules/gridNMBidAdapter.js +10 -14
- package/modules/growthCodeIdSystem.js +9 -5
- package/modules/gumgumBidAdapter.js +4 -0
- package/modules/improvedigitalBidAdapter.js +191 -470
- package/modules/ixBidAdapter.js +54 -71
- package/modules/jwplayerVideoProvider.js +929 -0
- package/modules/jwplayerVideoProvider.md +25 -0
- package/modules/kargoBidAdapter.js +1 -1
- package/modules/kueezRtbBidAdapter.js +278 -0
- package/modules/kueezRtbBidAdapter.md +35 -0
- package/modules/magniteAnalyticsAdapter.js +6 -1
- package/modules/mgidRtdProvider.js +190 -0
- package/modules/mgidRtdProvider.md +51 -0
- package/modules/multibid/index.js +12 -0
- package/modules/openxOrtbBidAdapter.js +120 -275
- package/modules/oxxionRtdProvider.js +119 -0
- package/modules/oxxionRtdProvider.md +48 -0
- package/modules/permutiveRtdProvider.js +2 -1
- package/modules/permutiveRtdProvider.md +36 -1
- package/modules/prebidServerBidAdapter/index.js +19 -716
- package/modules/prebidServerBidAdapter/ortbConverter.js +274 -0
- package/modules/priceFloors.js +73 -1
- package/modules/pubmaticBidAdapter.js +21 -29
- package/modules/rtdModule/index.js +22 -1
- package/modules/schain.js +24 -1
- package/modules/spotxBidAdapter.js +16 -15
- package/modules/synacormediaBidAdapter.js +1 -1
- package/modules/teadsIdSystem.js +5 -0
- package/modules/tripleliftBidAdapter.js +1 -1
- package/modules/userId/eids.js +3 -10
- package/modules/userId/index.js +64 -6
- package/modules/videoModule/addingSubmodule.md +521 -0
- package/modules/videoModule/coreVideo.js +234 -0
- package/modules/videoModule/gamAdServerSubmodule.js +27 -0
- package/modules/videoModule/index.js +244 -0
- package/modules/videoModule/videoImpressionVerifier.js +206 -0
- package/modules/videojsVideoProvider.js +854 -0
- package/modules/videojsVideoProvider.md +17 -0
- package/package.json +12 -8
- package/src/adRendering.js +1 -1
- package/src/adapterManager.js +56 -7
- package/src/adloader.js +3 -1
- package/src/auction.js +6 -1
- package/src/events.js +5 -1
- package/src/pbjsORTB.js +35 -0
- package/src/prebid.js +137 -112
- package/src/targeting.js +10 -2
- package/src/utils/currency.js +16 -0
- package/src/utils.js +21 -0
- package/test/spec/auctionmanager_spec.js +15 -0
- package/test/spec/modules/aaxBlockmeter_spec.js +58 -0
- package/test/spec/modules/admaticBidAdapter_spec.js +46 -0
- package/test/spec/modules/chtnwBidAdapter_spec.js +105 -0
- package/test/spec/modules/concertBidAdapter_spec.js +56 -0
- package/test/spec/modules/connectIdSystem_spec.js +175 -5
- package/test/spec/modules/consentManagementUsp_spec.js +64 -18
- package/test/spec/modules/criteoBidAdapter_spec.js +28 -0
- package/test/spec/modules/dgkeywordRtdProvider_spec.js +3 -3
- package/test/spec/modules/eids_spec.js +10 -7
- package/test/spec/modules/ftrackIdSystem_spec.js +34 -22
- package/test/spec/modules/gumgumBidAdapter_spec.js +15 -0
- package/test/spec/modules/improvedigitalBidAdapter_spec.js +231 -211
- package/test/spec/modules/ixBidAdapter_spec.js +412 -350
- package/test/spec/modules/kueezRtbBidAdapter_spec.js +396 -0
- package/test/spec/modules/magniteAnalyticsAdapter_spec.js +26 -0
- package/test/spec/modules/mgidRtdProvider_spec.js +366 -0
- package/test/spec/modules/openxOrtbBidAdapter_spec.js +77 -49
- package/test/spec/modules/oxxionRtdProvider_spec.js +142 -0
- package/test/spec/modules/permutiveRtdProvider_spec.js +64 -5
- package/test/spec/modules/prebidServerBidAdapter_spec.js +139 -137
- package/test/spec/modules/realTimeDataModule_spec.js +65 -0
- package/test/spec/modules/tripleliftBidAdapter_spec.js +14 -0
- package/test/spec/modules/userId_spec.js +67 -1
- package/test/spec/modules/videoModule/coreVideo_spec.js +98 -0
- package/test/spec/modules/videoModule/pbVideo_spec.js +362 -0
- package/test/spec/modules/videoModule/shared/parentModule_spec.js +73 -0
- package/test/spec/modules/videoModule/shared/state_spec.js +26 -0
- package/test/spec/modules/videoModule/shared/vastXmlBuilder_spec.js +103 -0
- package/test/spec/modules/videoModule/shared/vastXmlEditor_spec.js +209 -0
- package/test/spec/modules/videoModule/submodules/jwplayerVideoProvider_spec.js +846 -0
- package/test/spec/modules/videoModule/submodules/videojsVideoProvider_spec.js +391 -0
- package/test/spec/modules/videoModule/videoImpressionVerifier_spec.js +112 -0
- package/test/spec/ortbConverter/banner_spec.js +203 -0
- package/test/spec/ortbConverter/composer_spec.js +69 -0
- package/test/spec/ortbConverter/converter_spec.js +283 -0
- package/test/spec/ortbConverter/currency_spec.js +40 -0
- package/test/spec/ortbConverter/default_processors_spec.js +61 -0
- package/test/spec/ortbConverter/gdpr_spec.js +38 -0
- package/test/spec/ortbConverter/mediaTypes_spec.js +67 -0
- package/test/spec/ortbConverter/mergeProcessors_spec.js +59 -0
- package/test/spec/ortbConverter/multibid_spec.js +35 -0
- package/test/spec/ortbConverter/native_spec.js +95 -0
- package/test/spec/ortbConverter/pbjsORTB_spec.js +67 -0
- package/test/spec/ortbConverter/pbsExtensions/aliases_spec.js +57 -0
- package/test/spec/ortbConverter/pbsExtensions/params_spec.js +96 -0
- package/test/spec/ortbConverter/pbsExtensions/video_spec.js +52 -0
- package/test/spec/ortbConverter/priceFloors_spec.js +143 -0
- package/test/spec/ortbConverter/schain_spec.js +33 -0
- package/test/spec/ortbConverter/userId_spec.js +21 -0
- package/test/spec/ortbConverter/usp_spec.js +15 -0
- package/test/spec/ortbConverter/video_spec.js +189 -0
- package/test/spec/unit/core/adapterManager_spec.js +102 -0
- package/test/spec/unit/core/targeting_spec.js +34 -0
- package/test/spec/unit/pbjs_api_spec.js +124 -45
- package/test/spec/utils_spec.js +45 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const SORTED = new WeakMap();
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {Object} Component
|
|
5
|
+
* A component function, that can be composed with other compatible functions into one.
|
|
6
|
+
* Compatible functions take the same arguments; return values are ignored.
|
|
7
|
+
*
|
|
8
|
+
* @property {function} fn the component function;
|
|
9
|
+
* @property {number} priority determines the order in which this function will run when composed with others.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {Object[string, Component]} components to compose
|
|
15
|
+
* @param {Object[string, function|boolean]} overrides a map from component name, to a function that should override that component.
|
|
16
|
+
* Override functions are replacements, except that they get the original function they are overriding as their first argument. If the override
|
|
17
|
+
* is `false`, the component is disabled.
|
|
18
|
+
*
|
|
19
|
+
* @return a function that will run all components in order of priority, with functions from `overrides` taking
|
|
20
|
+
* precedence over components that match names
|
|
21
|
+
*/
|
|
22
|
+
export function compose(components, overrides = {}) {
|
|
23
|
+
if (!SORTED.has(components)) {
|
|
24
|
+
const sorted = Object.entries(components);
|
|
25
|
+
sorted.sort((a, b) => {
|
|
26
|
+
a = a[1].priority || 0;
|
|
27
|
+
b = b[1].priority || 0;
|
|
28
|
+
return a === b ? 0 : a > b ? -1 : 1
|
|
29
|
+
});
|
|
30
|
+
SORTED.set(components, sorted.map(([name, cmp]) => [name, cmp.fn]))
|
|
31
|
+
}
|
|
32
|
+
const fns = SORTED.get(components)
|
|
33
|
+
.filter(([name]) => !overrides.hasOwnProperty(name) || overrides[name])
|
|
34
|
+
.map(function ([name, fn]) {
|
|
35
|
+
return overrides.hasOwnProperty(name) ? overrides[name].bind(this, fn) : fn;
|
|
36
|
+
});
|
|
37
|
+
return function () {
|
|
38
|
+
const args = Array.from(arguments);
|
|
39
|
+
fns.forEach(fn => {
|
|
40
|
+
fn.apply(this, args);
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import {PROCESSOR_TYPES} from '../../../src/pbjsORTB.js';
|
|
2
|
+
|
|
3
|
+
export function mergeProcessors(...processors) {
|
|
4
|
+
const left = processors.shift();
|
|
5
|
+
const right = processors.length > 1 ? mergeProcessors(...processors) : processors[0];
|
|
6
|
+
return Object.fromEntries(
|
|
7
|
+
PROCESSOR_TYPES.map(type => [type, Object.assign({}, left[type], right[type])])
|
|
8
|
+
)
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {parseSizesInput} from '../../../src/utils.js';
|
|
2
|
+
|
|
3
|
+
export function sizesToFormat(sizes) {
|
|
4
|
+
sizes = parseSizesInput(sizes);
|
|
5
|
+
|
|
6
|
+
// get sizes in form [{ w: <int>, h: <int> }, ...]
|
|
7
|
+
return sizes.map(size => {
|
|
8
|
+
const [width, height] = size.split('x');
|
|
9
|
+
return {
|
|
10
|
+
w: parseInt(width, 10),
|
|
11
|
+
h: parseInt(height, 10)
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {createTrackPixelHtml, deepAccess, inIframe, mergeDeep} from '../../../src/utils.js';
|
|
2
|
+
import {BANNER} from '../../../src/mediaTypes.js';
|
|
3
|
+
import {sizesToFormat} from '../lib/sizes.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* fill in a request `imp` with banner parameters from `bidRequest`.
|
|
7
|
+
*/
|
|
8
|
+
export function fillBannerImp(imp, bidRequest, context) {
|
|
9
|
+
if (context.mediaType && context.mediaType !== BANNER) return;
|
|
10
|
+
|
|
11
|
+
const bannerParams = deepAccess(bidRequest, 'mediaTypes.banner');
|
|
12
|
+
if (bannerParams) {
|
|
13
|
+
const banner = {
|
|
14
|
+
topframe: inIframe() === true ? 0 : 1
|
|
15
|
+
};
|
|
16
|
+
if (bannerParams.sizes) {
|
|
17
|
+
banner.format = sizesToFormat(bannerParams.sizes);
|
|
18
|
+
}
|
|
19
|
+
if (bannerParams.hasOwnProperty('pos')) {
|
|
20
|
+
banner.pos = bannerParams.pos;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
imp.banner = mergeDeep(banner, imp.banner);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function bannerResponseProcessor({createPixel = (url) => createTrackPixelHtml(decodeURIComponent(url))} = {}) {
|
|
28
|
+
return function fillBannerResponse(bidResponse, bid) {
|
|
29
|
+
if (bidResponse.mediaType === BANNER) {
|
|
30
|
+
if (bid.adm && bid.nurl) {
|
|
31
|
+
bidResponse.ad = bid.adm;
|
|
32
|
+
bidResponse.ad += createPixel(bid.nurl);
|
|
33
|
+
} else if (bid.adm) {
|
|
34
|
+
bidResponse.ad = bid.adm;
|
|
35
|
+
} else if (bid.nurl) {
|
|
36
|
+
bidResponse.adUrl = bid.nurl;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import {deepSetValue, getDefinedParams, getDNT, mergeDeep} from '../../../src/utils.js';
|
|
2
|
+
import {bannerResponseProcessor, fillBannerImp} from './banner.js';
|
|
3
|
+
import {fillVideoImp, fillVideoResponse} from './video.js';
|
|
4
|
+
import {setResponseMediaType} from './mediaType.js';
|
|
5
|
+
import {fillNativeImp, fillNativeResponse} from './native.js';
|
|
6
|
+
import {BID_RESPONSE, IMP, REQUEST} from '../../../src/pbjsORTB.js';
|
|
7
|
+
import {config} from '../../../src/config.js';
|
|
8
|
+
|
|
9
|
+
export const DEFAULT_PROCESSORS = {
|
|
10
|
+
[REQUEST]: {
|
|
11
|
+
fpd: {
|
|
12
|
+
// sets initial request to bidderRequest.ortb2
|
|
13
|
+
priority: 99,
|
|
14
|
+
fn(ortbRequest, bidderRequest) {
|
|
15
|
+
mergeDeep(ortbRequest, bidderRequest.ortb2)
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
// override FPD app, site, and device with getConfig('app'), etc if defined
|
|
19
|
+
// TODO: these should be deprecated for v8
|
|
20
|
+
appFpd: fpdFromTopLevelConfig('app'),
|
|
21
|
+
siteFpd: fpdFromTopLevelConfig('site'),
|
|
22
|
+
deviceFpd: fpdFromTopLevelConfig('device'),
|
|
23
|
+
device: {
|
|
24
|
+
// sets device w / h / ua / language
|
|
25
|
+
fn: setDevice
|
|
26
|
+
},
|
|
27
|
+
site: {
|
|
28
|
+
// sets site.domain, page, and ref from refererInfo
|
|
29
|
+
fn: setSite
|
|
30
|
+
},
|
|
31
|
+
props: {
|
|
32
|
+
// sets request properties id, tmax, test, source.tid
|
|
33
|
+
fn(ortbRequest, bidderRequest) {
|
|
34
|
+
Object.assign(ortbRequest, {
|
|
35
|
+
id: ortbRequest.id || bidderRequest.auctionId,
|
|
36
|
+
test: ortbRequest.test || 0
|
|
37
|
+
});
|
|
38
|
+
const timeout = parseInt(bidderRequest.timeout, 10);
|
|
39
|
+
if (!isNaN(timeout)) {
|
|
40
|
+
ortbRequest.tmax = timeout;
|
|
41
|
+
}
|
|
42
|
+
deepSetValue(ortbRequest, 'source.tid', ortbRequest.source?.tid || bidderRequest.auctionId);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
coppa: {
|
|
46
|
+
fn(ortbRequest) {
|
|
47
|
+
const coppa = config.getConfig('coppa');
|
|
48
|
+
if (typeof coppa === 'boolean') {
|
|
49
|
+
deepSetValue(ortbRequest, 'regs.coppa', coppa ? 1 : 0);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
[IMP]: {
|
|
55
|
+
fpd: {
|
|
56
|
+
// sets initial imp to bidRequest.ortb2Imp
|
|
57
|
+
priority: 99,
|
|
58
|
+
fn(imp, bidRequest) {
|
|
59
|
+
mergeDeep(imp, bidRequest.ortb2Imp);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
id: {
|
|
63
|
+
// sets imp.id
|
|
64
|
+
fn(imp, bidRequest) {
|
|
65
|
+
imp.id = bidRequest.bidId;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
banner: {
|
|
69
|
+
// populates imp.banner
|
|
70
|
+
fn: fillBannerImp
|
|
71
|
+
},
|
|
72
|
+
video: {
|
|
73
|
+
// populates imp.video
|
|
74
|
+
fn: fillVideoImp
|
|
75
|
+
},
|
|
76
|
+
pbadslot: {
|
|
77
|
+
// removes imp.ext.data.pbaslot if it's not a string
|
|
78
|
+
// TODO: is this needed?
|
|
79
|
+
fn(imp) {
|
|
80
|
+
const pbadslot = imp.ext?.data?.pbadslot;
|
|
81
|
+
if (!pbadslot || typeof pbadslot !== 'string') {
|
|
82
|
+
delete imp.ext?.data?.pbadslot;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
[BID_RESPONSE]: {
|
|
88
|
+
mediaType: {
|
|
89
|
+
// sets bidResponse.mediaType from context.mediaType, falling back to seatbid.bid[].mtype
|
|
90
|
+
priority: 99,
|
|
91
|
+
fn: setResponseMediaType
|
|
92
|
+
},
|
|
93
|
+
banner: {
|
|
94
|
+
// sets banner response attributes if bidResponse.mediaType === BANNER
|
|
95
|
+
fn: bannerResponseProcessor(),
|
|
96
|
+
},
|
|
97
|
+
video: {
|
|
98
|
+
// sets video response attributes if bidResponse.mediaType === VIDEO
|
|
99
|
+
fn: fillVideoResponse
|
|
100
|
+
},
|
|
101
|
+
props: {
|
|
102
|
+
// sets base bidResponse properties common to all types of bids
|
|
103
|
+
fn(bidResponse, bid, context) {
|
|
104
|
+
Object.entries({
|
|
105
|
+
requestId: context.bidRequest?.bidId,
|
|
106
|
+
seatBidId: bid.id,
|
|
107
|
+
cpm: bid.price,
|
|
108
|
+
currency: context.ortbResponse.cur || context.currency,
|
|
109
|
+
width: bid.w,
|
|
110
|
+
height: bid.h,
|
|
111
|
+
dealId: bid.dealid,
|
|
112
|
+
creative_id: bid.crid,
|
|
113
|
+
creativeId: bid.crid,
|
|
114
|
+
burl: bid.burl,
|
|
115
|
+
ttl: bid.exp || context.ttl,
|
|
116
|
+
netRevenue: context.netRevenue,
|
|
117
|
+
}).filter(([k, v]) => typeof v !== 'undefined')
|
|
118
|
+
.forEach(([k, v]) => bidResponse[k] = v);
|
|
119
|
+
if (!bidResponse.meta) {
|
|
120
|
+
bidResponse.meta = {};
|
|
121
|
+
}
|
|
122
|
+
if (bid.adomain) {
|
|
123
|
+
bidResponse.meta.advertiserDomains = bid.adomain;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (FEATURES.NATIVE) {
|
|
131
|
+
DEFAULT_PROCESSORS[IMP].native = {
|
|
132
|
+
// populates imp.native
|
|
133
|
+
fn: fillNativeImp
|
|
134
|
+
}
|
|
135
|
+
DEFAULT_PROCESSORS[BID_RESPONSE].native = {
|
|
136
|
+
// populates bidResponse.native if bidResponse.mediaType === NATIVE
|
|
137
|
+
fn: fillNativeResponse
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function fpdFromTopLevelConfig(prop) {
|
|
142
|
+
return {
|
|
143
|
+
priority: 90, // after FPD from 'ortb2', before the rest
|
|
144
|
+
fn(ortbRequest) {
|
|
145
|
+
const data = config.getConfig(prop);
|
|
146
|
+
if (typeof data === 'object') {
|
|
147
|
+
ortbRequest[prop] = data;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function setDevice(ortbRequest) {
|
|
154
|
+
ortbRequest.device = Object.assign({
|
|
155
|
+
w: window.innerWidth,
|
|
156
|
+
h: window.innerHeight,
|
|
157
|
+
dnt: getDNT() ? 1 : 0,
|
|
158
|
+
ua: window.navigator.userAgent,
|
|
159
|
+
language: window.navigator.language.split('-').shift()
|
|
160
|
+
}, ortbRequest.device);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function setSite(ortbRequest, bidderRequest) {
|
|
164
|
+
if (bidderRequest.refererInfo) {
|
|
165
|
+
ortbRequest.site = Object.assign(getDefinedParams(bidderRequest.refererInfo, ['page', 'domain', 'ref']), ortbRequest.site);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {BANNER, NATIVE, VIDEO} from '../../../src/mediaTypes.js';
|
|
2
|
+
|
|
3
|
+
export const ORTB_MTYPES = {
|
|
4
|
+
1: BANNER,
|
|
5
|
+
2: VIDEO,
|
|
6
|
+
4: NATIVE
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Sets response mediaType, using ORTB 2.6 `seatbid.bid[].mtype`.
|
|
11
|
+
*
|
|
12
|
+
* Note that this will throw away bids if there is no `mtype` in the response.
|
|
13
|
+
*/
|
|
14
|
+
export function setResponseMediaType(bidResponse, bid, context) {
|
|
15
|
+
if (bidResponse.mediaType) return;
|
|
16
|
+
const mediaType = context.mediaType;
|
|
17
|
+
if (!mediaType && !ORTB_MTYPES.hasOwnProperty(bid.mtype)) {
|
|
18
|
+
throw new Error('Cannot determine mediaType for response')
|
|
19
|
+
}
|
|
20
|
+
bidResponse.mediaType = mediaType || ORTB_MTYPES[bid.mtype];
|
|
21
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {isPlainObject, logWarn, mergeDeep} from '../../../src/utils.js';
|
|
2
|
+
import {NATIVE} from '../../../src/mediaTypes.js';
|
|
3
|
+
|
|
4
|
+
export function fillNativeImp(imp, bidRequest, context) {
|
|
5
|
+
if (context.mediaType && context.mediaType !== NATIVE) return;
|
|
6
|
+
let nativeReq = bidRequest.nativeOrtbRequest;
|
|
7
|
+
if (nativeReq) {
|
|
8
|
+
nativeReq = Object.assign({}, context.nativeRequest, nativeReq);
|
|
9
|
+
if (nativeReq.assets?.length) {
|
|
10
|
+
imp.native = mergeDeep({}, {
|
|
11
|
+
request: JSON.stringify(nativeReq),
|
|
12
|
+
ver: nativeReq.ver
|
|
13
|
+
}, imp.native)
|
|
14
|
+
} else {
|
|
15
|
+
logWarn('mediaTypes.native is set, but no assets were specified. Native request skipped.', bidRequest)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function fillNativeResponse(bidResponse, bid) {
|
|
21
|
+
if (bidResponse.mediaType === NATIVE) {
|
|
22
|
+
let ortb;
|
|
23
|
+
if (typeof bid.adm === 'string') {
|
|
24
|
+
ortb = JSON.parse(bid.adm);
|
|
25
|
+
} else {
|
|
26
|
+
ortb = bid.adm;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (isPlainObject(ortb) && Array.isArray(ortb.assets)) {
|
|
30
|
+
bidResponse.native = {
|
|
31
|
+
ortb,
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
throw new Error('ORTB native response contained no assets');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {deepAccess, isEmpty, logWarn, mergeDeep} from '../../../src/utils.js';
|
|
2
|
+
import {VIDEO} from '../../../src/mediaTypes.js';
|
|
3
|
+
import {sizesToFormat} from '../lib/sizes.js';
|
|
4
|
+
|
|
5
|
+
// parameters that share the same name & semantics between pbjs adUnits and imp.video
|
|
6
|
+
const ORTB_VIDEO_PARAMS = new Set([
|
|
7
|
+
'pos',
|
|
8
|
+
'placement',
|
|
9
|
+
'api',
|
|
10
|
+
'mimes',
|
|
11
|
+
'protocols',
|
|
12
|
+
'playbackmethod',
|
|
13
|
+
'minduration',
|
|
14
|
+
'maxduration',
|
|
15
|
+
'w',
|
|
16
|
+
'h',
|
|
17
|
+
'startdelay',
|
|
18
|
+
'placement',
|
|
19
|
+
'linearity',
|
|
20
|
+
'skip',
|
|
21
|
+
'skipmin',
|
|
22
|
+
'skipafter',
|
|
23
|
+
'minbitrate',
|
|
24
|
+
'maxbitrate',
|
|
25
|
+
'delivery',
|
|
26
|
+
'playbackend'
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
const PLACEMENT = {
|
|
30
|
+
'instream': 1,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function fillVideoImp(imp, bidRequest, context) {
|
|
34
|
+
if (context.mediaType && context.mediaType !== VIDEO) return;
|
|
35
|
+
|
|
36
|
+
const videoParams = deepAccess(bidRequest, 'mediaTypes.video');
|
|
37
|
+
if (!isEmpty(videoParams)) {
|
|
38
|
+
const video = Object.fromEntries(
|
|
39
|
+
Object.entries(videoParams)
|
|
40
|
+
.filter(([name]) => ORTB_VIDEO_PARAMS.has(name))
|
|
41
|
+
);
|
|
42
|
+
if (videoParams.playerSize) {
|
|
43
|
+
const format = sizesToFormat(videoParams.playerSize);
|
|
44
|
+
if (format.length > 1) {
|
|
45
|
+
logWarn('video request specifies more than one playerSize; all but the first will be ignored')
|
|
46
|
+
}
|
|
47
|
+
Object.assign(video, format[0]);
|
|
48
|
+
}
|
|
49
|
+
const placement = PLACEMENT[videoParams.context];
|
|
50
|
+
if (placement != null) {
|
|
51
|
+
video.placement = placement;
|
|
52
|
+
}
|
|
53
|
+
imp.video = mergeDeep(video, imp.video);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function fillVideoResponse(bidResponse, seatbid, context) {
|
|
58
|
+
if (bidResponse.mediaType === VIDEO) {
|
|
59
|
+
if (deepAccess(context.imp, 'video.w') && deepAccess(context.imp, 'video.h')) {
|
|
60
|
+
[bidResponse.playerWidth, bidResponse.playerHeight] = [context.imp.video.w, context.imp.video.h];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (seatbid.adm) { bidResponse.vastXml = seatbid.adm; }
|
|
64
|
+
if (seatbid.nurl) { bidResponse.vastUrl = seatbid.nurl; }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {mergeProcessors} from '../ortbConverter/lib/mergeProcessors.js';
|
|
2
|
+
import {PBS_PROCESSORS} from './processors/pbs.js';
|
|
3
|
+
import {getProcessors, PBS} from '../../src/pbjsORTB.js';
|
|
4
|
+
import {defaultProcessors} from '../ortbConverter/converter.js';
|
|
5
|
+
import {memoize} from '../../src/utils.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ORTB converter processor set that understands Prebid Server extensions.
|
|
9
|
+
*
|
|
10
|
+
* Pass this as the `processors` option to `ortbConverter` if your backend is a PBS instance.
|
|
11
|
+
*/
|
|
12
|
+
export const pbsExtensions = memoize(() => mergeProcessors(defaultProcessors(), PBS_PROCESSORS, getProcessors(PBS)));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import adapterManager from '../../../src/adapterManager.js';
|
|
2
|
+
import {deepSetValue} from '../../../src/utils.js';
|
|
3
|
+
|
|
4
|
+
export function setRequestExtPrebidAliases(ortbRequest, bidderRequest, context, {am = adapterManager} = {}) {
|
|
5
|
+
if (am.aliasRegistry[bidderRequest.bidderCode]) {
|
|
6
|
+
const bidder = am.bidderRegistry[bidderRequest.bidderCode];
|
|
7
|
+
// adding alias only if alias source bidder exists and alias isn't configured to be standalone
|
|
8
|
+
// pbs adapter
|
|
9
|
+
if (!bidder || !bidder.getSpec().skipPbsAliasing) {
|
|
10
|
+
deepSetValue(
|
|
11
|
+
ortbRequest,
|
|
12
|
+
`ext.prebid.aliases.${bidderRequest.bidderCode}`,
|
|
13
|
+
am.aliasRegistry[bidderRequest.bidderCode]
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {BANNER, NATIVE, VIDEO} from '../../../src/mediaTypes.js';
|
|
2
|
+
import {ORTB_MTYPES} from '../../ortbConverter/processors/mediaType.js';
|
|
3
|
+
|
|
4
|
+
export const SUPPORTED_MEDIA_TYPES = {
|
|
5
|
+
// map from pbjs mediaType to its corresponding imp property
|
|
6
|
+
[BANNER]: 'banner',
|
|
7
|
+
[NATIVE]: 'native',
|
|
8
|
+
[VIDEO]: 'video'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Sets bidResponse.mediaType, using ORTB 2.6 `seatbid.bid[].mtype`, falling back to `ext.prebid.type`, falling back to 'banner'.
|
|
13
|
+
*/
|
|
14
|
+
export function extPrebidMediaType(bidResponse, bid, context) {
|
|
15
|
+
let mediaType = context.mediaType;
|
|
16
|
+
if (!mediaType) {
|
|
17
|
+
mediaType = ORTB_MTYPES.hasOwnProperty(bid.mtype) ? ORTB_MTYPES[bid.mtype] : bid.ext?.prebid?.type
|
|
18
|
+
if (!SUPPORTED_MEDIA_TYPES.hasOwnProperty(mediaType)) {
|
|
19
|
+
mediaType = BANNER;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
bidResponse.mediaType = mediaType;
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {auctionManager} from '../../../src/auctionManager.js';
|
|
2
|
+
import adapterManager from '../../../src/adapterManager.js';
|
|
3
|
+
import {deepSetValue} from '../../../src/utils.js';
|
|
4
|
+
|
|
5
|
+
export function setImpBidParams(
|
|
6
|
+
imp, bidRequest, context,
|
|
7
|
+
{adUnit, bidderRequests, index = auctionManager.index, bidderRegistry = adapterManager.bidderRegistry} = {}) {
|
|
8
|
+
let params = bidRequest.params;
|
|
9
|
+
const adapter = bidderRegistry[bidRequest.bidder];
|
|
10
|
+
if (adapter && adapter.getSpec().transformBidParams) {
|
|
11
|
+
adUnit = adUnit || index.getAdUnit(bidRequest);
|
|
12
|
+
bidderRequests = bidderRequests || [context.bidderRequest];
|
|
13
|
+
params = adapter.getSpec().transformBidParams(params, true, adUnit, bidderRequests);
|
|
14
|
+
}
|
|
15
|
+
if (params) {
|
|
16
|
+
deepSetValue(
|
|
17
|
+
imp,
|
|
18
|
+
`ext.prebid.bidder.${bidRequest.bidder}`,
|
|
19
|
+
params
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {BID_RESPONSE, IMP, REQUEST, RESPONSE} from '../../../src/pbjsORTB.js';
|
|
2
|
+
import {deepAccess, isPlainObject, isStr, mergeDeep} from '../../../src/utils.js';
|
|
3
|
+
import {extPrebidMediaType} from './mediaType.js';
|
|
4
|
+
import {setRequestExtPrebidAliases} from './aliases.js';
|
|
5
|
+
import {setImpBidParams} from './params.js';
|
|
6
|
+
import {setRequestExtPrebid, setRequestExtPrebidChannel} from './requestExtPrebid.js';
|
|
7
|
+
import {setBidResponseVideoCache} from './video.js';
|
|
8
|
+
|
|
9
|
+
export const PBS_PROCESSORS = {
|
|
10
|
+
[REQUEST]: {
|
|
11
|
+
extPrebid: {
|
|
12
|
+
// set request.ext.prebid.auctiontimestamp, .debug and .targeting
|
|
13
|
+
fn: setRequestExtPrebid
|
|
14
|
+
},
|
|
15
|
+
extPrebidChannel: {
|
|
16
|
+
// sets request.ext.prebid.channel
|
|
17
|
+
fn: setRequestExtPrebidChannel
|
|
18
|
+
},
|
|
19
|
+
extPrebidAliases: {
|
|
20
|
+
// sets ext.prebid.aliases
|
|
21
|
+
fn: setRequestExtPrebidAliases
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
[IMP]: {
|
|
25
|
+
params: {
|
|
26
|
+
// sets bid ext.prebid.bidder.[bidderCode] with bidRequest.params, passed through transformBidParams if necessary
|
|
27
|
+
fn: setImpBidParams
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
[BID_RESPONSE]: {
|
|
31
|
+
mediaType: {
|
|
32
|
+
// sets bidResponse.mediaType according to context.mediaType, falling back to imp.ext.prebid.type
|
|
33
|
+
fn: extPrebidMediaType,
|
|
34
|
+
priority: 99,
|
|
35
|
+
},
|
|
36
|
+
videoCache: {
|
|
37
|
+
// sets response video attributes; in addition, looks at ext.prebid.cache and .targeting to set video cache key and URL
|
|
38
|
+
fn: setBidResponseVideoCache,
|
|
39
|
+
priority: -10, // after 'video'
|
|
40
|
+
},
|
|
41
|
+
bidderCode: {
|
|
42
|
+
// sets bidderCode from on seatbid.seat
|
|
43
|
+
fn(bidResponse, bid, context) {
|
|
44
|
+
bidResponse.bidderCode = context.seatbid.seat;
|
|
45
|
+
bidResponse.adapterCode = deepAccess(bid, 'ext.prebid.meta.adaptercode') || context.bidRequest?.bidder || bidResponse.bidderCode;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
pbsBidId: {
|
|
49
|
+
// sets bidResponse.pbsBidId from ext.prebid.bidid
|
|
50
|
+
fn(bidResponse, bid) {
|
|
51
|
+
const bidId = deepAccess(bid, 'ext.prebid.bidid');
|
|
52
|
+
if (isStr(bidId)) {
|
|
53
|
+
bidResponse.pbsBidId = bidId;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
adserverTargeting: {
|
|
58
|
+
// sets bidResponse.adserverTargeting from ext.prebid.targeting
|
|
59
|
+
fn(bidResponse, bid) {
|
|
60
|
+
const targeting = deepAccess(bid, 'ext.prebid.targeting');
|
|
61
|
+
if (isPlainObject(targeting)) {
|
|
62
|
+
bidResponse.adserverTargeting = targeting;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
extPrebidMeta: {
|
|
67
|
+
// sets bidResponse.meta from ext.prebid.meta
|
|
68
|
+
fn(bidResponse, bid) {
|
|
69
|
+
bidResponse.meta = mergeDeep({}, deepAccess(bid, 'ext.prebid.meta'), bidResponse.meta);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
pbsWurl: {
|
|
73
|
+
// sets bidResponse.pbsWurl from ext.prebid.events.win
|
|
74
|
+
fn(bidResponse, bid) {
|
|
75
|
+
const wurl = deepAccess(bid, 'ext.prebid.events.win');
|
|
76
|
+
if (isStr(wurl)) {
|
|
77
|
+
bidResponse.pbsWurl = wurl;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
[RESPONSE]: {
|
|
83
|
+
serverSideStats: {
|
|
84
|
+
// updates bidderRequest and bidRequests with serverErrors from ext.errors and serverResponseTimeMs from ext.responsetimemillis
|
|
85
|
+
fn(response, ortbResponse, context) {
|
|
86
|
+
Object.entries({
|
|
87
|
+
errors: 'serverErrors',
|
|
88
|
+
responsetimemillis: 'serverResponseTimeMs'
|
|
89
|
+
}).forEach(([serverName, clientName]) => {
|
|
90
|
+
const value = deepAccess(ortbResponse, `ext.${serverName}.${context.bidderRequest.bidderCode}`);
|
|
91
|
+
if (value) {
|
|
92
|
+
context.bidderRequest[clientName] = value;
|
|
93
|
+
context.bidRequests.forEach(bid => bid[clientName] = value);
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {deepSetValue, mergeDeep} from '../../../src/utils.js';
|
|
2
|
+
import {config} from '../../../src/config.js';
|
|
3
|
+
import {getGlobal} from '../../../src/prebidGlobal.js';
|
|
4
|
+
|
|
5
|
+
export function setRequestExtPrebid(ortbRequest, bidderRequest) {
|
|
6
|
+
deepSetValue(
|
|
7
|
+
ortbRequest,
|
|
8
|
+
'ext.prebid',
|
|
9
|
+
mergeDeep(
|
|
10
|
+
{
|
|
11
|
+
auctiontimestamp: bidderRequest.auctionStart,
|
|
12
|
+
targeting: {
|
|
13
|
+
includewinners: true,
|
|
14
|
+
includebidderkeys: false
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
ortbRequest.ext?.prebid,
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
if (config.getConfig('debug')) {
|
|
21
|
+
ortbRequest.ext.prebid.debug = true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function setRequestExtPrebidChannel(ortbRequest) {
|
|
26
|
+
deepSetValue(ortbRequest, 'ext.prebid.channel', Object.assign({
|
|
27
|
+
name: 'pbjs',
|
|
28
|
+
version: getGlobal().version
|
|
29
|
+
}, ortbRequest.ext?.prebid?.channel));
|
|
30
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {VIDEO} from '../../../src/mediaTypes.js';
|
|
2
|
+
import {deepAccess} from '../../../src/utils.js';
|
|
3
|
+
|
|
4
|
+
export function setBidResponseVideoCache(bidResponse, bid) {
|
|
5
|
+
if (bidResponse.mediaType === VIDEO) {
|
|
6
|
+
// try to get cache values from 'response.ext.prebid.cache'
|
|
7
|
+
// else try 'bid.ext.prebid.targeting' as fallback
|
|
8
|
+
let {cacheId: videoCacheKey, url: vastUrl} = deepAccess(bid, 'ext.prebid.cache.vastXml') || {};
|
|
9
|
+
if (!videoCacheKey || !vastUrl) {
|
|
10
|
+
const {hb_uuid: uuid, hb_cache_host: cacheHost, hb_cache_path: cachePath} = deepAccess(bid, 'ext.prebid.targeting') || {};
|
|
11
|
+
if (uuid && cacheHost && cachePath) {
|
|
12
|
+
videoCacheKey = uuid;
|
|
13
|
+
vastUrl = `https://${cacheHost}${cachePath}?uuid=${uuid}`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (videoCacheKey && vastUrl) {
|
|
17
|
+
Object.assign(bidResponse, {
|
|
18
|
+
videoCacheKey,
|
|
19
|
+
vastUrl
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|