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 - support all userIds #5923

Merged
merged 3 commits into from
Nov 3, 2020
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
107 changes: 46 additions & 61 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,6 @@ export const spec = {
const eids = utils.deepAccess(bidderRequest, 'bids.0.userIdAsEids');
if (eids && eids.length) {
utils.deepSetValue(data, 'user.ext.eids', eids);

// liveintent requires additional props to be set
const liveIntentEid = find(data.user.ext.eids, eid => eid.source === 'liveintent.com');
if (liveIntentEid) {
utils.deepSetValue(data, 'user.ext.tpid', { source: liveIntentEid.source, uid: liveIntentEid.uids[0].id });
if (liveIntentEid.ext && liveIntentEid.ext.segments) {
utils.deepSetValue(data, 'rp.target.LIseg', liveIntentEid.ext.segments);
Copy link
Collaborator

Choose a reason for hiding this comment

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

we do not need to send this now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no, not according to the ticket.

}
}
}

// set user.id value from config value
Expand Down Expand Up @@ -374,6 +365,7 @@ export const spec = {
getOrderedParams: function(params) {
const containsTgV = /^tg_v/
const containsTgI = /^tg_i/
const containsUId = /^eid_|^tpid_/

const orderedParams = [
'account_id',
Expand All @@ -386,18 +378,15 @@ export const spec = {
'gdpr_consent',
'us_privacy',
'rp_schain',
'tpid_tdid',
'tpid_liveintent.com',
'tg_v.LIseg',
'ppuid',
'eid_pubcid.org',
'eid_sharedid.org',
'eid_criteo.com',
'rf',
'p_geo.latitude',
'p_geo.longitude',
'kw'
].concat(Object.keys(params).filter(item => containsTgV.test(item)))
].concat(Object.keys(params).filter(item => containsUId.test(item)))
.concat([
'x_liverampidl',
'ppuid',
'rf',
'p_geo.latitude',
'p_geo.longitude',
'kw'
]).concat(Object.keys(params).filter(item => containsTgV.test(item)))
.concat(Object.keys(params).filter(item => containsTgI.test(item)))
.concat([
'tk_flint',
Expand Down Expand Up @@ -503,51 +492,47 @@ export const spec = {
// For SRA we need to explicitly put empty semi colons so AE treats it as empty, instead of copying the latter value
data['p_pos'] = (params.position === 'atf' || params.position === 'btf') ? params.position : '';

if (bidRequest.userIdAsEids && bidRequest.userIdAsEids.length) {
const unifiedId = find(bidRequest.userIdAsEids, eid => eid.source === 'adserver.org');
if (unifiedId) {
data['tpid_tdid'] = unifiedId.uids[0].id;
}
const liveintentId = find(bidRequest.userIdAsEids, eid => eid.source === 'liveintent.com');
if (liveintentId) {
data['tpid_liveintent.com'] = liveintentId.uids[0].id;
if (liveintentId.ext && Array.isArray(liveintentId.ext.segments) && liveintentId.ext.segments.length) {
data['tg_v.LIseg'] = liveintentId.ext.segments.join(',');
}
}
const liverampId = find(bidRequest.userIdAsEids, eid => eid.source === 'liveramp.com');
if (liverampId) {
data['x_liverampidl'] = liverampId.uids[0].id;
}
const sharedId = find(bidRequest.userIdAsEids, eid => eid.source === 'sharedid.org');
if (sharedId) {
data['eid_sharedid.org'] = `${sharedId.uids[0].id}^${sharedId.uids[0].atype}^${sharedId.uids[0].ext.third}`;
}
const pubcid = find(bidRequest.userIdAsEids, eid => eid.source === 'pubcid.org');
if (pubcid) {
data['eid_pubcid.org'] = `${pubcid.uids[0].id}^${pubcid.uids[0].atype}`;
}
const criteoId = find(bidRequest.userIdAsEids, eid => eid.source === 'criteo.com');
if (criteoId) {
data['eid_criteo.com'] = `${criteoId.uids[0].id}^${criteoId.uids[0].atype}`;
}
}

// set ppuid value from config value
// pass publisher provided userId if configured
const configUserId = config.getConfig('user.id');
if (configUserId) {
data['ppuid'] = configUserId;
} else {
// if config.getConfig('user.id') doesn't return anything, then look for the first eid.uids[*].ext.stype === 'ppuid'
for (let i = 0; bidRequest.userIdAsEids && i < bidRequest.userIdAsEids.length; i++) {
if (bidRequest.userIdAsEids[i].uids) {
const pubProvidedId = find(bidRequest.userIdAsEids[i].uids, uid => uid.ext && uid.ext.stype === 'ppuid');
if (pubProvidedId && pubProvidedId.id) {
data['ppuid'] = pubProvidedId.id;
break;
}
// loop through userIds and add to request
if (bidRequest.userIdAsEids) {
bidRequest.userIdAsEids.forEach(eid => {
try {
// special cases
if (eid.source === 'adserver.org') {
data['tpid_tdid'] = eid.uids[0].id;
data['eid_adserver.org'] = eid.uids[0].id;
} else if (eid.source === 'liveintent.com') {
data['tpid_liveintent.com'] = eid.uids[0].id;
data['eid_liveintent.com'] = eid.uids[0].id;
if (eid.ext && Array.isArray(eid.ext.segments) && eid.ext.segments.length) {
data['tg_v.LIseg'] = eid.ext.segments.join(',');
}
} else if (eid.source === 'liveramp.com') {
data['x_liverampidl'] = eid.uids[0].id;
} else if (eid.source === 'sharedid.org') {
data['eid_sharedid.org'] = `${eid.uids[0].id}^${eid.uids[0].atype}^${(eid.uids[0].ext && eid.uids[0].ext.third) || ''}`;
} else if (eid.source === 'id5-sync.com') {
data['eid_id5-sync.com'] = `${eid.uids[0].id}^${eid.uids[0].atype}^${(eid.ext && eid.ext.linkType) || ''}`;
} else {
// add anything else with this generic format
smenzer marked this conversation as resolved.
Show resolved Hide resolved
data[`eid_${eid.source}`] = `${eid.uids[0].id}^${eid.uids[0].atype || ''}`;
}
// send AE "ppuid" signal if exists, and hasn't already been sent
if (!data['ppuid']) {
// get the first eid.uids[*].ext.stype === 'ppuid', if one exists
const ppId = find(eid.uids, uid => uid.ext && uid.ext.stype === 'ppuid');
Copy link
Collaborator

@robertrmartinez robertrmartinez Nov 2, 2020

Choose a reason for hiding this comment

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

should we check !configUserId before this so we do not loop through these eid.uids unnecessarily?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

seeking clarification on the expected logic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated the logic here.

if (ppId && ppId.id) {
data['ppuid'] = ppId.id;
}
}
} catch (e) {
utils.logWarn('Rubicon: error reading eid:', eid, e);
}
}
});
}

if (bidderRequest.gdprConsent) {
Expand Down
18 changes: 6 additions & 12 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ describe('the rubicon adapter', function () {
id: '4444444'
}]
}],
criteoId: '1111'
criteoId: '1111',
};
bid.userIdAsEids = createEidsArray(bid.userId);
bid.storedAuctionResponse = 11111;
Expand Down Expand Up @@ -1097,21 +1097,25 @@ describe('the rubicon adapter', function () {
let data = parseQuery(request.data);

expect(data['tpid_tdid']).to.equal('abcd-efgh-ijkl-mnop-1234');
expect(data['eid_adserver.org']).to.equal('abcd-efgh-ijkl-mnop-1234');
});

describe('LiveIntent support', function () {
it('should send tpid_liveintent.com when userIdAsEids contains liveintentId', function () {
const clonedBid = utils.deepClone(bidderRequest.bids[0]);
clonedBid.userId = {
lipb: {
lipbid: '0000-1111-2222-3333'
lipbid: '0000-1111-2222-3333',
segments: ['segA', 'segB']
}
};
clonedBid.userIdAsEids = createEidsArray(clonedBid.userId);
let [request] = spec.buildRequests([clonedBid], bidderRequest);
let data = parseQuery(request.data);

expect(data['tpid_liveintent.com']).to.equal('0000-1111-2222-3333');
expect(data['eid_liveintent.com']).to.equal('0000-1111-2222-3333');
expect(data['tg_v.LIseg']).to.equal('segA,segB');
});

it('should send tg_v.LIseg when userIdAsEids contains liveintentId with ext.segments as array', function () {
Expand Down Expand Up @@ -1429,20 +1433,10 @@ describe('the rubicon adapter', function () {
expect(post.user.ext.eids[0].ext).to.have.property('segments').that.is.an('array');
expect(post.user.ext.eids[0].ext.segments[0]).to.equal('segA');
expect(post.user.ext.eids[0].ext.segments[1]).to.equal('segB');
// Non-EID properties set using liveintent EID values
expect(post.user.ext).to.have.property('tpid').that.is.an('object');
expect(post.user.ext.tpid.source).to.equal('liveintent.com');
expect(post.user.ext.tpid.uid).to.equal('0000-1111-2222-3333');
expect(post).to.have.property('rp').that.is.an('object');
expect(post.rp).to.have.property('target').that.is.an('object');
expect(post.rp.target).to.have.property('LIseg').that.is.an('array');
expect(post.rp.target.LIseg[0]).to.equal('segA');
expect(post.rp.target.LIseg[1]).to.equal('segB');
// LiveRamp should exist
expect(post.user.ext.eids[1].source).to.equal('liveramp.com');
expect(post.user.ext.eids[1].uids[0].id).to.equal('1111-2222-3333-4444');
expect(post.user.ext.eids[1].uids[0].atype).to.equal(1);

// SharedId should exist
expect(post.user.ext.eids[2].source).to.equal('sharedid.org');
expect(post.user.ext.eids[2].uids[0].id).to.equal('1111');
Expand Down