Skip to content

Commit

Permalink
Eids liveintent ext fix (prebid#4944)
Browse files Browse the repository at this point in the history
* added support for pubcommon, digitrust, id5id

* added support for IdentityLink

* changed the source for id5

* added unit test cases

* changed source param for identityLink

* fixing liveintent-segments

added separate functions in config for eid.ext and uid.ext
liventent segments should have been in eid.ext not in eid.uids[].ext

* added example of generated eids array

* formating

* commeneted a console log; avoiding lint error

* fixed breaking test-cases
  • Loading branch information
pm-harshad-mane authored and rjvelicaria committed Apr 9, 2020
1 parent b6b4fbe commit 625b325
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 10 deletions.
25 changes: 18 additions & 7 deletions modules/userId/eids.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const USER_IDS_CONFIG = {
'tdid': {
source: 'adserver.org',
atype: 1,
ext: function() {
getUidExt: function() {
return {
rtiPartner: 'TDID'
};
Expand Down Expand Up @@ -47,7 +47,7 @@ const USER_IDS_CONFIG = {
},
source: 'liveintent.com',
atype: 1,
ext: function(data) {
getEidExt: function(data) {
if (Array.isArray(data.segments) && data.segments.length) {
return {
segments: data.segments
Expand Down Expand Up @@ -88,16 +88,27 @@ const USER_IDS_CONFIG = {
function createEidObject(userIdData, subModuleKey) {
const conf = USER_IDS_CONFIG[subModuleKey];
if (conf && userIdData) {
let eid = {};
eid.source = conf['source'];
const value = utils.isFn(conf['getValue']) ? conf['getValue'](userIdData) : userIdData;
if (value) {
const uid = { id: value, atype: conf['atype'] };
if (utils.isFn(conf['ext'])) {
const ext = conf['ext'](userIdData);
if (ext) {
uid.ext = ext;
// getUidExt
if (utils.isFn(conf['getUidExt'])) {
const uidExt = conf['getUidExt'](userIdData);
if (uidExt) {
uid.ext = uidExt;
}
}
return { source: conf['source'], uids: [uid] };
eid.uids = [uid];
// getEidExt
if (utils.isFn(conf['getEidExt'])) {
const eidExt = conf['getEidExt'](userIdData);
if (eidExt) {
eid.ext = eidExt;
}
}
return eid;
}
}
return null;
Expand Down
90 changes: 90 additions & 0 deletions modules/userId/eids.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
## Example of eids array generated by UserId Module.
```
userIdAsEids = [
{
source: 'pubcid.org',
uids: [{
id: 'some-random-id-value',
atype: 1
}]
},
{
source: 'adserver.org',
uids: [{
id: 'some-random-id-value',
atype: 1,
ext: {
rtiPartner: 'TDID'
}
}]
},
{
source: 'id5-sync.com',
uids: [{
id: 'some-random-id-value',
atype: 1
}]
},
{
source: 'parrable.com',
uids: [{
id: 'some-random-id-value',
atype: 1
}]
},
{
source: 'liveramp.com',
uids: [{
id: 'some-random-id-value',
atype: 1
}]
},
{
source: 'liveintent.com',
uids: [{
id: 'some-random-id-value',
atype: 1
}],
ext: {
segments: ['s1', 's2']
}
},
{
source: 'britepool.com',
uids: [{
id: 'some-random-id-value',
atype: 1
}]
},
{
source: 'digitru.st',
uids: [{
id: 'some-random-id-value',
atype: 1
}]
},
{
source: 'criteo.com',
uids: [{
id: 'some-random-id-value',
atype: 1
}]
},
{
source: 'netid.de',
uids: [{
id: 'some-random-id-value',
atype: 1
}]
}
]
```
3 changes: 2 additions & 1 deletion test/spec/modules/eids_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ describe('eids array generation for known sub-modules', function() {
expect(newEids.length).to.equal(1);
expect(newEids[0]).to.deep.equal({
source: 'liveintent.com',
uids: [{id: 'some-random-id-value', atype: 1, ext: {segments: ['s1', 's2']}}]
uids: [{id: 'some-random-id-value', atype: 1}],
ext: {segments: ['s1', 's2']}
});
});

Expand Down
6 changes: 4 additions & 2 deletions test/spec/modules/userId_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,8 @@ describe('User ID', function() {
expect(bid.userId.lipb.segments).to.include('123');
expect(bid.userIdAsEids[0]).to.deep.equal({
source: 'liveintent.com',
uids: [{id: 'random-ls-identifier', atype: 1, ext: {segments: ['123']}}]
uids: [{id: 'random-ls-identifier', atype: 1}],
ext: {segments: ['123']}
});
});
});
Expand All @@ -875,7 +876,8 @@ describe('User ID', function() {
expect(bid.userId.lipb.segments).to.include('123');
expect(bid.userIdAsEids[0]).to.deep.equal({
source: 'liveintent.com',
uids: [{id: 'random-cookie-identifier', atype: 1, ext: {segments: ['123']}}]
uids: [{id: 'random-cookie-identifier', atype: 1}],
ext: {segments: ['123']}
});
});
});
Expand Down

0 comments on commit 625b325

Please sign in to comment.