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: Get eids for oRTB request from bid.userIdAsEids #5657

Merged
merged 108 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
8d635ff
Add microadBidAdapter
Feb 15, 2019
3055b90
Remove unnecessary encodeURIComponent from microadBidAdapter
Feb 26, 2019
67fb91b
Submit Advangelists Prebid Adapter
Feb 26, 2019
3ebb916
Submit Advangelists Prebid Adapter 1.1
Feb 27, 2019
4f5c451
Correct procudtion endpoint for prebid
Feb 28, 2019
2dc6d1d
Merge branch 'microad-bid-adapter' of git://github.com/strong-zero/Pr…
Feb 28, 2019
fa3e081
Merge remote-tracking branch 'origin/master' into master-rubicon-clean
Mar 18, 2019
600a46e
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Mar 18, 2019
7f578b3
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 23, 2019
176a312
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 26, 2019
9abf89c
Merge branch 'master' of https://github.com/prebid/Prebid.js
May 13, 2019
6ce04ab
Merge remote-tracking branch 'upstream/master'
Jun 10, 2019
415e2f6
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jun 27, 2019
61fb82c
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 11, 2019
3cc4c67
analytics update with wrapper name
Jul 11, 2019
cd81e02
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 15, 2019
e2b4e04
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 15, 2019
53b5970
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 15, 2019
5c00ed5
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 16, 2019
28848ad
reverted error merge
Jul 16, 2019
ab635ee
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 19, 2019
93308f5
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 24, 2019
1cfd52d
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jul 25, 2019
d619807
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jul 27, 2019
9893f0f
Merge branch 'master' of https://github.com/prebid/Prebid.js
Aug 7, 2019
986a251
Merge remote-tracking branch 'upstream/master'
Aug 23, 2019
2cae7c0
Merge branch 'master' of https://github.com/prebid/Prebid.js into ori…
Aug 27, 2019
d7fd252
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 4, 2019
c7c01ba
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 10, 2019
24a28aa
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 10, 2019
7a1a4ec
Merge branch 'master' of https://github.com/rubicon-project/Prebid.js
Sep 25, 2019
4173d16
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 25, 2019
ca13952
update changed default value of netRevenue to true
Sep 27, 2019
0b6cd48
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 3, 2019
5f0110d
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 3, 2019
f930a34
Merge remote-tracking branch 'upstream/master'
Oct 8, 2019
9bff282
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 14, 2019
712ec9e
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 29, 2019
f192f65
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 29, 2019
006f53c
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 29, 2019
0341150
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 31, 2019
fa59897
Merge branch 'master' of https://github.com/prebid/Prebid.js
Nov 15, 2019
dcff2cf
Merge branch 'master' of https://github.com/prebid/Prebid.js
Nov 20, 2019
0222ce2
Merge branch 'master' of https://github.com/prebid/Prebid.js
Nov 24, 2019
227beca
Merge branch 'master' of https://github.com/prebid/Prebid.js
Nov 25, 2019
dc3ee49
Merge branch 'master' of https://github.com/rubicon-project/Prebid.js
Dec 4, 2019
9a5a08d
Merge branch 'master' of https://github.com/prebid/Prebid.js
Dec 4, 2019
35ea5d4
Merge branch 'master' of https://github.com/prebid/Prebid.js
Dec 6, 2019
f89b71c
Merge branch 'master' of https://github.com/prebid/Prebid.js
Dec 17, 2019
4e1679b
Re-add rubicon analytics without deprecated getTopWindowUrl util
Dec 17, 2019
fd80acd
Cache referrer on auction_init instead of bid_requested
Dec 17, 2019
2ab26a3
Merge pull request #51 from rubicon-project/rubicon-analytics-3.0
msm0504 Dec 17, 2019
7de7ca6
Merge branch 'master' of https://github.com/rubicon-project/Prebid.js
Jan 9, 2020
5f1fe06
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jan 9, 2020
60b5ad8
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jan 17, 2020
5f44edd
Merge branch 'master' of https://github.com/rubicon-project/Prebid.js
Feb 10, 2020
4809354
Merge branch 'master' of https://github.com/prebid/Prebid.js
Feb 10, 2020
8d8bdff
Merge branch 'master' of https://github.com/prebid/Prebid.js
Feb 13, 2020
a1a2318
Merge branch 'master' of https://github.com/prebid/Prebid.js
Feb 19, 2020
ac2ac12
Merge branch 'master' of https://github.com/prebid/Prebid.js
Feb 24, 2020
5ce8787
Merge branch 'master' of https://github.com/rubicon-project/Prebid.js
Mar 12, 2020
6c2bdec
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 12, 2020
a54a491
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 27, 2020
889178d
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 27, 2020
40cba46
Merge branch 'master' of https://github.com/prebid/Prebid.js
Apr 4, 2020
cc5d929
Merge remote-tracking branch 'remote/master'
Apr 23, 2020
5574a52
merged remote master changes
Apr 24, 2020
ba62245
Merge branch 'master' of https://github.com/prebid/Prebid.js
May 1, 2020
1fe62f9
Merge branch 'master' of https://github.com/prebid/Prebid.js
May 5, 2020
a4d1d62
Merge branch 'master' of https://github.com/prebid/Prebid.js
May 13, 2020
7215461
Merge branch 'master' of https://github.com/prebid/Prebid.js
May 20, 2020
258c555
Merge remote-tracking branch 'origin/master'
May 20, 2020
a921ac9
Merge remote-tracking branch 'remotes/remote/master'
Jun 3, 2020
90975d1
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jun 5, 2020
aac67fa
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jun 18, 2020
585993c
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jul 8, 2020
20f5825
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jul 16, 2020
8ce42f0
Merge branch 'master' of https://github.com/prebid/Prebid.js
Aug 4, 2020
253b8bb
Merge branch 'master' of https://github.com/prebid/Prebid.js
Aug 17, 2020
5e5ba25
Merge branch 'master' of https://github.com/prebid/Prebid.js into upd…
Aug 18, 2020
d81917a
update liveramp userid support
Aug 18, 2020
6cf396f
changed source value to all lowercase
Aug 18, 2020
3d996b0
update share id name
Aug 18, 2020
b64efbb
add unit test for shareid eid
Aug 18, 2020
1ae7999
update shareid obj paths
Aug 18, 2020
3b04900
fixed atype value
Aug 24, 2020
c104aa9
Merge branch 'master' of https://github.com/prebid/Prebid.js into upd…
Aug 24, 2020
3cf599d
update to use eids set by userId/eids.js
Aug 26, 2020
9b5d0f7
update eid to include ext object for adserver.org
Aug 26, 2020
1c34965
optimize remove lines
Aug 26, 2020
15cb955
optimize for line reduction
Aug 26, 2020
d8ede48
optimization
Aug 26, 2020
3ab0960
optimization
Aug 26, 2020
4e37d02
fixed liveramp missing property
Aug 26, 2020
fff8ee1
fixed import ordering
Aug 26, 2020
935fa32
reverted change
Aug 26, 2020
7a81bd3
undo revert
Aug 26, 2020
257b1f4
Merge branch 'master' of https://github.com/prebid/Prebid.js into upd…
Aug 26, 2020
146aeb8
fix tests expected values
Aug 26, 2020
75f282f
added fields to expected test results
Aug 26, 2020
7ac8751
refactor to user eids.js to mock test data
Aug 27, 2020
361e4ab
optimize code to reduce lines
Aug 27, 2020
5d9c3e4
removed extra braces
Aug 27, 2020
75273cb
removed extra lines and renamed userIdAsEids to eids
Aug 27, 2020
ab0779a
add tests for all supported sources
Aug 27, 2020
3ed9347
removed unnecessary comments
Aug 27, 2020
81cd98a
udate condition to check for eids length
Aug 27, 2020
ef0cbbb
removed liveramp.com from eidMap, and refactored to use single variable
Aug 27, 2020
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
77 changes: 12 additions & 65 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as utils from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {config} from '../src/config.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import find from 'core-js-pure/features/array/find.js';

