Skip to content

Commit

Permalink
Rubicon Bid Adapter: Pass on carbon segtaxes (prebid#10985)
Browse files Browse the repository at this point in the history
* Pass through Carbon segments

* Fix rubiconBidAdapter for unit tests

* segtax spec

* Fix access issues

* Remove dup ortb2 work

* Adjust unit tests

* Fix lint issues

* Add all desired segtaxes

* Fix unit tests

* Fix linting

* Don't concat undefined

* Unit test pub added segtaxes

* Pull site data from site.content.data

* Update unit tests
  • Loading branch information
spotxslagle authored Feb 24, 2024
1 parent f869118 commit ecc3441
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
23 changes: 23 additions & 0 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ export const spec = {
if (bidRequest?.ortb2Imp?.ext?.ae) {
data['o_ae'] = 1;
}

addDesiredSegtaxes(bidderRequest, data);
// loop through userIds and add to request
if (bidRequest.userIdAsEids) {
bidRequest.userIdAsEids.forEach(eid => {
Expand Down Expand Up @@ -1037,6 +1039,27 @@ function applyFPD(bidRequest, mediaType, data) {
}
}

function addDesiredSegtaxes(bidderRequest, target) {
if (rubiConf.readTopics === false) {
return;
}
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 || [];
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);
if (segments.includes(taxonomy)) {
target[`tg_${char}.tax${taxonomy}`] = topic.segment?.map(seg => seg.id).join(',');
}
}
}

/**
* @param sizes
* @returns {*}
Expand Down
50 changes: 50 additions & 0 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2770,6 +2770,56 @@ describe('the rubicon adapter', function () {

expect(slotParams['o_ae']).to.equal(1)
});

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: {
segtax: '404'
},
segment: [{id: 5}, {id: 6}]
}, {
ext: {
segtax: '508'
},
segment: [{id: 5}, {id: 2}]
}, {
ext: {
segtax: '9'
},
segment: [{id: 1}, {id: 2}]
}]
}
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('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);
});
});

describe('classifiedAsVideo', function () {
Expand Down

0 comments on commit ecc3441

Please sign in to comment.