Skip to content
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

Rubicon Bid Adapter: Pass on carbon segtaxes #10985

Merged
merged 14 commits into from
Feb 24, 2024
23 changes: 23 additions & 0 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,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 @@ -1001,6 +1003,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 @@ -2718,6 +2718,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