const DEFAULT_INTEGRATION = 'pbjs_lite';
const DEFAULT_PBS_INTEGRATION = 'pbjs';
Expand Down Expand Up @@ -247,73 +248,19 @@ export const spec = {
utils.deepSetValue(data, 'regs.ext.us_privacy', bidderRequest.uspConsent);
}

if (bidRequest.userId && typeof bidRequest.userId === 'object' &&
(bidRequest.userId.tdid || bidRequest.userId.pubcid || bidRequest.userId.lipb || bidRequest.userId.idl_env || bidRequest.userId.sharedid)) {
utils.deepSetValue(data, 'user.ext.eids', []);

if (bidRequest.userId.tdid) {
data.user.ext.eids.push({
source: 'adserver.org',
uids: [{
id: bidRequest.userId.tdid,
ext: {
rtiPartner: 'TDID'
}
}]
});
}

if (bidRequest.userId.pubcid) {
data.user.ext.eids.push({
source: 'pubcommon',
uids: [{
id: bidRequest.userId.pubcid,
}]
});
}

// support liveintent ID
if (bidRequest.userId.lipb && bidRequest.userId.lipb.lipbid) {
data.user.ext.eids.push({
source: 'liveintent.com',
uids: [{
id: bidRequest.userId.lipb.lipbid
}]
});

data.user.ext.tpid = {
source: 'liveintent.com',
uid: bidRequest.userId.lipb.lipbid
};

if (Array.isArray(bidRequest.userId.lipb.segments) && bidRequest.userId.lipb.segments.length) {
utils.deepSetValue(data, 'rp.target.LIseg', bidRequest.userId.lipb.segments);
const eids = utils.deepAccess(bidderRequest, 'bids.0.userIdAsEids');
if (eids && eids.length) {
// filter out unsupported id systems
utils.deepSetValue(data, 'user.ext.eids', eids.filter(eid => ['adserver.org', 'pubcid.org', 'liveintent.com', 'liveramp.com', 'sharedid.org'].indexOf(eid.source) !== -1));

// 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);
}
}

// support identityLink (aka LiveRamp)
if (bidRequest.userId.idl_env) {
data.user.ext.eids.push({
source: 'liveramp_idl',
uids: [{
id: bidRequest.userId.idl_env
}]
});
}

// support shared id
if (bidRequest.userId.sharedid) {
data.user.ext.eids.push({
source: 'sharedid.org',
uids: [{
id: bidRequest.userId.sharedid.id,
atype: 3,
ext: {
third: bidRequest.userId.sharedid.third
}
}]
});
}
}

// set user.id value from config value
Expand Down
73 changes: 38 additions & 35 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {parse as parseQuery} from 'querystring';
import {config} from 'src/config.js';
import * as utils from 'src/utils.js';
import find from 'core-js-pure/features/array/find.js';
import { createEidsArray } from 'modules/userId/eids.js';

const INTEGRATION = `pbjs_lite_v$prebid.version$`; // $prebid.version$ will be substituted in by gulp in built prebid
const PBS_INTEGRATION = 'pbjs';
Expand Down Expand Up @@ -219,16 +220,13 @@ describe('the rubicon adapter', function () {
'size_id': 201,
};
bid.userId = {
lipb: {
lipbid: '0000-1111-2222-3333',
segments: ['segA', 'segB']
},
lipb: { lipbid: '0000-1111-2222-3333', segments: ['segA', 'segB'] },
idl_env: '1111-2222-3333-4444',
sharedid: {
id: '1111',
third: '2222'
}
sharedid: { id: '1111', third: '2222' },
tdid: '3000',
pubcid: '4000'
};
bid.userIdAsEids = createEidsArray(bid.userId);
bid.storedAuctionResponse = 11111;
}

Expand Down Expand Up @@ -1323,6 +1321,7 @@ describe('the rubicon adapter', function () {
clonedBid.userId = {
tdid: 'abcd-efgh-ijkl-mnop-1234'
};
clonedBid.userIdAsEids = createEidsArray(clonedBid.userId);
let [request] = spec.buildRequests([clonedBid], bidderRequest);
let data = parseQuery(request.data);

Expand All @@ -1337,6 +1336,7 @@ describe('the rubicon adapter', function () {
lipbid: '0000-1111-2222-3333'
}
};
clonedBid.userIdAsEids = createEidsArray(clonedBid.userId);
let [request] = spec.buildRequests([clonedBid], bidderRequest);
let data = parseQuery(request.data);

Expand All @@ -1351,6 +1351,7 @@ describe('the rubicon adapter', function () {
segments: ['segD', 'segE']
}
};
clonedBid.userIdAsEids = createEidsArray(clonedBid.userId);
let [request] = spec.buildRequests([clonedBid], bidderRequest);
const unescapedData = unescape(request.data);

Expand All @@ -1365,6 +1366,7 @@ describe('the rubicon adapter', function () {
clonedBid.userId = {
idl_env: '1111-2222-3333-4444'
};
clonedBid.userIdAsEids = createEidsArray(clonedBid.userId);
let [request] = spec.buildRequests([clonedBid], bidderRequest);
let data = parseQuery(request.data);

Expand All @@ -1381,6 +1383,7 @@ describe('the rubicon adapter', function () {
third: '2222'
}
};
clonedBid.userIdAsEids = createEidsArray(clonedBid.userId);
let [request] = spec.buildRequests([clonedBid], bidderRequest);
let data = parseQuery(request.data);

Expand Down Expand Up @@ -1590,25 +1593,44 @@ describe('the rubicon adapter', function () {
expect(imp.ext.rubicon.video.skipafter).to.equal(15);
expect(imp.ext.prebid.auctiontimestamp).to.equal(1472239426000);
expect(post.user.ext.consent).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==');
// EIDs should exist
expect(post.user.ext).to.have.property('eids').that.is.an('array');
// LiveIntent should exist
expect(post.user.ext.eids[0].source).to.equal('liveintent.com');
expect(post.user.ext.eids[0].uids[0].id).to.equal('0000-1111-2222-3333');
expect(post.user.ext.tpid).that.is.an('object');
expect(post.user.ext.eids[0].uids[0].atype).to.equal(1);
expect(post.user.ext.eids[0]).to.have.property('ext').that.is.an('object');
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_idl');
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');
expect(post.user.ext.eids[2].uids[0].atype).to.equal(3);
expect(post.user.ext.eids[2].uids[0].atype).to.equal(1);
expect(post.user.ext.eids[2].uids[0].ext.third).to.equal('2222');
// UnifiedId should exist
expect(post.user.ext.eids[3].source).to.equal('adserver.org');
expect(post.user.ext.eids[3].uids[0].atype).to.equal(1);
expect(post.user.ext.eids[3].uids[0].id).to.equal('3000');
// PubCommonId should exist
expect(post.user.ext.eids[4].source).to.equal('pubcid.org');
expect(post.user.ext.eids[4].uids[0].atype).to.equal(1);
expect(post.user.ext.eids[4].uids[0].id).to.equal('4000');

expect(post.rp).that.is.an('object');
expect(post.rp.target).that.is.an('object');
expect(post.rp.target.LIseg).that.is.an('array');
expect(post.rp.target.LIseg[0]).to.equal('segA');
expect(post.rp.target.LIseg[1]).to.equal('segB');
expect(post.regs.ext.gdpr).to.equal(1);
expect(post.regs.ext.us_privacy).to.equal('1NYN');
expect(post).to.have.property('ext').that.is.an('object');
Expand Down Expand Up @@ -2076,25 +2098,6 @@ describe('the rubicon adapter', function () {
expect(imp.ext.rubicon.video.skipafter).to.equal(15);
expect(imp.ext.prebid.auctiontimestamp).to.equal(1472239426000);
expect(post.user.ext.consent).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==');
expect(post.user.ext.eids[0].source).to.equal('liveintent.com');
expect(post.user.ext.eids[0].uids[0].id).to.equal('0000-1111-2222-3333');
expect(post.user.ext.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');
// LiveRamp should exist
expect(post.user.ext.eids[1].source).to.equal('liveramp_idl');
expect(post.user.ext.eids[1].uids[0].id).to.equal('1111-2222-3333-4444');
// 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');
expect(post.user.ext.eids[2].uids[0].atype).to.equal(3);
expect(post.user.ext.eids[2].uids[0].ext.third).to.equal('2222');

expect(post.rp).that.is.an('object');
expect(post.rp.target).that.is.an('object');
expect(post.rp.target.LIseg).that.is.an('array');
expect(post.rp.target.LIseg[0]).to.equal('segA');
expect(post.rp.target.LIseg[1]).to.equal('segB');

// Config user.id
expect(post.user.id).to.equal('123');
Expand Down