From 4676ba298faf3aaac9067c24a0bb502004b5bd30 Mon Sep 17 00:00:00 2001 From: Andrew Slagle <42588549+spotxslagle@users.noreply.github.com> Date: Fri, 12 Jan 2024 09:30:20 -0700 Subject: [PATCH 01/14] Pass through Carbon segments --- modules/rubiconBidAdapter.js | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index e9556b9afc6..a97ade072b3 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -177,6 +177,11 @@ export const converter = ortbConverter({ delete data?.ext?.prebid?.storedrequest; + let carbonTopics = fetchCarbonTopics(); + if (carbonTopics.length > 0) { + deepSetValue(data, 'user.data', carbonTopics); + } + // floors if (rubiConf.disableFloors === true) { delete data.ext.prebid.floors; @@ -528,6 +533,15 @@ export const spec = { if (bidRequest?.ortb2Imp?.ext?.ae) { data['o_ae'] = 1; } + + const topics = readCarbonTopics(); + if (topics) { + const domain = bidderRequest.refererInfo.domain + Object.keys(topics).forEach(taxonomy => { + const field = `s_segs_${taxonomy}_${domain}`; + data[field] = topics[taxonomy]; + }); + } // loop through userIds and add to request if (bidRequest.userIdAsEids) { bidRequest.userIdAsEids.forEach(eid => { @@ -1001,6 +1015,34 @@ function applyFPD(bidRequest, mediaType, data) { } } + +function fetchCarbonTopics() { + let topics = []; + if (rubiConf.readTopics === false ? false : true) { + topics = config.getConfig('user.data').filter(topic => { + const taxonomy = topic.taxonomyVersion; + return taxonomy == 507 || taxonomy == 508; + }); + } + return topics +} + +function readCarbonTopics() { + let topics = {}; + let carbonTopics = fetchCarbonTopics(); + carbonTopics.forEach(topic => { + const taxonomy = topic.taxonomyVersion; + if (topics[taxonomy]) { + topics[taxonomy] = topics[taxonomy] + ',' + topic.topic; + } else { + topics[taxonomy] = '' + topic.topic; + } + + }) + let hasProps = Object.keys(topics) > 0; + return hasProps ? topics : undefined; +} + /** * @param sizes * @returns {*} From 0b282fe64ad15277ec634b4cdfb460bd56ac5052 Mon Sep 17 00:00:00 2001 From: Andrew Slagle <42588549+spotxslagle@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:34:06 -0700 Subject: [PATCH 02/14] Fix rubiconBidAdapter for unit tests --- modules/rubiconBidAdapter.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index a97ade072b3..7c16263b5ef 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -178,7 +178,7 @@ export const converter = ortbConverter({ delete data?.ext?.prebid?.storedrequest; let carbonTopics = fetchCarbonTopics(); - if (carbonTopics.length > 0) { + if (carbonTopics?.length > 0) { deepSetValue(data, 'user.data', carbonTopics); } @@ -1015,14 +1015,13 @@ function applyFPD(bidRequest, mediaType, data) { } } - function fetchCarbonTopics() { let topics = []; - if (rubiConf.readTopics === false ? false : true) { - topics = config.getConfig('user.data').filter(topic => { + if (rubiConf.readTopics !== false) { + topics = config.getConfig('user.data')?.filter(topic => { const taxonomy = topic.taxonomyVersion; return taxonomy == 507 || taxonomy == 508; - }); + }) || topics; } return topics } @@ -1037,9 +1036,8 @@ function readCarbonTopics() { } else { topics[taxonomy] = '' + topic.topic; } - }) - let hasProps = Object.keys(topics) > 0; + let hasProps = Object.keys(topics).length > 0; return hasProps ? topics : undefined; } From 8206da4d9455b53c330c88b3a85dff7dd2f7f11c Mon Sep 17 00:00:00 2001 From: Andrew Slagle <42588549+spotxslagle@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:35:36 -0700 Subject: [PATCH 03/14] segtax spec --- test/spec/modules/rubiconBidAdapter_spec.js | 55 +++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index f0e33ce940e..00bed2b6057 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -1949,6 +1949,28 @@ describe('the rubicon adapter', function () { bidderRequest.auctionStart + 100 ); + sandbox.stub(config, 'getConfig') + .withArgs('user.data') + .onFirstCall().returns([{ + taxonomyVersion: 404, + topic: '5' + }, { + taxonomyVersion: '404', + topic: '6' + }, { + taxonomyVersion: '507', + topic: '1' + }, { + taxonomyVersion: 507, + topic: '2' + }, { + taxonomyVersion: 508, + topic: '3' + }, { + taxonomyVersion: '508', + topic: '4' + }]); + let [request] = spec.buildRequests(bidderRequest.bids, syncAddFPDToBidderRequest(bidderRequest)); let post = request.data; @@ -1969,6 +1991,10 @@ describe('the rubicon adapter', function () { expect(imp.ext.prebid.bidder.rubicon.video.playerHeight).to.equal(480); expect(imp.ext.prebid.bidder.rubicon.video.size_id).to.equal(201); expect(imp.ext.prebid.bidder.rubicon.video.language).to.equal('en'); + expect(post.user.data[0]).to.deep.equal({'taxonomyVersion': '507', 'topic': '1'}); + expect(post.user.data[1]).to.deep.equal({'taxonomyVersion': 507, 'topic': '2'}); + expect(post.user.data[2]).to.deep.equal({'taxonomyVersion': 508, 'topic': '3'}); + expect(post.user.data[3]).to.deep.equal({'taxonomyVersion': '508', 'topic': '4'}); // Also want it to be in post.site.content.language expect(imp.ext.prebid.bidder.rubicon.video.skip).to.equal(1); expect(imp.ext.prebid.bidder.rubicon.video.skipafter).to.equal(15); @@ -2718,6 +2744,35 @@ describe('the rubicon adapter', function () { expect(slotParams['o_ae']).to.equal(1) }); + + it('should pass along Carbon segtaxes, but not non-Carbon ones', () => { + const localBidderRequest = Object.assign({}, bidderRequest); + localBidderRequest.refererInfo = {domain: 'bob'}; + sandbox.stub(config, 'getConfig') + .onFirstCall().returns(1) + .onSecondCall().returns([{ + taxonomyVersion: 404, + topic: '5' + }, { + taxonomyVersion: '404', + topic: '6' + }, { + taxonomyVersion: '507', + topic: '1' + }, { + taxonomyVersion: 507, + topic: '2' + }, { + taxonomyVersion: 508, + topic: '3' + }, { + taxonomyVersion: '508', + topic: '4' + }]); + const slotParams = spec.createSlotParams(bidderRequest.bids[0], localBidderRequest); + expect(slotParams.s_segs_507_bob).is.equal('1,2'); + expect(slotParams.s_segs_508_bob).is.equal('3,4'); + }); }); describe('classifiedAsVideo', function () { From f92e8e6c7ba68c63ba30dec9def7b5003820bb56 Mon Sep 17 00:00:00 2001 From: Andrew Slagle <42588549+spotxslagle@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:14:38 -0700 Subject: [PATCH 04/14] Fix access issues --- modules/rubiconBidAdapter.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 7c16263b5ef..68c4c3c69b4 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -177,7 +177,7 @@ export const converter = ortbConverter({ delete data?.ext?.prebid?.storedrequest; - let carbonTopics = fetchCarbonTopics(); + let carbonTopics = fetchCarbonTopics(bidderRequest); if (carbonTopics?.length > 0) { deepSetValue(data, 'user.data', carbonTopics); } @@ -534,7 +534,7 @@ export const spec = { data['o_ae'] = 1; } - const topics = readCarbonTopics(); + const topics = readCarbonTopics(bidderRequest); if (topics) { const domain = bidderRequest.refererInfo.domain Object.keys(topics).forEach(taxonomy => { @@ -1015,27 +1015,23 @@ function applyFPD(bidRequest, mediaType, data) { } } -function fetchCarbonTopics() { +function fetchCarbonTopics(bidderRequest) { let topics = []; if (rubiConf.readTopics !== false) { - topics = config.getConfig('user.data')?.filter(topic => { - const taxonomy = topic.taxonomyVersion; + topics = bidderRequest.ortb2?.user?.data?.filter(topic => { + const taxonomy = topic.ext?.segtax; return taxonomy == 507 || taxonomy == 508; }) || topics; } return topics } -function readCarbonTopics() { +function readCarbonTopics(bidderRequest) { let topics = {}; - let carbonTopics = fetchCarbonTopics(); + let carbonTopics = fetchCarbonTopics(bidderRequest); carbonTopics.forEach(topic => { - const taxonomy = topic.taxonomyVersion; - if (topics[taxonomy]) { - topics[taxonomy] = topics[taxonomy] + ',' + topic.topic; - } else { - topics[taxonomy] = '' + topic.topic; - } + const taxonomy = topic.ext?.segtax; + topics[taxonomy] = topic.segments.forEach(seg => seg.id).join(',') }) let hasProps = Object.keys(topics).length > 0; return hasProps ? topics : undefined; From 23761e3d6160ccb8bd0b08ae86dca4d6a646485a Mon Sep 17 00:00:00 2001 From: Andrew Slagle <42588549+spotxslagle@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:01:03 -0700 Subject: [PATCH 05/14] Remove dup ortb2 work --- modules/rubiconBidAdapter.js | 41 ++++++++++++------------------------ 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 68c4c3c69b4..80f1b103b7c 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -177,11 +177,6 @@ export const converter = ortbConverter({ delete data?.ext?.prebid?.storedrequest; - let carbonTopics = fetchCarbonTopics(bidderRequest); - if (carbonTopics?.length > 0) { - deepSetValue(data, 'user.data', carbonTopics); - } - // floors if (rubiConf.disableFloors === true) { delete data.ext.prebid.floors; @@ -534,12 +529,10 @@ export const spec = { data['o_ae'] = 1; } - const topics = readCarbonTopics(bidderRequest); + const topics = getCarbonTopics(bidderRequest); if (topics) { - const domain = bidderRequest.refererInfo.domain - Object.keys(topics).forEach(taxonomy => { - const field = `s_segs_${taxonomy}_${domain}`; - data[field] = topics[taxonomy]; + Object.keys(topics).forEach(field => { + data[field] = topics[field]; }); } // loop through userIds and add to request @@ -1015,26 +1008,20 @@ function applyFPD(bidRequest, mediaType, data) { } } -function fetchCarbonTopics(bidderRequest) { - let topics = []; - if (rubiConf.readTopics !== false) { - topics = bidderRequest.ortb2?.user?.data?.filter(topic => { - const taxonomy = topic.ext?.segtax; - return taxonomy == 507 || taxonomy == 508; - }) || topics; +function getCarbonTopics(bidderRequest) { + if (rubiConf.readTopics === false) { + return undefined; } - return topics -} - -function readCarbonTopics(bidderRequest) { - let topics = {}; - let carbonTopics = fetchCarbonTopics(bidderRequest); - carbonTopics.forEach(topic => { + let fields = {}; + bidderRequest.ortb2?.user?.data?.forEach(topic => { const taxonomy = topic.ext?.segtax; - topics[taxonomy] = topic.segments.forEach(seg => seg.id).join(',') + if (taxonomy == 507 || taxonomy == 508) { + const domain = bidderRequest.refererInfo.domain; + fields[`s_segs_${taxonomy}_${domain}`] = topic.segment?.map(seg => seg.id).join(',') + } }) - let hasProps = Object.keys(topics).length > 0; - return hasProps ? topics : undefined; + let hasProps = Object.keys(fields).length > 0; + return hasProps ? fields : undefined; } /** From 36ddddf581dc979ce23f1a743fa5699de32fbf8a Mon Sep 17 00:00:00 2001 From: Andrew Slagle <42588549+spotxslagle@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:06:37 -0700 Subject: [PATCH 06/14] Adjust unit tests --- test/spec/modules/rubiconBidAdapter_spec.js | 61 ++++++--------------- 1 file changed, 16 insertions(+), 45 deletions(-) diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index 00bed2b6057..56d2f08c475 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -1949,28 +1949,6 @@ describe('the rubicon adapter', function () { bidderRequest.auctionStart + 100 ); - sandbox.stub(config, 'getConfig') - .withArgs('user.data') - .onFirstCall().returns([{ - taxonomyVersion: 404, - topic: '5' - }, { - taxonomyVersion: '404', - topic: '6' - }, { - taxonomyVersion: '507', - topic: '1' - }, { - taxonomyVersion: 507, - topic: '2' - }, { - taxonomyVersion: 508, - topic: '3' - }, { - taxonomyVersion: '508', - topic: '4' - }]); - let [request] = spec.buildRequests(bidderRequest.bids, syncAddFPDToBidderRequest(bidderRequest)); let post = request.data; @@ -1991,10 +1969,6 @@ describe('the rubicon adapter', function () { expect(imp.ext.prebid.bidder.rubicon.video.playerHeight).to.equal(480); expect(imp.ext.prebid.bidder.rubicon.video.size_id).to.equal(201); expect(imp.ext.prebid.bidder.rubicon.video.language).to.equal('en'); - expect(post.user.data[0]).to.deep.equal({'taxonomyVersion': '507', 'topic': '1'}); - expect(post.user.data[1]).to.deep.equal({'taxonomyVersion': 507, 'topic': '2'}); - expect(post.user.data[2]).to.deep.equal({'taxonomyVersion': 508, 'topic': '3'}); - expect(post.user.data[3]).to.deep.equal({'taxonomyVersion': '508', 'topic': '4'}); // Also want it to be in post.site.content.language expect(imp.ext.prebid.bidder.rubicon.video.skip).to.equal(1); expect(imp.ext.prebid.bidder.rubicon.video.skipafter).to.equal(15); @@ -2748,27 +2722,24 @@ describe('the rubicon adapter', function () { it('should pass along Carbon segtaxes, but not non-Carbon ones', () => { const localBidderRequest = Object.assign({}, bidderRequest); localBidderRequest.refererInfo = {domain: 'bob'}; - sandbox.stub(config, 'getConfig') - .onFirstCall().returns(1) - .onSecondCall().returns([{ - taxonomyVersion: 404, - topic: '5' - }, { - taxonomyVersion: '404', - topic: '6' - }, { - taxonomyVersion: '507', - topic: '1' - }, { - taxonomyVersion: 507, - topic: '2' + localBidderRequest.ortb2.user = { + data: [{ + ext: { + segtax: '404' + }, + segment: [{id: 5}, {id: 6}] }, { - taxonomyVersion: 508, - topic: '3' + ext: { + segtax: '507' + }, + segment: [{id: 1}, {id: 2}] }, { - taxonomyVersion: '508', - topic: '4' - }]); + ext: { + segtax: '508' + }, + segment: [{id: 3}, {id: 4}] + }] + } const slotParams = spec.createSlotParams(bidderRequest.bids[0], localBidderRequest); expect(slotParams.s_segs_507_bob).is.equal('1,2'); expect(slotParams.s_segs_508_bob).is.equal('3,4'); From 87a2175d5c39ff3352e65510a93ac4ac192175d4 Mon Sep 17 00:00:00 2001 From: Andrew Slagle <42588549+spotxslagle@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:59:45 -0700 Subject: [PATCH 07/14] Fix lint issues --- modules/rubiconBidAdapter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 80f1b103b7c..6d12ab6c04e 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -1013,7 +1013,8 @@ function getCarbonTopics(bidderRequest) { return undefined; } let fields = {}; - bidderRequest.ortb2?.user?.data?.forEach(topic => { + let userData = bidderRequest.ortb2?.user?.data || []; + userData.forEach(topic => { const taxonomy = topic.ext?.segtax; if (taxonomy == 507 || taxonomy == 508) { const domain = bidderRequest.refererInfo.domain; From 02a95918e60d61074094edd3a359915325c66cb4 Mon Sep 17 00:00:00 2001 From: Andrew Slagle <42588549+spotxslagle@users.noreply.github.com> Date: Wed, 14 Feb 2024 11:43:49 -0700 Subject: [PATCH 08/14] Add all desired segtaxes --- modules/rubiconBidAdapter.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 6d12ab6c04e..4ef21d1d2f7 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -529,12 +529,8 @@ export const spec = { data['o_ae'] = 1; } - const topics = getCarbonTopics(bidderRequest); - if (topics) { - Object.keys(topics).forEach(field => { - data[field] = topics[field]; - }); - } + addDesiredSegtaxes(bidderRequest, data); + // loop through userIds and add to request if (bidRequest.userIdAsEids) { bidRequest.userIdAsEids.forEach(eid => { @@ -1008,21 +1004,20 @@ function applyFPD(bidRequest, mediaType, data) { } } -function getCarbonTopics(bidderRequest) { +function addDesiredSegtaxes(bidderRequest, target) { if (rubiConf.readTopics === false) { - return undefined; + return; } - let fields = {}; + let iSegments = [1, 2, 5, 6, 507].concat(rubiConf.sendUserSegtax?.map(seg => Number(seg))); + let vSegments = [4, 508].concat(rubiConf.sendSiteSegtax?.map(seg => Number(seg))); let userData = bidderRequest.ortb2?.user?.data || []; userData.forEach(topic => { - const taxonomy = topic.ext?.segtax; - if (taxonomy == 507 || taxonomy == 508) { - const domain = bidderRequest.refererInfo.domain; - fields[`s_segs_${taxonomy}_${domain}`] = topic.segment?.map(seg => seg.id).join(',') + const taxonomy = Number(topic.ext?.segtax); + let char; + if ((iSegments.includes(taxonomy) && (char = 'i')) || (vSegments.includes(taxonomy) && (char = 'v'))) { + target[`tg_${char}.tax${taxonomy}`] = topic.segment?.map(seg => seg.id).join(',') } }) - let hasProps = Object.keys(fields).length > 0; - return hasProps ? fields : undefined; } /** From 905df9920a71fe158a7ab851f2bed3881ea36134 Mon Sep 17 00:00:00 2001 From: Andrew Slagle <42588549+spotxslagle@users.noreply.github.com> Date: Wed, 14 Feb 2024 11:44:37 -0700 Subject: [PATCH 09/14] Fix unit tests --- test/spec/modules/rubiconBidAdapter_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index 56d2f08c475..b30c4b850aa 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -2741,8 +2741,8 @@ describe('the rubicon adapter', function () { }] } const slotParams = spec.createSlotParams(bidderRequest.bids[0], localBidderRequest); - expect(slotParams.s_segs_507_bob).is.equal('1,2'); - expect(slotParams.s_segs_508_bob).is.equal('3,4'); + expect(slotParams['tg_i.tax507']).is.equal('1,2'); + expect(slotParams['tg_v.tax508']).is.equal('3,4'); }); }); From 41e5e27fc50f4aab1c06f305395be5890ed557b3 Mon Sep 17 00:00:00 2001 From: Andrew Slagle <42588549+spotxslagle@users.noreply.github.com> Date: Wed, 14 Feb 2024 11:58:22 -0700 Subject: [PATCH 10/14] Fix linting --- modules/rubiconBidAdapter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 4ef21d1d2f7..7fdedefc98d 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -530,7 +530,6 @@ export const spec = { } addDesiredSegtaxes(bidderRequest, data); - // loop through userIds and add to request if (bidRequest.userIdAsEids) { bidRequest.userIdAsEids.forEach(eid => { From c8e5a2695892e210ff033782effb9e7fca59003f Mon Sep 17 00:00:00 2001 From: Andrew Slagle <42588549+spotxslagle@users.noreply.github.com> Date: Wed, 14 Feb 2024 12:09:33 -0700 Subject: [PATCH 11/14] Don't concat undefined --- modules/rubiconBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 7fdedefc98d..5db23a45e5c 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -1007,8 +1007,8 @@ function addDesiredSegtaxes(bidderRequest, target) { if (rubiConf.readTopics === false) { return; } - let iSegments = [1, 2, 5, 6, 507].concat(rubiConf.sendUserSegtax?.map(seg => Number(seg))); - let vSegments = [4, 508].concat(rubiConf.sendSiteSegtax?.map(seg => Number(seg))); + let iSegments = [1, 2, 5, 6, 507].concat(rubiConf.sendUserSegtax?.map(seg => Number(seg)) || []); + let vSegments = [4, 508].concat(rubiConf.sendSiteSegtax?.map(seg => Number(seg)) || []); let userData = bidderRequest.ortb2?.user?.data || []; userData.forEach(topic => { const taxonomy = Number(topic.ext?.segtax); From 9916193f3a63b278a6fe034286b70047dd39ae73 Mon Sep 17 00:00:00 2001 From: Andrew Slagle <42588549+spotxslagle@users.noreply.github.com> Date: Wed, 14 Feb 2024 12:21:10 -0700 Subject: [PATCH 12/14] Unit test pub added segtaxes --- test/spec/modules/rubiconBidAdapter_spec.js | 26 ++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index b30c4b850aa..40d3d2da774 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -2719,9 +2719,15 @@ describe('the rubicon adapter', function () { expect(slotParams['o_ae']).to.equal(1) }); - it('should pass along Carbon segtaxes, but not non-Carbon ones', () => { + it('should pass along desired segtaxes, but not non-desired ones', () => { const localBidderRequest = Object.assign({}, bidderRequest); localBidderRequest.refererInfo = {domain: 'bob'}; + config.setConfig({ + rubicon: { + sendUserSegtax: [9], + sendSiteSegtax: [10] + } + }); localBidderRequest.ortb2.user = { data: [{ ext: { @@ -2733,6 +2739,21 @@ describe('the rubicon adapter', function () { segtax: '507' }, segment: [{id: 1}, {id: 2}] + }, { + ext: { + segtax: '9' + }, + segment: [{id: 1}, {id: 2}] + }, { + ext: { + segtax: '10' + }, + segment: [{id: 2}, {id: 3}] + }, { + ext: { + segtax: '508' + }, + segment: [{id: 3}, {id: 4}] }, { ext: { segtax: '508' @@ -2743,6 +2764,9 @@ describe('the rubicon adapter', function () { const slotParams = spec.createSlotParams(bidderRequest.bids[0], localBidderRequest); expect(slotParams['tg_i.tax507']).is.equal('1,2'); expect(slotParams['tg_v.tax508']).is.equal('3,4'); + expect(slotParams['tg_i.tax9']).is.equal('1,2'); + expect(slotParams['tg_v.tax10']).is.equal('2,3'); + expect(slotParams['tg_i.tax404']).is.equal(undefined); }); }); From 8e2d0d385caf1add380fbcf4e7992a004bb3255d Mon Sep 17 00:00:00 2001 From: Andrew Slagle <42588549+spotxslagle@users.noreply.github.com> Date: Thu, 15 Feb 2024 14:54:20 -0700 Subject: [PATCH 13/14] Pull site data from site.content.data --- modules/rubiconBidAdapter.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 5db23a45e5c..6ea6a637dfb 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -1007,16 +1007,21 @@ function addDesiredSegtaxes(bidderRequest, target) { if (rubiConf.readTopics === false) { return; } - let iSegments = [1, 2, 5, 6, 507].concat(rubiConf.sendUserSegtax?.map(seg => Number(seg)) || []); - let vSegments = [4, 508].concat(rubiConf.sendSiteSegtax?.map(seg => Number(seg)) || []); + let iSegments = [1, 2, 5, 6, 7, 507].concat(rubiConf.sendSiteSegtax?.map(seg => Number(seg)) || []); + let vSegments = [4, 508].concat(rubiConf.sendUserSegtax?.map(seg => Number(seg)) || []); let userData = bidderRequest.ortb2?.user?.data || []; - userData.forEach(topic => { + let siteData = bidderRequest.ortb2?.site?.content?.data || []; + userData.forEach(iterateOverSegmentData(target, 'v', vSegments)); + siteData.forEach(iterateOverSegmentData(target, 'i', iSegments)); +} + +function iterateOverSegmentData(target, char, segments) { + return (topic) => { const taxonomy = Number(topic.ext?.segtax); - let char; - if ((iSegments.includes(taxonomy) && (char = 'i')) || (vSegments.includes(taxonomy) && (char = 'v'))) { - target[`tg_${char}.tax${taxonomy}`] = topic.segment?.map(seg => seg.id).join(',') + if (segments.includes(taxonomy)) { + target[`tg_${char}.tax${taxonomy}`] = topic.segment?.map(seg => seg.id).join(','); } - }) + } } /** From be28180bbe560a1e8df401f488cbdeda1f6ac4d8 Mon Sep 17 00:00:00 2001 From: Andrew Slagle <42588549+spotxslagle@users.noreply.github.com> Date: Thu, 15 Feb 2024 14:54:58 -0700 Subject: [PATCH 14/14] Update unit tests --- test/spec/modules/rubiconBidAdapter_spec.js | 44 ++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index 40d3d2da774..739c408da91 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -2736,37 +2736,37 @@ describe('the rubicon adapter', function () { segment: [{id: 5}, {id: 6}] }, { ext: { - segtax: '507' + segtax: '508' }, - segment: [{id: 1}, {id: 2}] + segment: [{id: 5}, {id: 2}] }, { ext: { segtax: '9' }, segment: [{id: 1}, {id: 2}] - }, { - ext: { - segtax: '10' - }, - segment: [{id: 2}, {id: 3}] - }, { - ext: { - segtax: '508' - }, - segment: [{id: 3}, {id: 4}] - }, { - ext: { - segtax: '508' - }, - segment: [{id: 3}, {id: 4}] }] } + localBidderRequest.ortb2.site = { + content: { + data: [{ + ext: { + segtax: '10' + }, + segment: [{id: 2}, {id: 3}] + }, { + ext: { + segtax: '507' + }, + segment: [{id: 3}, {id: 4}] + }] + } + } const slotParams = spec.createSlotParams(bidderRequest.bids[0], localBidderRequest); - expect(slotParams['tg_i.tax507']).is.equal('1,2'); - expect(slotParams['tg_v.tax508']).is.equal('3,4'); - expect(slotParams['tg_i.tax9']).is.equal('1,2'); - expect(slotParams['tg_v.tax10']).is.equal('2,3'); - expect(slotParams['tg_i.tax404']).is.equal(undefined); + expect(slotParams['tg_i.tax507']).is.equal('3,4'); + expect(slotParams['tg_v.tax508']).is.equal('5,2'); + expect(slotParams['tg_v.tax9']).is.equal('1,2'); + expect(slotParams['tg_i.tax10']).is.equal('2,3'); + expect(slotParams['tg_v.tax404']).is.equal(undefined); }); });