Skip to content

Commit

Permalink
Fpd 2.0 Update (prebid#6293)
Browse files Browse the repository at this point in the history
* Update to consolidate applying FPD to both banner and video requests. FPD will be merged using global defined FPD, ad unit FPD, and rubicon bidder param FPD. Validation logic with warning logs added

* Refectored last push to:
1) Correct keywords bug
2) Revise error which looked for FPD in (user/context).ext.data as opposed to (user/context).data
3) General code cleanup

* Consolidated other FPD data logic into new function

* 1. Update to move pbadslot and adserver data into imp[] as opposed to parent.
2. Update to convert keywords passed through RP params to string if array found

* Removed unnecessary conditional

* Changed conditional to check for undefined type

* FPD 2.0 Update
1) The setConfig and setBidderConfig functions support a transition period where they map the original 'fpd' config:
   - fpd.context.ATTR --> ortb2.site.ATTR
   - fpd.context.data.ATTR --> ortb2.site.ext.data
   - fpd.user.ATTR --> ortb2.user.ATTR
   - fpd.user.data.ATTR --> ortb2.user.ext.data
2) gptPreAuction:
   a) move adunit.fpd to adunit.ortb2
   b) adUnit.ortb2Imp.ext.data.adserver.{name, adSlot}
   c) pbAdSlot moves to AdUnit.ortb2Imp.ext.data.pbAdSlot

3) pbsBidAdapter
   a) merge the new ortb2 and AdUnit.ortb2Imp.ext objects into the OpenRTB JSON.
   b) therefore imp[].ext.context.data.pbadslot is now changed to imp[].ext.data.pbadslot (no context)
   c) read adUnit.ortb2Imp.ext.data.adserver from the new location. Output location is moved to imp[].ext.data.adserver (no context)

* FPD 2.0 Update
Update to adrelevantis adapter to look at config.ortb2 instead of config.fpd

* FPD 2.0 Update
Update to amx adapter to look at config.ortb2 instead of config.fpd

* FPD 2.0 Update
Update to avocet adapter to look at config.ortb2 instead of config.fpd

* FPD 2.0 Update
Update to criteo adapter to look at config.ortb2 instead of config.fpd

* Update to correct imp fpd structure

* Update to s2s adapter to coincide with imp fpd alteration

* Update to consolidate several lines of duplicate code into one location

* Slight modification for ortb2Imp to use ortb2Imp.ext as opposed to ortb2Imp.ext.data

* FPD 2.0 Update
Update to grid adapter to look at config.ortb2 instead of config.fpd

* FPD 2.0 Update
Update to inmar adapter to look at config.ortb2 instead of config.fpd

* FPD 2.0 Update
Update to luponmedia adapter to look at config.ortb2 instead of config.fpd

* FPD 2.0 Update
Update to smaato adapter to look at config.ortb2 instead of config.fpd

* FPD 2.0 Update
Update to triplelift adapter to look at config.ortb2 instead of config.fpd

* Update to gptPreAuction to move over to imp level ortb2

* FPD 2.0 Update
Update to triplelift adapter to look at config.ortb2 instead of config.fpd

* FPD 2.0 Update

* FPD 2.0 Update
Update to jwplayerRtd adapter to look at config.ortb2 instead of config.fpd

* FPD 2.0 Update
Update to admixer adapter to look at config.ortb2 instead of config.fpd

* FPD 2.0 Update
Update to rubicon adapter to look at config.ortb2 instead of config.fpd

* Update to fix keyword bug

* Added backwards compatibility functions for FPD both global/bidder and adunit level data

* Update to utilize new backward functionality for fpd 2.0

* Removed extra new line

* Update to include new backward functionality for FPD 2.0 data

* Update to utilize new backward functionality to pass FPD 2.0 data

* Update to utilize backward functionality to pass FPD 2.0 data

* Update to utilize backward functionality to pass FPD 2.0 data

* Update to utilize backward functionality to pass FPD 2.0 data

* Update to utilize backward functionality to pass FPD 2.0 data

* Update to utilize backward functionality to pass FPD 2.0 data

* Fixed typo in fpd config object location

* Uodate to utilize backward functionality to pass FPD 2.0 data

* Update to change all ortb2Imp.ext.data.adserver.adSlot references to ortb2Imp.ext.data.adserver.adslot - all lowercase. Corresponding adapter and unit tests to adhere to these changes

* Fixed typo

* Fixed typo

* FPD 2.0 update to rubicon adapter to pass iab values

