From 4d02dd1a3b1b564f0c9d53acc467a704da3020cc Mon Sep 17 00:00:00 2001 From: nouchy <33549554+nouchy@users.noreply.github.com> Date: Tue, 6 Jun 2023 23:51:06 +0200 Subject: [PATCH] Sirdata RTD Module : bidder specific handling removal (#9970) * bidder specific handling removal move bidder specific handling to ortb2 * Revert "bidder specific handling removal" This reverts commit 6daebf348d67d1c7526cb463d0c411aedf036082. * bidder specific handling removal move bidder specific handling to ortb2 * bidder specific handling removal move Proxistore spcific logic to bidder --- modules/proxistoreBidAdapter.js | 25 +-- modules/sirdataRtdProvider.js | 219 +++++++------------ test/spec/modules/sirdataRtdProvider_spec.js | 127 +++++++++-- 3 files changed, 194 insertions(+), 177 deletions(-) diff --git a/modules/proxistoreBidAdapter.js b/modules/proxistoreBidAdapter.js index 1f113f9c432..2b5e31d535d 100644 --- a/modules/proxistoreBidAdapter.js +++ b/modules/proxistoreBidAdapter.js @@ -88,23 +88,20 @@ function _createServerRequest(bidRequests, bidderRequest) { } function _assignSegments(bid) { - if ( - bid.ortb2 && - bid.ortb2.user && - bid.ortb2.user.ext && - bid.ortb2.user.ext.data - ) { - return ( - bid.ortb2.user.ext.data || { - segments: [], - contextual_categories: {}, - } - ); + var segs = (bid.ortb2 && bid.ortb2.user && bid.ortb2.user.ext && bid.ortb2.user.ext.data && bid.ortb2.user.ext.data.sd_rtd && bid.ortb2.user.ext.data.sd_rtd.segments ? bid.ortb2.user.ext.data.sd_rtd.segments : []); + var cats = {}; + if (bid.ortb2 && bid.ortb2.site && bid.ortb2.site.ext && bid.ortb2.site.ext.data && bid.ortb2.site.ext.data.sd_rtd) { + if (bid.ortb2.site.ext.data.sd_rtd.categories) { + segs = segs.concat(bid.ortb2.site.ext.data.sd_rtd.categories); + } + if (bid.ortb2.site.ext.data.sd_rtd.categories_score) { + cats = bid.ortb2.site.ext.data.sd_rtd.categories_score; + } } return { - segments: [], - contextual_categories: {}, + segments: segs, + contextual_categories: cats }; } diff --git a/modules/sirdataRtdProvider.js b/modules/sirdataRtdProvider.js index 40ee3d8b973..aaa3c48856b 100644 --- a/modules/sirdataRtdProvider.js +++ b/modules/sirdataRtdProvider.js @@ -134,44 +134,24 @@ export function getSegmentsAndCategories(reqBidsConfigObj, onDone, moduleConfig, }); } -export function setGlobalOrtb2Sda(ortb2Fragments, data, segtaxid, cattaxid) { +export function pushToOrtb2(ortb2Fragments, bidder, data, segtaxid, cattaxid) { try { if (!isEmpty(data.segments)) { - applyGlobalOrtb2Sda(ortb2Fragments, 'user', data.segments, segtaxid); + if (segtaxid) { + setOrtb2Sda(ortb2Fragments, bidder, 'user', data.segments, segtaxid); + } else { + setOrtb2(ortb2Fragments, bidder, 'user.ext.data', {sd_rtd: {segments: data.segments}}); + } } if (!isEmpty(data.categories)) { - applyGlobalOrtb2Sda(ortb2Fragments, 'site', data.categories, cattaxid); - } - } catch (e) { - logError(e) - } - return true; -} - -export function applyGlobalOrtb2Sda(ortb2Fragments, type, segments, segtaxValue) { - try { - let ortb2Data = [{ - name: ORTB2_NAME, - segment: segments.map((segmentId) => ({ id: segmentId })), - }]; - if (segtaxValue) { - ortb2Data[0].ext = { segtax: segtaxValue }; - } - let ortb2Conf = (type == 'site' ? {site: {content: {data: ortb2Data}}} : {user: {data: ortb2Data}}); - mergeDeep(ortb2Fragments, ortb2Conf); - } catch (e) { - logError(e) - } - return true; -} - -export function setBidderOrtb2Sda(ortb2Fragments, bidder, data, segtaxid, cattaxid) { - try { - if (!isEmpty(data.segments)) { - applyBidderOrtb2Sda(ortb2Fragments, bidder, 'user', data.segments, segtaxid); + if (cattaxid) { + setOrtb2Sda(ortb2Fragments, bidder, 'site', data.categories, cattaxid); + } else { + setOrtb2(ortb2Fragments, bidder, 'site.ext.data', {sd_rtd: {categories: data.categories}}); + } } - if (!isEmpty(data.categories)) { - applyBidderOrtb2Sda(ortb2Fragments, bidder, 'site', data.categories, cattaxid); + if (!isEmpty(data.categories_score) && !cattaxid) { + setOrtb2(ortb2Fragments, bidder, 'site.ext.data', {sd_rtd: {categories_score: data.categories_score}}); } } catch (e) { logError(e) @@ -179,7 +159,7 @@ export function setBidderOrtb2Sda(ortb2Fragments, bidder, data, segtaxid, cattax return true; } -export function applyBidderOrtb2Sda(ortb2Fragments, bidder, type, segments, segtaxValue) { +export function setOrtb2Sda(ortb2Fragments, bidder, type, segments, segtaxValue) { try { let ortb2Data = [{ name: ORTB2_NAME, @@ -189,19 +169,25 @@ export function applyBidderOrtb2Sda(ortb2Fragments, bidder, type, segments, segt ortb2Data[0].ext = { segtax: segtaxValue }; } let ortb2Conf = (type == 'site' ? {site: {content: {data: ortb2Data}}} : {user: {data: ortb2Data}}); - mergeDeep(ortb2Fragments, {[bidder]: ortb2Conf}); + if (bidder) { + ortb2Conf = {[bidder]: ortb2Conf}; + } + mergeDeep(ortb2Fragments, ortb2Conf); } catch (e) { logError(e) } return true; } -export function setBidderOrtb2(bidderOrtb2Fragments, bidder, path, segments) { +export function setOrtb2(ortb2Fragments, bidder, path, segments) { try { - if (isEmpty(segments)) { return; } + if (isEmpty(segments)) { return false; } let ortb2Conf = {}; deepSetValue(ortb2Conf, path, segments || {}); - mergeDeep(bidderOrtb2Fragments, {[bidder]: ortb2Conf}); + if (bidder) { + ortb2Conf = {[bidder]: ortb2Conf}; + } + mergeDeep(ortb2Fragments, ortb2Conf); } catch (e) { logError(e) } @@ -221,15 +207,22 @@ export function loadCustomFunction(todo, adUnit, list, data, bid) { } export function getSegAndCatsArray(data, minScore, pid) { - let sirdataData = {'segments': [], 'categories': []}; + let sirdataData = {'segments': [], 'categories': [], 'categories_score': {}}; minScore = minScore && typeof minScore == 'number' ? minScore : 30; + let cattaxid = data.cattaxid || null; + let segtaxid = data.segtaxid || null; try { if (data && data.contextual_categories) { for (let catId in data.contextual_categories) { if (data.contextual_categories.hasOwnProperty(catId) && data.contextual_categories[catId]) { let value = data.contextual_categories[catId]; if (value >= minScore && sirdataData.categories.indexOf(catId) === -1) { - sirdataData.categories.push((pid ? pid.toString() + 'cc' : '') + catId.toString()); + if (pid && cattaxid) { + sirdataData.categories.push(pid.toString() + 'cc' + catId.toString()); + } else { + sirdataData.categories.push(catId.toString()); + sirdataData.categories_score[catId] = value; + } } } } @@ -241,9 +234,16 @@ export function getSegAndCatsArray(data, minScore, pid) { if (data && data.segments) { for (let segId in data.segments) { if (data.segments.hasOwnProperty(segId) && data.segments[segId]) { - sirdataData.segments.push((pid ? pid.toString() + 'us' : '') + data.segments[segId].toString()); + let id = data.segments[segId].toString(); if (pid && CONTEXT_ONLY) { - sirdataData.categories.push(pid.toString() + 'uc' + data.segments[segId].toString()); + if (segtaxid) { + sirdataData.categories.push(pid.toString() + 'uc' + id); + } else { + sirdataData.categories.push(id); + sirdataData.categories_score[id] = 100; + } + } else { + sirdataData.segments.push((pid && segtaxid) ? pid.toString() + 'us' + id : id); } } } @@ -254,12 +254,12 @@ 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 let sirdataDataForSDA = getSegAndCatsArray(data, minScore, moduleConfig.params.partnerId); - setBidderOrtb2Sda(reqBids.ortb2Fragments?.bidder, bid.bidder, sirdataDataForSDA, data.segtaxid, data.cattaxid); + pushToOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, sirdataDataForSDA, data.segtaxid, data.cattaxid); } // always share SDA for curation @@ -268,30 +268,31 @@ export function applySdaGetSpecificData(data, sirdataList, biddersParamsExist, m // seller defined audience & bidder specific data 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); - - // SDA Partners - let curationDataForSDA = getSegAndCatsArray(data.shared_taxonomy[curationId], minScore, curationId); - setBidderOrtb2Sda(reqBids.ortb2Fragments?.bidder, bid.bidder, curationDataForSDA, data.shared_taxonomy[curationId].segtaxid, data.shared_taxonomy[curationId].cattaxid); + let curationData = getSegAndCatsArray(data.shared_taxonomy[curationId], minScore, curationId); + pushToOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, curationData, data.shared_taxonomy[curationId].segtaxid, data.shared_taxonomy[curationId].cattaxid); } } // 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) { + setOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, 'user.ext.data', {sd_rtd: sirdataData.segments}); } + if (sirdataData.categories && sirdataData.categories.length > 0) { + setOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, 'site.ext.data', {sd_rtd: sirdataData.categories}); + } + */ } export function addSegmentData(reqBids, data, moduleConfig, onDone) { @@ -301,17 +302,15 @@ 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 if (data.global_taxonomy && !isEmpty(data.global_taxonomy)) { - let globalData = {'segments': [], 'categories': []}; + let globalData = {'segments': [], 'categories': [], 'categories_score': []}; for (let i in data.global_taxonomy) { if (!isEmpty(data.global_taxonomy[i])) { globalData = getSegAndCatsArray(data.global_taxonomy[i], globalMinScore, null); - setGlobalOrtb2Sda(reqBids.ortb2Fragments?.global, globalData, data.global_taxonomy[i].segtaxid, data.global_taxonomy[i].cattaxid); + pushToOrtb2(reqBids.ortb2Fragments?.global, null, globalData, data.global_taxonomy[i].segtaxid, data.global_taxonomy[i].cattaxid); } } } @@ -320,15 +319,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,10 +341,6 @@ 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; @@ -351,7 +348,6 @@ export function addSegmentData(reqBids, data, moduleConfig, onDone) { 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,87 +366,18 @@ 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) { + setOrtb2(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(';')); + if (sirdataData.categories && sirdataData.categories.length > 0) { + setOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, 'site.content.keywords', 'sd_rtd=' + sirdataData.categories.join(',sd_rtd=')); } 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}}}); - } - 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); - setBidderOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, 'user.ext.data', { - segments: sirdataData.segments.concat(psCurationData.segments), - contextual_categories: {...data.contextual_categories, ...data.shared_taxonomy[psCurationId].contextual_categories} - }); - } - break; - - case 'rubicon': - case 'criteo': - case 'triplelift': - case 'smaato': - case 'yahoossp': - case 'openx': - case 'pubmatic': - case 'smilewanted': - case 'taboola': - case 'ttd': - case 'zeta_global': - case 'zeta_global_ssp': - case 'teads': - case 'conversant': - case 'improvedigital': - case 'invibes': - case 'sublime': - case 'rtbhouse': - case 'mediasquare': - applySdaAndDefaultSpecificData(data, sirdataList, 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) { diff --git a/test/spec/modules/sirdataRtdProvider_spec.js b/test/spec/modules/sirdataRtdProvider_spec.js index eccc4777906..fbb5967bc20 100644 --- a/test/spec/modules/sirdataRtdProvider_spec.js +++ b/test/spec/modules/sirdataRtdProvider_spec.js @@ -1,26 +1,31 @@ -import {addSegmentData, getSegmentsAndCategories, sirdataSubmodule} from 'modules/sirdataRtdProvider.js'; +import {addSegmentData, getSegmentsAndCategories, sirdataSubmodule, setOrtb2} from 'modules/sirdataRtdProvider.js'; import {server} from 'test/mocks/xhr.js'; const responseHeader = {'Content-Type': 'application/json'}; describe('sirdataRtdProvider', function () { describe('sirdataSubmodule', function () { + it('exists', function () { + expect(sirdataSubmodule.init).to.be.a('function'); + }); it('successfully instantiates', function () { expect(sirdataSubmodule.init()).to.equal(true); }); + it('has the correct module name', function () { + expect(sirdataSubmodule.name).to.equal('SirdataRTDModule'); + }); }); describe('Add Segment Data', function () { it('adds segment data', function () { - const config = { + const firstConfig = { params: { - setGptKeyValues: false, + partnerId: 1, + key: 1, + setGptKeyValues: true, + gptCurationId: 27449, contextualMinRelevancyScore: 50, - bidders: [{ - bidder: 'appnexus' - }, { - bidder: 'other' - }] + bidders: [] } }; @@ -37,21 +42,47 @@ describe('sirdataRtdProvider', function () { } ]; - let data = { + let firstReqBidsConfigObj = { + adUnits: adUnits, + ortb2Fragments: { + global: {} + } + }; + + let firstData = { segments: [111111, 222222], - contextual_categories: {'333333': 100} + contextual_categories: {'333333': 100}, + 'segtaxid': null, + 'cattaxid': null, + 'shared_taxonomy': { + '27449': { + 'segments': [444444, 555555], + 'segtaxid': null, + 'cattaxid': null, + 'contextual_categories': {'666666': 100} + } + }, + 'global_taxonomy': { + '9998': { + 'segments': [123, 234], + 'segtaxid': 4, + 'cattaxid': 7, + 'contextual_categories': {'345': 100, '456': 100} + } + } }; - addSegmentData({adUnits}, data, config, () => { + addSegmentData(firstReqBidsConfigObj, firstData, firstConfig, () => { }); - expect(adUnits[0].bids[0].params.keywords).to.have.deep.property('sd_rtd', ['111111', '222222', '333333']); + + expect(firstReqBidsConfigObj.ortb2Fragments.global.user.data[0].ext.segtax).to.equal(4); }); }); describe('Get Segments And Categories', function () { it('gets data from async request and adds segment data', function () { const overrideAppnexus = function (adUnit, list, data, bid) { - deepSetValue(bid, 'params.keywords.custom', list); + deepSetValue(bid, 'params.keywords.custom', list.segments.concat(list.categories)); } const config = { @@ -60,16 +91,21 @@ describe('sirdataRtdProvider', function () { contextualMinRelevancyScore: 50, bidders: [{ bidder: 'appnexus', - customFunction: overrideAppnexus + customFunction: overrideAppnexus, + curationId: 27446 }, { - bidder: 'smartadserver' + bidder: 'smartadserver', + curationId: 27440 }, { bidder: 'ix', sizeLimit: 1200, + curationId: 27248 }, { bidder: 'rubicon', + curationId: 27452 }, { bidder: 'proxistore', + curationId: 27484 }] } }; @@ -146,6 +182,12 @@ describe('sirdataRtdProvider', function () { 'segtaxid': 552, 'cattaxid': 553, 'contextual_categories': {'666666': 100} + }, + '27446': { + 'segments': [777777, 888888], + 'segtaxid': 552, + 'cattaxid': 553, + 'contextual_categories': {'999999': 100} } }, 'global_taxonomy': { @@ -164,8 +206,6 @@ describe('sirdataRtdProvider', function () { let request = server.requests[0]; request.respond(200, responseHeader, JSON.stringify(data)); - expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.have.deep.property('target', 'sd_rtd=111111;sd_rtd=222222;sd_rtd=333333;sd_rtd=444444;sd_rtd=555555;sd_rtd=666666'); - expect(reqBidsConfigObj.ortb2Fragments.global.site.content.data[0].name).to.equal( 'sirdata.com' ); @@ -185,4 +225,57 @@ describe('sirdataRtdProvider', function () { expect(reqBidsConfigObj.ortb2Fragments.global.user.data[0].ext.segtax).to.equal(4); }); }); + + describe('Set ortb2 for bidder', function () { + it('set ortb2 for a givent bidder', function () { + const config = { + params: { + setGptKeyValues: false, + contextualMinRelevancyScore: 50, + bidders: [{ + bidder: 'appnexus', + }] + } + }; + + let reqBidsConfigObj = { + adUnits: [{ + bids: [{ + bidder: 'appnexus', + params: { + placementId: 13144370 + } + }] + }], + ortb2Fragments: { + global: {} + } + }; + + let data = { + 'segments': [111111, 222222], + 'segtaxid': null, + 'cattaxid': null, + 'contextual_categories': {'333333': 100}, + 'shared_taxonomy': { + '27440': { + 'segments': [444444, 555555], + 'segtaxid': null, + 'cattaxid': null, + 'contextual_categories': {'666666': 100} + } + }, + 'global_taxonomy': {} + }; + + window.googletag = window.googletag || {}; + window.googletag.cmd = window.googletag.cmd || []; + + let test = setOrtb2(reqBidsConfigObj.ortb2Fragments, 'appnexus', 'user', []); + expect(test).to.be.false; + + test = setOrtb2(reqBidsConfigObj.ortb2Fragments, 'appnexus', 'user', ['1']); + expect(test).to.be.true; + }); + }); });