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-769 - Allow to configure distributorId #15

Closed
wants to merge 3 commits into from
Closed
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
12 changes: 8 additions & 4 deletions modules/liveIntentIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,25 @@ function initializeLiveConnect(configParams) {

const publisherId = configParams.publisherId || 'any';
const identityResolutionConfig = {
source: 'prebid',
publisherId: publisherId,
requestedAttributes: parseRequestedAttributes(configParams.requestedAttributesOverrides)
};
if (configParams.url) {
identityResolutionConfig.url = configParams.url
}
if (configParams.partner) {
identityResolutionConfig.source = configParams.partner
}
if (configParams.ajaxTimeout) {
identityResolutionConfig.ajaxTimeout = configParams.ajaxTimeout;
}

const liveConnectConfig = parseLiveIntentCollectorConfig(configParams.liCollectConfig);

if (!liveConnectConfig.appId && configParams.distributorId) {
liveConnectConfig.distributorId = configParams.distributorId;
Comment on lines +107 to +108
Copy link
Author

Choose a reason for hiding this comment

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

LiveConnect already ignores the distributorId when an appId is present. Duplicating this check here to have all distributorId related config decisions in one place.

Choose a reason for hiding this comment

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

since we have two different places where the publisher id and distributor id (publisher id ends up in a separate column whereas distributor id is going be a part of destination field), I would recommend we keep both. Happy to learn more about what you think.

Choose a reason for hiding this comment

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

It's not strictly duplicating the logic. In LiveConnect we have if(appId && distributorId). And here we have a bit different condition. But IMHO it is better to have the LC config logic in one place.

Copy link
Author

Choose a reason for hiding this comment

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

@SuperIzya You mean in one place like here or in one place in live-connect?

Choose a reason for hiding this comment

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

IMHO, it would make more sense to have in live-connect. But I'm fine either way, as long as it's the only place

identityResolutionConfig.source = configParams.distributorId;

Choose a reason for hiding this comment

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

identityResolutionConfig.source is set only if no appId was provided. Is that intentional?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it is intentional.

} else {
identityResolutionConfig.source = configParams.partner || 'prebid'
}

liveConnectConfig.wrapperName = 'prebid';
liveConnectConfig.identityResolutionConfig = identityResolutionConfig;
liveConnectConfig.identifiersToResolve = configParams.identifiersToResolve || [];
Expand Down
28 changes: 28 additions & 0 deletions test/spec/modules/liveIntentIdMinimalSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,34 @@ describe('LiveIntentMinimalId', function() {
expect(callBackSpy.calledOnce).to.be.true;
});

it('should call the Identity Exchange endpoint with the privided distributorId', function() {
getCookieStub.returns(null);
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111' } }).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq('https://idx.liadm.com/idex/did-1111/any?did=did-1111&resolve=nonId');
request.respond(
204,
responseHeader
);
expect(callBackSpy.calledOnceWith({})).to.be.true;
});

it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided', function() {
getCookieStub.returns(null);
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111', liCollectConfig: { appId: 'a-0001' } } }).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/any?resolve=nonId');
request.respond(
204,
responseHeader
);
expect(callBackSpy.calledOnceWith({})).to.be.true;
});

it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function() {
getCookieStub.returns(null);
let callBackSpy = sinon.spy();
Expand Down
45 changes: 45 additions & 0 deletions test/spec/modules/liveIntentIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ describe('LiveIntentId', function() {
}, 200);
});

it('should fire an event with the provided distributorId', function (done) {
liveIntentIdSubmodule.decode({}, { params: { fireEventDelay: 1, distributorId: 'did-1111' } });
setTimeout(() => {
expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*did=did-1111.*&wpn=prebid.*/);
done();
}, 200);
});

it('should fire an event without the provided distributorId when appId is provided', function (done) {
liveIntentIdSubmodule.decode({}, { params: { fireEventDelay: 1, distributorId: 'did-1111', liCollectConfig: { appId: 'a-0001' } } });
setTimeout(() => {
expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*aid=a-0001.*&wpn=prebid.*/);
expect(server.requests[0].url).to.not.match(/.*did=*/);
done();
}, 200);
});

it('should initialize LiveConnect and emit an event with a privacy string when decode', function(done) {
uspConsentDataStub.returns('1YNY');
gdprConsentDataStub.returns({
Expand Down Expand Up @@ -162,6 +179,34 @@ describe('LiveIntentId', function() {
expect(callBackSpy.calledOnceWith({})).to.be.true;
});

it('should call the Identity Exchange endpoint with the privided distributorId', function() {
getCookieStub.returns(null);
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111' } }).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq('https://idx.liadm.com/idex/did-1111/any?did=did-1111&resolve=nonId');
request.respond(
204,
responseHeader
);
expect(callBackSpy.calledOnceWith({})).to.be.true;
});

it('should call the Identity Exchange endpoint without the privided distributorId when appId is provided', function() {
getCookieStub.returns(null);
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId({ params: { fireEventDelay: 1, distributorId: 'did-1111', liCollectConfig: { appId: 'a-0001' } } }).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/any?resolve=nonId');
request.respond(
204,
responseHeader
);
expect(callBackSpy.calledOnceWith({})).to.be.true;
});

it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function() {
getCookieStub.returns(null);
let callBackSpy = sinon.spy();
Expand Down