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

Convert id5id to an object to support passing additional data points to platforms #5756

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
move id5id to an object to support passing linkType and other data in…
… the future
  • Loading branch information
smenzer committed Sep 16, 2020
commit 6640e22287bc47f1edb13231c4d0ee5a8fab2a39
17 changes: 15 additions & 2 deletions modules/id5IdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,27 @@ export const id5IdSubmodule = {
* @returns {(Object|undefined)}
*/
decode(value) {
let uid;
let linkType = 0;

if (value && typeof value.ID5ID === 'string') {
// don't lose our legacy value from cache
return { 'id5id': value.ID5ID };
uid = value.ID5ID;
} else if (value && typeof value.universal_uid === 'string') {
return { 'id5id': value.universal_uid };
uid = value.universal_uid;
linkType = value.link_type || linkType;
} else {
return undefined;
}

return {
'id5id': {
'uid': uid,
'ext': {
'linkType': linkType
}
}
};
},

/**
Expand Down
10 changes: 9 additions & 1 deletion modules/userId/eids.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@ const USER_IDS_CONFIG = {

// id5Id
'id5id': {
getValue: function(data) {
return data.uid
},
source: 'id5-sync.com',
atype: 1
atype: 1,
getEidExt: function(data) {
if (data.ext) {
return data.ext;
}
}
},

// parrableId
Expand Down
42 changes: 33 additions & 9 deletions test/spec/modules/eids_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,39 @@ describe('eids array generation for known sub-modules', function() {
});
});

it('id5Id', function() {
const userId = {
id5id: 'some-random-id-value'
};
const newEids = createEidsArray(userId);
expect(newEids.length).to.equal(1);
expect(newEids[0]).to.deep.equal({
source: 'id5-sync.com',
uids: [{id: 'some-random-id-value', atype: 1}]
describe('id5Id', function() {
it('does not include an ext if not provided', function() {
const userId = {
id5id: {
uid: 'some-random-id-value'
}
};
const newEids = createEidsArray(userId);
expect(newEids.length).to.equal(1);
expect(newEids[0]).to.deep.equal({
source: 'id5-sync.com',
uids: [{ id: 'some-random-id-value', atype: 1 }]
});
});

it('includes ext if provided', function() {
const userId = {
id5id: {
uid: 'some-random-id-value',
ext: {
linkType: 0
}
}
};
const newEids = createEidsArray(userId);
expect(newEids.length).to.equal(1);
expect(newEids[0]).to.deep.equal({
source: 'id5-sync.com',
uids: [{ id: 'some-random-id-value', atype: 1 }],
ext: {
linkType: 0
}
});
});
});

Expand Down
19 changes: 12 additions & 7 deletions test/spec/modules/id5IdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ describe('ID5 ID System', function() {
return {
name: ID5_MODULE_NAME,
value: {
id5id: value
id5id: {
uid: value
}
}
}
}
Expand Down Expand Up @@ -238,10 +240,13 @@ describe('ID5 ID System', function() {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property(`userId.${ID5_EIDS_NAME}`);
expect(bid.userId.id5id).to.equal(ID5_STORED_ID);
expect(bid.userId.id5id.uid).to.equal(ID5_STORED_ID);
expect(bid.userIdAsEids[0]).to.deep.equal({
source: ID5_SOURCE,
uids: [{ id: ID5_STORED_ID, atype: 1 }]
uids: [{ id: ID5_STORED_ID, atype: 1 }],
ext: {
linkType: 0
}
});
});
});
Expand All @@ -258,7 +263,7 @@ describe('ID5 ID System', function() {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property(`userId.${ID5_EIDS_NAME}`);
expect(bid.userId.id5id).to.equal(ID5_STORED_ID);
expect(bid.userId.id5id.uid).to.equal(ID5_STORED_ID);
expect(bid.userIdAsEids[0]).to.deep.equal({
source: ID5_SOURCE,
uids: [{ id: ID5_STORED_ID, atype: 1 }]
Expand Down Expand Up @@ -368,13 +373,13 @@ describe('ID5 ID System', function() {
});

describe('Decode stored object', function() {
const decodedObject = { 'id5id': ID5_STORED_ID };
const expectedDecodedObject = { id5id: { uid: ID5_STORED_ID, ext: { linkType: 0 } } };

it('should properly decode from a stored object', function() {
expect(id5IdSubmodule.decode(ID5_STORED_OBJ)).to.deep.equal(decodedObject);
expect(id5IdSubmodule.decode(ID5_STORED_OBJ)).to.deep.equal(expectedDecodedObject);
});
it('should properly decode from a legacy stored object', function() {
expect(id5IdSubmodule.decode(ID5_LEGACY_STORED_OBJ)).to.deep.equal(decodedObject);
expect(id5IdSubmodule.decode(ID5_LEGACY_STORED_OBJ)).to.deep.equal(expectedDecodedObject);
});
it('should return undefined if passed a string', function() {
expect(id5IdSubmodule.decode('somestring')).to.eq(undefined);
Expand Down
12 changes: 6 additions & 6 deletions test/spec/modules/userId_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1235,8 +1235,8 @@ describe('User ID', function() {
expect(bid).to.have.deep.nested.property('userId.tdid');
expect(bid.userId.tdid).to.equal('testunifiedid');
// also check that Id5Id id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.id5id');
expect(bid.userId.id5id).to.equal('testid5id');
expect(bid).to.have.deep.nested.property('userId.id5id.uid');
expect(bid.userId.id5id.uid).to.equal('testid5id');
// check that identityLink id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.idl_env');
expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf');
Expand Down Expand Up @@ -1328,8 +1328,8 @@ describe('User ID', function() {
expect(bid).to.have.deep.nested.property('userId.tdid');
expect(bid.userId.tdid).to.equal('cookie-value-add-module-variations');
// also check that Id5Id id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.id5id');
expect(bid.userId.id5id).to.equal('testid5id');
expect(bid).to.have.deep.nested.property('userId.id5id.uid');
expect(bid.userId.id5id.uid).to.equal('testid5id');
// also check that identityLink id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.idl_env');
expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf');
Expand Down Expand Up @@ -1461,8 +1461,8 @@ describe('User ID', function() {
expect(bid).to.have.deep.nested.property('userId.tdid');
expect(bid.userId.tdid).to.equal('cookie-value-add-module-variations');
// also check that Id5Id id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.id5id');
expect(bid.userId.id5id).to.equal('testid5id');
expect(bid).to.have.deep.nested.property('userId.id5id.uid');
expect(bid.userId.id5id.uid).to.equal('testid5id');
// also check that identityLink id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.idl_env');
expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf');
Expand Down