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
19 changes: 19 additions & 0 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ 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 +1004,22 @@ function applyFPD(bidRequest, mediaType, data) {
}
}

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)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these will add undefined to the arrays

To get around this can just add || [] I think at end of map so it skips it.

Other ways to handle also.

Think adding undefined to these arrays is prob not a big deal, but is unnecessary.

EX:

iSegments = [1, 2, 5, 6, 507].concat(rubiConf.sendUserSegtax?.map(seg => Number(seg)) || []);

let userData = bidderRequest.ortb2?.user?.data || [];
userData.forEach(topic => {
const taxonomy = Number(topic.ext?.segtax);
let char;
if ((iSegments.includes(taxonomy) && (char = 'i')) || (vSegments.includes(taxonomy) && (char = 'v'))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool way to handle the v and I thing nice! sneaky assignment!

target[`tg_${char}.tax${taxonomy}`] = topic.segment?.map(seg => seg.id).join(',')
}
})
}

/**
* @param sizes
* @returns {*}
Expand Down
26 changes: 26 additions & 0 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2718,6 +2718,32 @@ 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'};
localBidderRequest.ortb2.user = {
data: [{
ext: {
segtax: '404'
},
segment: [{id: 5}, {id: 6}]
}, {
ext: {
segtax: '507'
},
segment: [{id: 1}, {id: 2}]
}, {
ext: {
segtax: '508'
},
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');
});
});

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