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

LiveIntent UserId module: Add support for openx and pubmatic id #10570

Merged
merged 2 commits into from
Oct 4, 2023
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
32 changes: 32 additions & 0 deletions modules/liveIntentIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ export const liveIntentIdSubmodule = {
result.index = { 'id': value.index, ext: { provider: LI_PROVIDER_DOMAIN } }
}

if (value.openx) {
result.openx = { 'id': value.openx, ext: { provider: LI_PROVIDER_DOMAIN } }
}

if (value.pubmatic) {
result.pubmatic = { 'id': value.pubmatic, ext: { provider: LI_PROVIDER_DOMAIN } }
}

return result
}

Expand Down Expand Up @@ -310,6 +318,30 @@ export const liveIntentIdSubmodule = {
return data.ext;
}
}
},
'openx': {
source: 'openx.com',
atype: 3,
getValue: function(data) {
return data.id;
},
getUidExt: function(data) {
if (data.ext) {
return data.ext;
}
}
},
'pubmatic': {
source: 'pubmatic.com',
atype: 3,
getValue: function(data) {
return data.id;
},
getUidExt: function(data) {
if (data.ext) {
return data.ext;
}
}
}
}
};
Expand Down
66 changes: 66 additions & 0 deletions test/spec/modules/eids_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,72 @@ describe('eids array generation for known sub-modules', function() {
});
});

it('openx', function () {
const userId = {
openx: { 'id': 'sample_id' }
};
const newEids = createEidsArray(userId);
expect(newEids.length).to.equal(1);
expect(newEids[0]).to.deep.equal({
source: 'openx.com',
uids: [{
id: 'sample_id',
atype: 3
}]
});
});

it('openx with ext', function () {
const userId = {
openx: { 'id': 'sample_id', 'ext': { 'provider': 'some.provider.com' } }
};
const newEids = createEidsArray(userId);
expect(newEids.length).to.equal(1);
expect(newEids[0]).to.deep.equal({
source: 'openx.com',
uids: [{
id: 'sample_id',
atype: 3,
ext: {
provider: 'some.provider.com'
}
}]
});
});

it('pubmatic', function() {
const userId = {
pubmatic: {'id': 'sample_id'}
};
const newEids = createEidsArray(userId);
expect(newEids.length).to.equal(1);
expect(newEids[0]).to.deep.equal({
source: 'pubmatic.com',
uids: [{
id: 'sample_id',
atype: 3
}]
});
});

it('pubmatic with ext', function() {
const userId = {
pubmatic: {'id': 'sample_id', 'ext': {'provider': 'some.provider.com'}}
};
const newEids = createEidsArray(userId);
expect(newEids.length).to.equal(1);
expect(newEids[0]).to.deep.equal({
source: 'pubmatic.com',
uids: [{
id: 'sample_id',
atype: 3,
ext: {
provider: 'some.provider.com'
}
}]
});
});

it('liveIntentId; getValue call and NO ext', function() {
const userId = {
lipb: {
Expand Down
10 changes: 10 additions & 0 deletions test/spec/modules/liveIntentIdMinimalSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@ describe('LiveIntentMinimalId', function() {
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar'}, 'index': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should decode an openx id to a seperate object when present', function () {
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', openx: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'openx': 'bar'}, 'openx': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should decode an pubmatic id to a seperate object when present', function() {
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', pubmatic: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'pubmatic': 'bar'}, 'pubmatic': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should allow disabling nonId resolution', function() {
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId({ params: {
Expand Down
10 changes: 10 additions & 0 deletions test/spec/modules/liveIntentIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,16 @@ describe('LiveIntentId', function() {
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar'}, 'index': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should decode an openx id to a seperate object when present', function () {
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', openx: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'openx': 'bar'}, 'openx': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should decode an pubmatic id to a seperate object when present', function() {
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', pubmatic: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'pubmatic': 'bar'}, 'pubmatic': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should allow disabling nonId resolution', function() {
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId({ params: {
Expand Down