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

[CM-587][Do not merge] Allow resolving uid2 and custom attributes #5

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
26 changes: 21 additions & 5 deletions modules/liveIntentIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ function initializeLiveConnect(configParams) {
const publisherId = configParams.publisherId || 'any';
const identityResolutionConfig = {
source: 'prebid',
publisherId: publisherId
publisherId: publisherId,
requestedAttributes: [ 'nonId' ].concat(configParams.extraRequestedAttributes || [ ])
Copy link

Choose a reason for hiding this comment

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

It looks like we have three proposals how to compute requestedAttributes:

We also need a configuration option for publishers that defaults to true for each 
bid request - in future we could potentially do Ramp ID envelopes. So the json 
configuration could specify which ID they want to enrich in their web bid request
- some thing including name of id, true along with an optional fields that could 
pass anything we need to generate the identifiers they want us to enrich. 
If this config is set to false, we do not enrich bid request with the identifier.

I think either opting in or opting out should work.

Copy link
Author

Choose a reason for hiding this comment

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

This is the same as the spec, with the one difference being that we always resolve nonId. That is important for our module to work correctly, so we should not allow users to disable it.

But good point regarding disabling some future default values. Will update this to operate on an object instead of a list

Copy link

Choose a reason for hiding this comment

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

🤦 misread nonId for uid :)

Copy link

Choose a reason for hiding this comment

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

But good point regarding disabling some future default values. Will update this to operate on an object instead of a list

👍

};
if (configParams.url) {
identityResolutionConfig.url = configParams.url
Expand Down Expand Up @@ -136,17 +137,32 @@ export const liveIntentIdSubmodule = {
decode(value, config) {
const configParams = (config && config.params) || {};
function composeIdObject(value) {
const base = { 'lipbid': value.unifiedId };
delete value.unifiedId;
return { 'lipb': { ...base, ...value } };
// old versions stored lipbid in unifiedId. Ensure that we can still read the data.
value.lipbid = value.nonId || value.unifiedId
wi101 marked this conversation as resolved.
Show resolved Hide resolved
delete value.unifiedId

const result = { 'lipb': value }

// Lift usage of uid2 by exposing uid2 if we were asked to resolve it.
// As adapters are applied in lexicographical order, we will always
// be overwritten by the 'proper' uid2 module if it is present.
if (value.uid2) {
result.uid2 = { 'id': value.uid2 }
}

return result
}

function isValid(value) {
return value && (typeof value['nonId'] === 'string' || typeof value['unifiedId'] === 'string')
}

if (!liveConnect) {
initializeLiveConnect(configParams);
}
tryFireEvent();

return (value && typeof value['unifiedId'] === 'string') ? composeIdObject(value) : undefined;
return isValid(value) ? composeIdObject(value) : undefined;
},

/**
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"express": "^4.15.4",
"fun-hooks": "^0.9.9",
"just-clone": "^1.0.2",
"live-connect-js": "2.3.3"
"live-connect-js": "2.4.0-alpha.1"
},
"optionalDependencies": {
"fsevents": "^2.3.2"
Expand Down
46 changes: 39 additions & 7 deletions test/spec/modules/liveIntentIdMinimalSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('LiveIntentMinimalId', function() {
let submoduleCallback = liveIntentIdSubmodule.getId({ params: {...defaultConfigParams.params, ...{'url': 'https://dummy.liveintent.com/idex'}} }).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899');
expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899?resolve=nonId');
request.respond(
200,
responseHeader,
Expand All @@ -85,7 +85,7 @@ describe('LiveIntentMinimalId', function() {
} }).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/rubicon/89899');
expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/rubicon/89899?resolve=nonId');
request.respond(
200,
responseHeader,
Expand All @@ -100,7 +100,7 @@ describe('LiveIntentMinimalId', function() {
let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899');
expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?resolve=nonId');
request.respond(
200,
responseHeader,
Expand All @@ -115,7 +115,7 @@ describe('LiveIntentMinimalId', function() {
let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899');
expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?resolve=nonId');
request.respond(
503,
responseHeader,
Expand All @@ -132,7 +132,7 @@ describe('LiveIntentMinimalId', function() {
let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}`);
expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}&resolve=nonId`);
request.respond(
200,
responseHeader,
Expand All @@ -155,7 +155,7 @@ describe('LiveIntentMinimalId', function() {
let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}&_thirdPC=third-pc`);
expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}&_thirdPC=third-pc&resolve=nonId`);
request.respond(
200,
responseHeader,
Expand All @@ -177,12 +177,44 @@ describe('LiveIntentMinimalId', function() {
let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?_thirdPC=%7B%22key%22%3A%22value%22%7D');
expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?_thirdPC=%7B%22key%22%3A%22value%22%7D&resolve=nonId');
request.respond(
200,
responseHeader,
JSON.stringify({})
);
expect(callBackSpy.calledOnce).to.be.true;
});

it('should decode a unifiedId to lipbId and remove it', function() {
const result = liveIntentIdSubmodule.decode({ unifiedId: 'data' });
expect(result).to.eql({'lipb': {'lipbid': 'data'}});
});

it('should decode a nonId to lipbId', function() {
const result = liveIntentIdSubmodule.decode({ nonId: 'data' });
expect(result).to.eql({'lipb': {'lipbid': 'data', 'nonId': 'data'}});
});

it('should resolve extra attributes', function() {
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId({ params: {
...defaultConfigParams.params,
...{ extraRequestedAttributes: ['foo'] }
} }).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?resolve=nonId&resolve=foo`);
request.respond(
200,
responseHeader,
JSON.stringify({})
);
expect(callBackSpy.calledOnce).to.be.true;
});

it('should decode a uid2 to a seperate object when present', function() {
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', uid2: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar'}, 'uid2': {'id': 'bar'}});
});
});
46 changes: 39 additions & 7 deletions test/spec/modules/liveIntentIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('LiveIntentId', function() {
let submoduleCallback = liveIntentIdSubmodule.getId({ params: {...defaultConfigParams.params, ...{'url': 'https://dummy.liveintent.com/idex'}} }).callback;
submoduleCallback(callBackSpy);
let request = server.requests[1];
expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899');
expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899?resolve=nonId');
request.respond(
204,
responseHeader
Expand All @@ -153,7 +153,7 @@ describe('LiveIntentId', function() {
} }).callback;
submoduleCallback(callBackSpy);
let request = server.requests[1];
expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/rubicon/89899');
expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/rubicon/89899?resolve=nonId');
request.respond(
200,
responseHeader,
Expand All @@ -168,7 +168,7 @@ describe('LiveIntentId', function() {
let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[1];
expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899');
expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?resolve=nonId');
request.respond(
200,
responseHeader,
Expand All @@ -183,7 +183,7 @@ describe('LiveIntentId', function() {
let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[1];
expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899');
expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?resolve=nonId');
request.respond(
503,
responseHeader,
Expand All @@ -200,7 +200,7 @@ describe('LiveIntentId', function() {
let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[1];
expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}`);
expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}&resolve=nonId`);
request.respond(
200,
responseHeader,
Expand All @@ -223,7 +223,7 @@ describe('LiveIntentId', function() {
let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[1];
expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}&_thirdPC=third-pc`);
expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}&_thirdPC=third-pc&resolve=nonId`);
request.respond(
200,
responseHeader,
Expand All @@ -245,7 +245,7 @@ describe('LiveIntentId', function() {
let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[1];
expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?_thirdPC=%7B%22key%22%3A%22value%22%7D');
expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?_thirdPC=%7B%22key%22%3A%22value%22%7D&resolve=nonId');
request.respond(
200,
responseHeader,
Expand All @@ -259,4 +259,36 @@ describe('LiveIntentId', function() {
liveIntentIdSubmodule.getId(defaultConfigParams);
expect(imgStub.getCall(0).args[0]).to.match(/.*ae=.+/);
});

it('should decode a unifiedId to lipbId and remove it', function() {
const result = liveIntentIdSubmodule.decode({ unifiedId: 'data' });
expect(result).to.eql({'lipb': {'lipbid': 'data'}});
});

it('should decode a nonId to lipbId', function() {
const result = liveIntentIdSubmodule.decode({ nonId: 'data' });
expect(result).to.eql({'lipb': {'lipbid': 'data', 'nonId': 'data'}});
});

it('should resolve extra attributes', function() {
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId({ params: {
...defaultConfigParams.params,
...{ extraRequestedAttributes: ['foo'] }
} }).callback;
submoduleCallback(callBackSpy);
let request = server.requests[1];
expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?resolve=nonId&resolve=foo`);
request.respond(
200,
responseHeader,
JSON.stringify({})
);
expect(callBackSpy.calledOnce).to.be.true;
});

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