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 adapter: ortb2 data update to use segtax #6679

Merged
merged 1 commit into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -974,11 +974,12 @@ function applyFPD(bidRequest, mediaType, data) {

let fpd = utils.mergeDeep({}, config.getConfig('ortb2') || {}, BID_FPD);
let impData = utils.deepAccess(bidRequest.ortb2Imp, 'ext.data') || {};
const SEGTAX = {user: [3], site: [1, 2]};
const MAP = {user: 'tg_v.', site: 'tg_i.', adserver: 'tg_i.dfp_ad_unit_code', pbadslot: 'tg_i.pbadslot', keywords: 'kw'};
const validate = function(prop, key) {
const validate = function(prop, key, parentName) {
if (key === 'data' && Array.isArray(prop)) {
return prop.filter(name => name.segment && utils.deepAccess(name, 'ext.taxonomyname') &&
utils.deepAccess(name, 'ext.taxonomyname').match(/iab/i)).map(value => {
return prop.filter(name => name.segment && utils.deepAccess(name, 'ext.segtax') && SEGTAX[parentName] &&
SEGTAX[parentName].indexOf(utils.deepAccess(name, 'ext.segtax')) !== -1).map(value => {
let segments = value.segment.filter(obj => obj.id).reduce((result, obj) => {
result.push(obj.id);
return result;
Expand All @@ -996,7 +997,7 @@ function applyFPD(bidRequest, mediaType, data) {
}
};
const addBannerData = function(obj, name, key, isParent = true) {
let val = validate(obj, key);
let val = validate(obj, key, name);
let loc = (MAP[key] && isParent) ? `${MAP[key]}` : (key === 'data') ? `${MAP[name]}iab` : `${MAP[name]}${key}`;
data[loc] = (data[loc]) ? data[loc].concat(',', val) : val;
}
Expand All @@ -1014,7 +1015,9 @@ function applyFPD(bidRequest, mediaType, data) {
if (mediaType === BANNER) {
['site', 'user'].forEach(name => {
Object.keys(fpd[name]).forEach((key) => {
if (key !== 'ext') {
if (name === 'site' && key === 'content' && fpd[name][key].data) {
addBannerData(fpd[name][key].data, name, 'data');
} else if (key !== 'ext') {
addBannerData(fpd[name][key], name, key);
} else if (fpd[name][key].data) {
Object.keys(fpd[name].ext.data).forEach((key) => {
Expand Down
18 changes: 17 additions & 1 deletion test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,12 +846,27 @@ describe('the rubicon adapter', function () {
data: {
page: 'home'
}
},
content: {
data: [{
'name': 'www.dataprovider1.com',
'ext': { 'segtax': 1 },
'segment': [
{ 'id': '987' }
]
}, {
'name': 'www.dataprovider1.com',
'ext': { 'segtax': 2 },
'segment': [
{ 'id': '432' }
]
}]
}
};
const user = {
data: [{
'name': 'www.dataprovider1.com',
'ext': { 'taxonomyname': 'IAB Audience Taxonomy' },
'ext': { 'segtax': 3 },
'segment': [
{ 'id': '687' },
{ 'id': '123' }
Expand Down Expand Up @@ -886,6 +901,7 @@ describe('the rubicon adapter', function () {
'tg_v.gender': 'M',
'tg_v.age': '40',
'tg_v.iab': '687,123',
'tg_i.iab': '987,432',
'tg_v.yob': '1984',
'tg_i.rating': '4-star,5-star',
'tg_i.page': 'home',
Expand Down