* Updates:
1) Change function name
2) addAdUnits always pass array
3) Remove unecessary comment
4) Bug fix for ortb2.user.data to be filtered on legacy fpd conversion
  • Loading branch information
mmoschovas authored and seergiioo6 committed Mar 23, 2021
1 parent 3ae5ea0 commit d474a46
Show file tree
Hide file tree
Showing 29 changed files with 583 additions and 330 deletions.
8 changes: 6 additions & 2 deletions modules/admixerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const spec = {
buildRequests: function (validRequest, bidderRequest) {
const payload = {
imps: [],
fpd: config.getConfig('fpd')
fpd: config.getLegacyFpd(config.getConfig('ortb2'))
};
let endpointUrl;
if (bidderRequest) {
Expand All @@ -42,7 +42,11 @@ export const spec = {
}
}
validRequest.forEach((bid) => {
payload.imps.push(bid);
let imp = {};
Object.keys(bid).forEach(key => {
(key === 'ortb2Imp') ? imp.fpd = config.getLegacyImpFpd(bid[key]) : imp[key] = bid[key];
});
payload.imps.push(imp);
});
const payloadString = JSON.stringify(payload);
return {
Expand Down
6 changes: 3 additions & 3 deletions modules/adrelevantisBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ export const spec = {
payload.referrer_detection = refererinfo;
}

let fpdcfg = config.getConfig('fpd')
let fpdcfg = config.getLegacyFpd(config.getConfig('ortb2'));
if (fpdcfg && fpdcfg.context) {
let fdata = {
keywords: fpdcfg.context.keywords,
category: fpdcfg.context.data.category
keywords: fpdcfg.context.keywords || '',
category: utils.deepAccess(fpdcfg, 'context.data.category') || ''
}
payload.fpd = fdata;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/amxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export const spec = {
d: '',
m: createBidMap(bidRequests),
cpp: config.getConfig('coppa') ? 1 : 0,
fpd: config.getConfig('fpd'),
fpd: config.getLegacyFpd(config.getConfig('ortb2')),
eids: values(bidRequests.reduce((all, bid) => {
// we only want unique ones in here
if (bid == null || bid.userIdAsEids == null) {
Expand Down
2 changes: 1 addition & 1 deletion modules/avocetBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const spec = {
const publisherDomain = config.getConfig('publisherDomain');

// First-party data from config
const fpd = config.getConfig('fpd');
const fpd = config.getLegacyFpd(config.getConfig('ortb2'));

// GDPR status and TCF consent string
let tcfConsentString;
Expand Down
11 changes: 6 additions & 5 deletions modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const spec = {
gvlid: GVLID,
supportedMediaTypes: [ BANNER, VIDEO, NATIVE ],

/**
/** f
* @param {object} bid
* @return {boolean}
*/
Expand Down Expand Up @@ -56,10 +56,11 @@ export const spec = {
buildRequests: (bidRequests, bidderRequest) => {
let url;
let data;
let fpd = config.getLegacyFpd(config.getConfig('ortb2')) || {};

Object.assign(bidderRequest, {
publisherExt: config.getConfig('fpd.context'),
userExt: config.getConfig('fpd.user'),
publisherExt: fpd.context,
userExt: fpd.user,
ceh: config.getConfig('criteo.ceh')
});

Expand Down Expand Up @@ -280,8 +281,8 @@ function buildCdbRequest(context, bidRequests, bidderRequest) {
if (bidRequest.params.zoneId) {
slot.zoneid = bidRequest.params.zoneId;
}
if (bidRequest.fpd && bidRequest.fpd.context) {
slot.ext = bidRequest.fpd.context;
if (utils.deepAccess(bidRequest, 'ortb2Imp.ext')) {
slot.ext = bidRequest.ortb2Imp.ext;
}
if (bidRequest.params.ext) {
slot.ext = Object.assign({}, slot.ext, bidRequest.params.ext);
Expand Down
32 changes: 17 additions & 15 deletions modules/gptPreAuction.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,48 @@ export const appendGptSlots = adUnits => {

if (matchingAdUnitCode) {
const adUnit = adUnitMap[matchingAdUnitCode];
adUnit.fpd = adUnit.fpd || {};
adUnit.fpd.context = adUnit.fpd.context || {};
adUnit.ortb2Imp = adUnit.ortb2Imp || {};
adUnit.ortb2Imp.ext = adUnit.ortb2Imp.ext || {};
adUnit.ortb2Imp.ext.data = adUnit.ortb2Imp.ext.data || {};

const context = adUnit.fpd.context;
context.adServer = context.adServer || {};
context.adServer.name = 'gam';
context.adServer.adSlot = slot.getAdUnitPath();
const context = adUnit.ortb2Imp.ext.data;
context.adserver = context.adserver || {};
context.adserver.name = 'gam';
context.adserver.adslot = slot.getAdUnitPath();
}
});
};

export const appendPbAdSlot = adUnit => {
adUnit.fpd = adUnit.fpd || {};
adUnit.fpd.context = adUnit.fpd.context || {};
const context = adUnit.fpd.context;
adUnit.ortb2Imp = adUnit.ortb2Imp || {};
adUnit.ortb2Imp.ext = adUnit.ortb2Imp.ext || {};
adUnit.ortb2Imp.ext.data = adUnit.ortb2Imp.ext.data || {};
const context = adUnit.ortb2Imp.ext.data;
const { customPbAdSlot } = _currentConfig;

if (customPbAdSlot) {
context.pbAdSlot = customPbAdSlot(adUnit.code, utils.deepAccess(context, 'adServer.adSlot'));
context.pbadslot = customPbAdSlot(adUnit.code, utils.deepAccess(context, 'adserver.adslot'));
return;
}

// use context.pbAdSlot if set
if (context.pbAdSlot) {
if (context.pbadslot) {
return;
}
// use data attribute 'data-adslotid' if set
try {
const adUnitCodeDiv = document.getElementById(adUnit.code);
if (adUnitCodeDiv.dataset.adslotid) {
context.pbAdSlot = adUnitCodeDiv.dataset.adslotid;
context.pbadslot = adUnitCodeDiv.dataset.adslotid;
return;
}
} catch (e) {}
// banner adUnit, use GPT adunit if defined
if (context.adServer) {
context.pbAdSlot = context.adServer.adSlot;
if (utils.deepAccess(context, 'adserver.adslot')) {
context.pbadslot = context.adserver.adslot;
return;
}
context.pbAdSlot = adUnit.code;
context.pbadslot = adUnit.code;
};

export const makeBidRequestsHook = (fn, adUnits, ...args) => {
Expand Down
4 changes: 2 additions & 2 deletions modules/gridBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ export const spec = {
}

const configKeywords = utils.transformBidderParamKeywords({
'user': utils.deepAccess(config.getConfig('fpd.user'), 'keywords') || null,
'context': utils.deepAccess(config.getConfig('fpd.context'), 'keywords') || null
'user': utils.deepAccess(config.getConfig('ortb2.user'), 'keywords') || null,
'context': utils.deepAccess(config.getConfig('ortb2.site'), 'keywords') || null
});

if (configKeywords.length) {
Expand Down
2 changes: 1 addition & 1 deletion modules/inmarBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const spec = {
uspConsent: bidderRequest.uspConsent,
currencyCode: config.getConfig('currency.adServerCurrency'),
coppa: config.getConfig('coppa'),
firstPartyData: config.getConfig('fpd'),
firstPartyData: config.getLegacyFpd(config.getConfig('ortb2')),
prebidVersion: '$prebid.version$'
};

Expand Down
4 changes: 2 additions & 2 deletions modules/jwplayerRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function enrichBidRequest(bidReqConfig, onDone) {
* @param {function} onDone
*/
export function enrichAdUnits(adUnits) {
const fpdFallback = config.getConfig('fpd.context.data.jwTargeting');
const fpdFallback = config.getConfig('ortb2.site.ext.data.jwTargeting');
adUnits.forEach(adUnit => {
const jwTargeting = extractPublisherParams(adUnit, fpdFallback);
if (!jwTargeting || !Object.keys(jwTargeting).length) {
Expand All @@ -170,7 +170,7 @@ function supportsInstreamVideo(mediaTypes) {
export function extractPublisherParams(adUnit, fallback) {
let adUnitTargeting;
try {
adUnitTargeting = adUnit.fpd.context.data.jwTargeting;
adUnitTargeting = adUnit.ortb2Imp.ext.data.jwTargeting;
} catch (e) {}

if (!adUnitTargeting && !supportsInstreamVideo(adUnit.mediaTypes)) {
Expand Down
7 changes: 4 additions & 3 deletions modules/luponmediaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ function newOrtbBidRequest(bidRequest, bidderRequest, currentImps) {
utils.deepSetValue(data, 'source.ext.schain', bidRequest.schain);
}

const siteData = Object.assign({}, bidRequest.params.inventory, config.getConfig('fpd.context'));
const userData = Object.assign({}, bidRequest.params.visitor, config.getConfig('fpd.user'));
const fpd = config.getLegacyFpd(config.getConfig('ortb2')) || {};
const siteData = Object.assign({}, bidRequest.params.inventory, fpd.context);
const userData = Object.assign({}, bidRequest.params.visitor, fpd.user);

if (!utils.isEmpty(siteData) || !utils.isEmpty(userData)) {
const bidderData = {
Expand All @@ -301,7 +302,7 @@ function newOrtbBidRequest(bidRequest, bidderRequest, currentImps) {
utils.deepSetValue(data, 'ext.prebid.bidderconfig.0', bidderData);
}

const pbAdSlot = utils.deepAccess(bidRequest, 'fpd.context.pbAdSlot');
const pbAdSlot = utils.deepAccess(bidRequest, 'ortb2Imp.ext.data.pbadslot');
if (typeof pbAdSlot === 'string' && pbAdSlot) {
utils.deepSetValue(data.imp[0].ext, 'context.data.adslot', pbAdSlot);
}
Expand Down
60 changes: 32 additions & 28 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,18 +336,18 @@ function addBidderFirstPartyDataToRequest(request) {
const bidderConfig = config.getBidderConfig();
const fpdConfigs = Object.keys(bidderConfig).reduce((acc, bidder) => {
const currBidderConfig = bidderConfig[bidder];
if (currBidderConfig.fpd) {
const fpd = {};
if (currBidderConfig.fpd.context) {
fpd.site = currBidderConfig.fpd.context;
if (currBidderConfig.ortb2) {
const ortb2 = {};
if (currBidderConfig.ortb2.site) {
ortb2.site = currBidderConfig.ortb2.site;
}
if (currBidderConfig.fpd.user) {
fpd.user = currBidderConfig.fpd.user;
if (currBidderConfig.ortb2.user) {
ortb2.user = currBidderConfig.ortb2.user;
}

acc.push({
bidders: [ bidder ],
config: { fpd }
config: { ortb2 }
});
}
return acc;
Expand Down Expand Up @@ -618,23 +618,27 @@ const OPEN_RTB_PROTOCOL = {

const imp = { id: adUnit.code, ext, secure: s2sConfig.secure };

/**
* Prebid AdSlot
* @type {(string|undefined)}
*/
const pbAdSlot = utils.deepAccess(adUnit, 'fpd.context.pbAdSlot');
if (typeof pbAdSlot === 'string' && pbAdSlot) {
utils.deepSetValue(imp, 'ext.context.data.pbadslot', pbAdSlot);
}

/**
* Copy GAM AdUnit and Name to imp
*/
['name', 'adSlot'].forEach(name => {
/** @type {(string|undefined)} */
const value = utils.deepAccess(adUnit, `fpd.context.adserver.${name}`);
if (typeof value === 'string' && value) {
utils.deepSetValue(imp, `ext.context.data.adserver.${name.toLowerCase()}`, value);
const ortb2 = {...utils.deepAccess(adUnit, 'ortb2Imp.ext.data')};
Object.keys(ortb2).forEach(prop => {
/**
* Prebid AdSlot
* @type {(string|undefined)}
*/
if (prop === 'pbadslot') {
if (typeof ortb2[prop] === 'string' && ortb2[prop]) utils.deepSetValue(imp, 'ext.data.pbadslot', ortb2[prop]);
} else if (prop === 'adserver') {
/**
* Copy GAM AdUnit and Name to imp
*/
['name', 'adslot'].forEach(name => {
/** @type {(string|undefined)} */
const value = utils.deepAccess(ortb2, `adserver.${name}`);
if (typeof value === 'string' && value) {
utils.deepSetValue(imp, `ext.data.adserver.${name.toLowerCase()}`, value);
}
});
} else {
utils.deepSetValue(imp, `ext.data.${prop}`, ortb2[prop]);
}
});

Expand Down Expand Up @@ -763,12 +767,12 @@ const OPEN_RTB_PROTOCOL = {
utils.deepSetValue(request, 'regs.coppa', 1);
}

const commonFpd = getConfig('fpd') || {};
if (commonFpd.context) {
utils.deepSetValue(request, 'site.ext.data', commonFpd.context);
const commonFpd = getConfig('ortb2') || {};
if (commonFpd.site) {
utils.deepSetValue(request, 'site', commonFpd.site);
}
if (commonFpd.user) {
utils.deepSetValue(request, 'user.ext.data', commonFpd.user);
utils.deepSetValue(request, 'user', commonFpd.user);
}
addBidderFirstPartyDataToRequest(request);

Expand Down
Loading

0 comments on commit d474a46

Please sign in to comment.