-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Sirdata RTD Module : bidder specific handling removal #9970
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,7 +198,7 @@ export function applyBidderOrtb2Sda(ortb2Fragments, bidder, type, segments, segt | |
|
||
export function setBidderOrtb2(bidderOrtb2Fragments, bidder, path, segments) { | ||
try { | ||
if (isEmpty(segments)) { return; } | ||
if (isEmpty(segments)) { return false; } | ||
let ortb2Conf = {}; | ||
deepSetValue(ortb2Conf, path, segments || {}); | ||
mergeDeep(bidderOrtb2Fragments, {[bidder]: ortb2Conf}); | ||
|
@@ -254,7 +254,7 @@ export function getSegAndCatsArray(data, minScore, pid) { | |
return sirdataData; | ||
} | ||
|
||
export function applySdaGetSpecificData(data, sirdataList, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit) { | ||
export function applySdaGetSpecificData(data, sirdataData, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit) { | ||
// only share SDA data if whitelisted | ||
if (!biddersParamsExist || indexFound) { | ||
// SDA Publisher | ||
|
@@ -269,7 +269,8 @@ export function applySdaGetSpecificData(data, sirdataList, biddersParamsExist, m | |
if (data.shared_taxonomy && data.shared_taxonomy[curationId]) { | ||
// Get Bidder Specific Data | ||
let curationData = getSegAndCatsArray(data.shared_taxonomy[curationId], minScore, null); | ||
sirdataList = sirdataList.concat(curationData.segments).concat(curationData.categories); | ||
sirdataData.segments = sirdataData.segments.concat(curationData.segments); | ||
sirdataData.categories = sirdataData.categories.concat(curationData.categories); | ||
|
||
// SDA Partners | ||
let curationDataForSDA = getSegAndCatsArray(data.shared_taxonomy[curationId], minScore, curationId); | ||
|
@@ -278,19 +279,22 @@ export function applySdaGetSpecificData(data, sirdataList, biddersParamsExist, m | |
} | ||
|
||
// Apply custom function or return Bidder Specific Data if publisher is ok | ||
if (sirdataList && sirdataList.length > 0 && (!biddersParamsExist || indexFound)) { | ||
if (!biddersParamsExist || indexFound) { | ||
if (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('customFunction')) { | ||
return loadCustomFunction(moduleConfig.params.bidders[bidderIndex].customFunction, adUnit, sirdataList, data, bid); | ||
return loadCustomFunction(moduleConfig.params.bidders[bidderIndex].customFunction, adUnit, sirdataData, data, bid); | ||
} else { | ||
return sirdataList; | ||
return sirdataData; | ||
} | ||
} | ||
} | ||
|
||
export function applySdaAndDefaultSpecificData(data, sirdataList, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit) { | ||
let specificData = applySdaGetSpecificData(data, sirdataList, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); | ||
if (specificData && specificData.length > 0) { | ||
setBidderOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, 'user.ext.data', {sd_rtd: specificData}); | ||
export function applySdaAndDefaultSpecificData(data, sirdataData, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit) { | ||
sirdataData = applySdaGetSpecificData(data, sirdataData, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); | ||
if (sirdataData.segments && sirdataData.segments.length > 0) { | ||
setBidderOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, 'user.ext.data', {sd_rtd: sirdataData.segments}); | ||
} | ||
if (sirdataData.categories && sirdataData.categories.length > 0) { | ||
setBidderOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, 'site.ext.data', {sd_rtd: sirdataData.categories}); | ||
} | ||
} | ||
|
||
|
@@ -301,8 +305,6 @@ export function addSegmentData(reqBids, data, moduleConfig, onDone) { | |
const globalMinScore = moduleConfig.params.hasOwnProperty('contextualMinRelevancyScore') ? moduleConfig.params.contextualMinRelevancyScore : 30; | ||
var sirdataData = getSegAndCatsArray(data, globalMinScore, null); | ||
|
||
const sirdataList = sirdataData.segments.concat(sirdataData.categories); | ||
|
||
const biddersParamsExist = (!!(moduleConfig.params && moduleConfig.params.bidders)); | ||
|
||
// Global ortb2 SDA | ||
|
@@ -320,15 +322,17 @@ export function addSegmentData(reqBids, data, moduleConfig, onDone) { | |
if (typeof window.googletag !== 'undefined' && (moduleConfig.params.setGptKeyValues || !moduleConfig.params.hasOwnProperty('setGptKeyValues'))) { | ||
try { | ||
let gptCurationId = (moduleConfig.params.gptCurationId ? moduleConfig.params.gptCurationId : (partnerIds['sdRtdForGpt'] ? partnerIds['sdRtdForGpt'] : null)); | ||
let sirdataMergedList = sirdataList; | ||
let sirdataMergedList = sirdataData.segments.concat(sirdataData.categories); | ||
if (gptCurationId && data.shared_taxonomy && data.shared_taxonomy[gptCurationId]) { | ||
let gamCurationData = getSegAndCatsArray(data.shared_taxonomy[gptCurationId], globalMinScore, null); | ||
sirdataMergedList = sirdataMergedList.concat(gamCurationData.segments).concat(gamCurationData.categories); | ||
} | ||
window.googletag.pubads().getSlots().forEach(function (n) { | ||
if (typeof n.setTargeting !== 'undefined' && sirdataMergedList && sirdataMergedList.length > 0) { | ||
n.setTargeting('sd_rtd', sirdataMergedList); | ||
} | ||
window.googletag.cmd.push(function() { | ||
window.googletag.pubads().getSlots().forEach(function (n) { | ||
if (typeof n.setTargeting !== 'undefined' && sirdataMergedList && sirdataMergedList.length > 0) { | ||
n.setTargeting('sd_rtd', sirdataMergedList); | ||
} | ||
}); | ||
}); | ||
} catch (e) { | ||
logError(e); | ||
|
@@ -340,18 +344,13 @@ export function addSegmentData(reqBids, data, moduleConfig, onDone) { | |
var indexFound = false; | ||
|
||
adUnits.forEach(adUnit => { | ||
if (!biddersParamsExist && !deepAccess(adUnit, 'ortb2Imp.ext.data.sd_rtd')) { | ||
deepSetValue(adUnit, 'ortb2Imp.ext.data.sd_rtd', sirdataList); | ||
} | ||
|
||
adUnit.hasOwnProperty('bids') && adUnit.bids.forEach(bid => { | ||
bidderIndex = (moduleConfig.params.hasOwnProperty('bidders') ? findIndex(moduleConfig.params.bidders, function (i) { | ||
return i.bidder === bid.bidder; | ||
}) : false); | ||
indexFound = (!!(typeof bidderIndex == 'number' && bidderIndex >= 0)); | ||
try { | ||
let minScore = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('contextualMinRelevancyScore') ? moduleConfig.params.bidders[bidderIndex].contextualMinRelevancyScore : globalMinScore); | ||
let specificData = null; | ||
|
||
switch (bid.bidder) { | ||
case 'appnexus': | ||
|
@@ -370,57 +369,24 @@ export function addSegmentData(reqBids, data, moduleConfig, onDone) { | |
case 'msq_classic': | ||
case 'msq_max': | ||
case '366_apx': | ||
specificData = applySdaGetSpecificData(data, sirdataList, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); | ||
if (specificData && specificData.length > 0) { | ||
deepSetValue(bid, 'params.keywords.sd_rtd', specificData); | ||
sirdataData = applySdaGetSpecificData(data, sirdataData, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); | ||
if (sirdataData.segments && sirdataData.segments.length > 0) { | ||
setBidderOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, 'user.keywords', 'sd_rtd=' + sirdataData.segments.join(',sd_rtd=')); | ||
} | ||
break; | ||
|
||
case 'smartadserver': | ||
case 'smart': | ||
specificData = applySdaGetSpecificData(data, sirdataList, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); | ||
if (specificData && specificData.length > 0) { | ||
var target = []; | ||
if (bid.hasOwnProperty('params') && bid.params.hasOwnProperty('target')) { | ||
target.push(bid.params.target); | ||
} | ||
specificData.forEach(function (entry) { | ||
if (target.indexOf('sd_rtd=' + entry) === -1) { | ||
target.push('sd_rtd=' + entry); | ||
} | ||
}); | ||
deepSetValue(bid, 'params.target', target.join(';')); | ||
} | ||
break; | ||
|
||
case 'ix': | ||
specificData = applySdaGetSpecificData(data, sirdataList, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); | ||
let ixConfig = config.getConfig('ix.firstPartyData.sd_rtd'); | ||
if (!ixConfig && specificData && specificData.length > 0) { | ||
let cappIxCategories = []; | ||
let ixLength = 0; | ||
let ixLimit = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('sizeLimit') ? moduleConfig.params.bidders[bidderIndex].sizeLimit : 1000); | ||
// Push ids For publisher use and for curation if exists but limit size because the bidder uses GET parameters | ||
specificData.forEach(function (entry) { | ||
if (ixLength < ixLimit) { | ||
cappIxCategories.push(entry); | ||
ixLength += entry.toString().length; | ||
} | ||
}); | ||
config.setConfig({ix: {firstPartyData: {sd_rtd: cappIxCategories}}}); | ||
if (sirdataData.categories && sirdataData.categories.length > 0) { | ||
setBidderOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, 'site.content.keywords', 'sd_rtd=' + sirdataData.categories.join(',sd_rtd=')); | ||
} | ||
break; | ||
|
||
case 'proxistore': | ||
specificData = applySdaGetSpecificData(data, sirdataList, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); | ||
if (specificData && specificData.length > 0) { | ||
let psCurationId = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('curationId') ? moduleConfig.params.bidders[bidderIndex].curationId : (partnerIds[bid.bidder] ? partnerIds[bid.bidder] : null)); | ||
if (!data.shared_taxonomy || !data.shared_taxonomy[psCurationId]) { | ||
data.shared_taxonomy[psCurationId] = {segments: [], contextual_categories: {}, segtaxid: null, cattaxid: null}; | ||
} | ||
let psCurationData = getSegAndCatsArray(data.shared_taxonomy[psCurationId], minScore, null); | ||
sirdataData = applySdaGetSpecificData(data, sirdataData, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); | ||
let psCurationId = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('curationId') ? moduleConfig.params.bidders[bidderIndex].curationId : (partnerIds[bid.bidder] ? partnerIds[bid.bidder] : null)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you move this logic into the proxistore adapter? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done :) |
||
if (!data.shared_taxonomy || !data.shared_taxonomy[psCurationId]) { | ||
data.shared_taxonomy[psCurationId] = {segments: [], contextual_categories: {}, segtaxid: null, cattaxid: null}; | ||
} | ||
if ((sirdataData.segments && sirdataData.segments.length > 0) || (sirdataData.categories && sirdataData.categories.length > 0)) { | ||
setBidderOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, 'user.ext.data', { | ||
segments: sirdataData.segments.concat(psCurationData.segments), | ||
segments: sirdataData.segments, | ||
contextual_categories: {...data.contextual_categories, ...data.shared_taxonomy[psCurationId].contextual_categories} | ||
}); | ||
} | ||
|
@@ -445,12 +411,15 @@ export function addSegmentData(reqBids, data, moduleConfig, onDone) { | |
case 'sublime': | ||
case 'rtbhouse': | ||
case 'mediasquare': | ||
applySdaAndDefaultSpecificData(data, sirdataList, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); | ||
case 'smartadserver': | ||
case 'smart': | ||
case 'ix': | ||
applySdaAndDefaultSpecificData(data, sirdataData, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); | ||
break; | ||
|
||
default: | ||
if (!biddersParamsExist || (indexFound && (!moduleConfig.params.bidders[bidderIndex].hasOwnProperty('adUnitCodes') || moduleConfig.params.bidders[bidderIndex].adUnitCodes.indexOf(adUnit.code) !== -1))) { | ||
applySdaAndDefaultSpecificData(data, sirdataList, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); | ||
applySdaAndDefaultSpecificData(data, sirdataData, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); | ||
} | ||
} | ||
} catch (e) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm missing some context, if the intent of this is to remove bidder-specific handling why is there a giant switch statement for a bunch of bidders?