Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prebid 7: auction-specific first party data and refactoring of FPD internals #8338

Merged
merged 4 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ export function setExtraParam(bid, paramName) {
}

const adgGlobalConf = config.getConfig('adagio') || {};
const ortb2Conf = config.getConfig('ortb2');
const ortb2Conf = bid.ortb2;

const detected = adgGlobalConf[paramName] || deepAccess(ortb2Conf, `site.ext.data.${paramName}`, null);
if (detected) {
Expand Down
2 changes: 1 addition & 1 deletion modules/adfBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const spec = {
buildRequests: (validBidRequests, bidderRequest) => {
let app, site;

const commonFpd = getConfig('ortb2') || {};
const commonFpd = bidderRequest.ortb2 || {};
let { user } = commonFpd;

if (typeof getConfig('app') === 'object') {
Expand Down
2 changes: 1 addition & 1 deletion modules/adkernelBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ function makeSyncInfo(bidderRequest) {
* @return {Object} Complete rtb request
*/
function buildRtbRequest(imps, bidderRequest, schain) {
let fpd = config.getConfig('ortb2') || {};
let fpd = bidderRequest.ortb2 || {};

let req = mergeDeep(
makeBaseRequest(bidderRequest, imps, fpd),
Expand Down
16 changes: 8 additions & 8 deletions modules/adlooxRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
/* eslint prebid/validate-imports: "off" */

import {command as analyticsCommand, COMMAND} from './adlooxAnalyticsAdapter.js';
import {config as _config} from '../src/config.js';
import {submodule} from '../src/hook.js';
import {ajax} from '../src/ajax.js';
import {getGlobal} from '../src/prebidGlobal.js';
Expand Down Expand Up @@ -231,9 +230,9 @@ function getBidRequestData(reqBidsConfigObj, callback, config, userConsent) {
return config.params.thresholds.filter(t => t <= v);
}

const ortb2 = _config.getConfig('ortb2') || {};
const dataSite = _config.getConfig('ortb2.site.ext.data') || {};
const dataUser = _config.getConfig('ortb2.user.ext.data') || {};
const ortb2 = reqBidsConfigObj.ortb2Fragments?.global || {};
const dataSite = deepAccess(ortb2, 'site.ext.data') || {};
const dataUser = deepAccess(ortb2, 'user.ext.data') || {};

_each(response, (v0, k0) => {
if (k0 == '_') return;
Expand All @@ -245,7 +244,7 @@ function getBidRequestData(reqBidsConfigObj, callback, config, userConsent) {

deepSetValue(ortb2, 'site.ext.data', dataSite);
deepSetValue(ortb2, 'user.ext.data', dataUser);
_config.setConfig({ ortb2 });
deepSetValue(reqBidsConfigObj, 'ortb2Fragments.global', ortb2);

adUnits.forEach((adUnit, i) => {
_each(response['_'][i], (v0, k0) => {
Expand Down Expand Up @@ -365,18 +364,19 @@ function getBidRequestData(reqBidsConfigObj, callback, config, userConsent) {
});
}

function getTargetingData(adUnitArray, config, userConsent) {
function getTargetingData(adUnitArray, config, userConsent, auction) {
function targetingNormalise(v) {
if (isArray(v) && v.length == 0) return undefined;
if (isBoolean(v)) v = ~~v;
if (!v) return undefined; // empty string and zero
return v;
}

const dataSite = _config.getConfig(`ortb2.site.ext.data.${MODULE_NAME}_rtd`) || {};
const ortb2 = auction.getFPD().global || {};
const dataSite = deepAccess(ortb2, `site.ext.data.${MODULE_NAME}_rtd`) || {};
if (!dataSite.ok) return {};

const dataUser = _config.getConfig(`ortb2.user.ext.data.${MODULE_NAME}_rtd`) || {};
const dataUser = deepAccess(ortb2, `user.ext.data.${MODULE_NAME}_rtd`) || {};
return getGlobal().adUnits.filter(adUnit => includes(adUnitArray, adUnit.code)).reduce((a, adUnit) => {
a[adUnit.code] = {};

Expand Down
2 changes: 1 addition & 1 deletion modules/admixerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const spec = {
} while (w !== window.top);
const payload = {
imps: [],
ortb2: config.getConfig('ortb2'),
ortb2: bidderRequest.ortb2,
docReferrer: docRef,
};
let endpointUrl;
Expand Down
2 changes: 1 addition & 1 deletion modules/adnuntiusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const spec = {
const bidRequests = {};
const requests = [];
const request = [];
const ortb2 = config.getConfig('ortb2');
const ortb2 = bidderRequest.ortb2 || {};
const bidderConfig = config.getConfig();

const adnMeta = handleMeta()
Expand Down
2 changes: 1 addition & 1 deletion modules/adrelevantisBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const spec = {
payload.referrer_detection = refererinfo;
}

let fpdcfg = config.getLegacyFpd(config.getConfig('ortb2'));
let fpdcfg = config.getLegacyFpd(bidderRequest.ortb2);
if (fpdcfg && fpdcfg.context) {
let fdata = {
keywords: fpdcfg.context.keywords || '',
Expand Down
2 changes: 1 addition & 1 deletion modules/adxcgBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const spec = {
buildRequests: (validBidRequests, bidderRequest) => {
let app, site;

const commonFpd = getConfig('ortb2') || {};
const commonFpd = bidderRequest.ortb2 || {};
let { user } = commonFpd;

if (typeof getConfig('app') === 'object') {
Expand Down
23 changes: 6 additions & 17 deletions modules/airgridRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
* @module modules/airgridRtdProvider
* @requires module:modules/realTimeData
*/
import {config} from '../src/config.js';
import {submodule} from '../src/hook.js';
import {mergeDeep, isPlainObject, deepSetValue, deepAccess} from '../src/utils.js';
import {deepAccess, deepSetValue, mergeDeep} from '../src/utils.js';
import {getGlobal} from '../src/prebidGlobal.js';
import {getStorageManager} from '../src/storageManager.js';

Expand Down Expand Up @@ -76,25 +75,15 @@ function setAudiencesToAppNexusAdUnits(adUnits, audiences) {
* Pass audience data to configured bidders, using ORTB2
* @param {Object} rtdConfig
* @param {Array} audiences
* @return {void}
* @return {{}} a map from bidder code to ORTB2 config
*/
export function setAudiencesUsingBidderOrtb2(rtdConfig, audiences) {
export function getAudiencesAsBidderOrtb2(rtdConfig, audiences) {
const bidders = deepAccess(rtdConfig, 'params.bidders');
if (!bidders || bidders.length === 0) return;
const allBiddersConfig = config.getBidderConfig();
if (!bidders || bidders.length === 0) return {};
const agOrtb2 = {}
deepSetValue(agOrtb2, 'ortb2.user.ext.data.airgrid', audiences || []);

bidders.forEach((bidder) => {
let bidderConfig = {};
if (isPlainObject(allBiddersConfig[bidder])) {
bidderConfig = allBiddersConfig[bidder];
}
config.setBidderConfig({
bidders: [bidder],
config: mergeDeep(bidderConfig, agOrtb2)
});
});
return Object.fromEntries(bidders.map(bidder => [bidder, agOrtb2]));
}

/**
Expand All @@ -120,7 +109,7 @@ export function passAudiencesToBidders(bidConfig, onDone, rtdConfig, userConsent
const adUnits = bidConfig.adUnits || getGlobal().adUnits;
const audiences = getMatchedAudiencesFromStorage();
if (audiences.length > 0) {
setAudiencesUsingBidderOrtb2(rtdConfig, audiences);
mergeDeep(bidConfig?.ortb2Fragments?.bidder, getAudiencesAsBidderOrtb2(rtdConfig, audiences));
if (adUnits) {
setAudiencesToAppNexusAdUnits(adUnits, audiences);
}
Expand Down
10 changes: 4 additions & 6 deletions modules/akamaiDapRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
* @requires module:modules/realTimeData
*/
import {ajax} from '../src/ajax.js';
import {config} from '../src/config.js';
import {getStorageManager} from '../src/storageManager.js';
import {submodule} from '../src/hook.js';
import {isPlainObject, mergeDeep, logMessage, logInfo, logError} from '../src/utils.js';
import {isPlainObject, logError, logInfo, logMessage, mergeDeep} from '../src/utils.js';

const MODULE_NAME = 'realTimeData';
const SUBMODULE_NAME = 'dap';
Expand Down Expand Up @@ -38,13 +37,12 @@ function mergeLazy(target, source) {
* @param {Object} rtd
* @param {Object} rtdConfig
*/
export function addRealTimeData(rtd) {
export function addRealTimeData(ortb2, rtd) {
logInfo('DEBUG(addRealTimeData) - ENTER');
if (isPlainObject(rtd.ortb2)) {
let ortb2 = config.getConfig('ortb2') || {};
logMessage('DEBUG(addRealTimeData): merging original: ', ortb2);
logMessage('DEBUG(addRealTimeData): merging in: ', rtd.ortb2);
config.setConfig({ortb2: mergeLazy(ortb2, rtd.ortb2)});
mergeLazy(ortb2, rtd.ortb2);
}
logInfo('DEBUG(addRealTimeData) - EXIT');
}
Expand All @@ -64,7 +62,7 @@ export function getRealTimeData(bidConfig, onDone, rtdConfig, userConsent) {
if (jsonData) {
let data = JSON.parse(jsonData);
if (data.rtd) {
addRealTimeData(data.rtd);
addRealTimeData(bidConfig.ortb2Fragments?.global, data.rtd);
onDone();
logInfo('DEBUG(getRealTimeData) - 1');
// Don't return - ensure the data is always fresh.
Expand Down
2 changes: 1 addition & 1 deletion modules/amxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export const spec = {
d: '',
m: createBidMap(bidRequests),
cpp: config.getConfig('coppa') ? 1 : 0,
fpd2: config.getConfig('ortb2'),
fpd2: bidderRequest.ortb2,
tmax: config.getConfig('bidderTimeout'),
eids: values(bidRequests.reduce((all, bid) => {
// we only want unique ones in here
Expand Down
4 changes: 2 additions & 2 deletions modules/beachfrontBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ function createVideoRequestData(bid, bidderRequest) {
let tagid = getVideoBidParam(bid, 'tagid');
let topLocation = getTopWindowLocation(bidderRequest);
let eids = getEids(bid);
let ortb2 = deepClone(config.getConfig('ortb2'));
let ortb2 = deepClone(bidderRequest.ortb2);
let payload = {
isPrebid: true,
appId: appId,
Expand Down Expand Up @@ -443,7 +443,7 @@ function createBannerRequestData(bids, bidderRequest) {
sizes: getBannerSizes(bid)
};
});
let ortb2 = deepClone(config.getConfig('ortb2'));
let ortb2 = deepClone(bidderRequest.ortb2);
let payload = {
slots: slots,
ortb2: ortb2,
Expand Down
2 changes: 1 addition & 1 deletion modules/beopBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const spec = {
buildRequests: function(validBidRequests, bidderRequest) {
const slots = validBidRequests.map(beOpRequestSlotsMaker);
let pageUrl = deepAccess(window, 'location.href') || deepAccess(bidderRequest, 'refererInfo.canonicalUrl') || config.getConfig('pageUrl');
let fpd = config.getLegacyFpd(config.getConfig('ortb2'));
let fpd = config.getLegacyFpd(bidderRequest.ortb2);
let gdpr = bidderRequest.gdprConsent;
let firstSlot = slots[0];
let payloadObject = {
Expand Down
15 changes: 6 additions & 9 deletions modules/brandmetricsRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* @module modules/brandmetricsRtdProvider
* @requires module:modules/realTimeData
*/
import { config } from '../src/config.js'
import { submodule } from '../src/hook.js'
import { deepSetValue, mergeDeep, logError, deepAccess } from '../src/utils.js'
import {loadExternalScript} from '../src/adloader.js'
import {submodule} from '../src/hook.js';
import {deepAccess, deepSetValue, logError, mergeDeep} from '../src/utils.js';
import {loadExternalScript} from '../src/adloader.js';

const MODULE_NAME = 'brandmetrics'
const MODULE_CODE = MODULE_NAME
const RECEIVED_EVENTS = []
Expand Down Expand Up @@ -109,11 +109,8 @@ function processBrandmetricsEvents (reqBidsConfigObj, moduleConfig, callback) {
function setBidderTargeting (reqBidsConfigObj, moduleConfig, key, val) {
const bidders = deepAccess(moduleConfig, 'params.bidders')
if (bidders && bidders.length > 0) {
const ortb2 = {}
deepSetValue(ortb2, 'ortb2.user.ext.data.' + key, val)
config.setBidderConfig({
bidders: bidders,
config: ortb2
bidders.forEach(bidder => {
deepSetValue(reqBidsConfigObj, `ortb2Fragments.bidder.${bidder}.user.ext.data.${key}`, val);
})
}
}
Expand Down
3 changes: 1 addition & 2 deletions modules/conversantBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { logWarn, isStr, deepAccess, isArray, getBidIdParameter, deepSetValue, i
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {getStorageManager} from '../src/storageManager.js';
import { config } from '../src/config.js';

const GVLID = 24;

Expand Down Expand Up @@ -177,7 +176,7 @@ export const spec = {
payload.user = {ext: userExt};
}

const firstPartyData = config.getConfig('ortb2') || {};
const firstPartyData = bidderRequest.ortb2 || {};
mergeDeep(payload, firstPartyData);

return {
Expand Down
2 changes: 1 addition & 1 deletion modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const spec = {
buildRequests: (bidRequests, bidderRequest) => {
let url;
let data;
let fpd = config.getConfig('ortb2') || {};
let fpd = bidderRequest.ortb2 || {};

Object.assign(bidderRequest, {
publisherExt: fpd.site?.ext,
Expand Down
2 changes: 1 addition & 1 deletion modules/datablocksBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export const spec = {
gdpr: bidderRequest.gdprConsent || {},
usp: bidderRequest.uspConsent || {},
client_info: this.get_client_info(),
ortb2: config.getConfig('ortb2') || {}
ortb2: bidderRequest.ortb2 || {}
}
};

Expand Down
5 changes: 2 additions & 3 deletions modules/dgkeywordRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @requires module:modules/realTimeData
*/

import { logMessage, deepSetValue, logError, logInfo } from '../src/utils.js';
import {logMessage, deepSetValue, logError, logInfo, mergeDeep} from '../src/utils.js';
import { ajax } from '../src/ajax.js';
import { submodule } from '../src/hook.js';
import { getGlobal } from '../src/prebidGlobal.js';
Expand Down Expand Up @@ -62,8 +62,7 @@ export function getDgKeywordsAndSet(reqBidsConfigObj, callback, moduleConfig, us
let addOrtb2 = {};
deepSetValue(addOrtb2, 'site.keywords', keywords);
deepSetValue(addOrtb2, 'user.keywords', keywords);
const ortb2 = {ortb2: addOrtb2};
reqBidsConfigObj.setBidderConfig({ bidders: Object.keys(targetBidKeys), config: ortb2 });
mergeDeep(reqBidsConfigObj.ortb2Fragments.bidder, Object.fromEntries(Object.keys(targetBidKeys).map(bidder => [bidder, addOrtb2])));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/distroscaleBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export const spec = {
}

// First Party Data
const commonFpd = config.getConfig('ortb2') || {};
const commonFpd = bidderRequest.ortb2 || {};
if (commonFpd.site) {
mergeDeep(payload, {site: commonFpd.site});
}
Expand Down
8 changes: 5 additions & 3 deletions modules/enrichmentFpdModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,19 @@ function runEnrichments() {
/**
* Sets default values to ortb2 if exists and adds currency and ortb2 setConfig callbacks on init
*/
export function initSubmodule(fpdConf, data) {
export function processFpd(fpdConf, {global}) {
resetOrtb2();

return (!fpdConf.skipEnrichments) ? mergeDeep(runEnrichments(), data) : data;
return {
global: (!fpdConf.skipEnrichments) ? mergeDeep(runEnrichments(), global) : global
};
}

/** @type {firstPartyDataSubmodule} */
export const enrichmentsSubmodule = {
name: 'enrichments',
queue: 2,
init: initSubmodule
processFpd
}

submodule('firstPartyData', enrichmentsSubmodule)
3 changes: 1 addition & 2 deletions modules/etargetBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { deepSetValue, isFn, isPlainObject } from '../src/utils.js';
import {config} from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';

Expand Down Expand Up @@ -91,7 +90,7 @@ export const spec = {
mts['title'] = [(document.getElementsByTagName('title')[0] || []).innerHTML];
mts['base'] = [(document.getElementsByTagName('base')[0] || {}).href];
mts['referer'] = [document.location.href];
mts['ortb2'] = (config.getConfig('ortb2') || {});
mts['ortb2'] = (bidderRequest.ortb2 || {});
} catch (e) {
mts.error = e;
}
Expand Down
Loading