Skip to content

Commit

Permalink
Allow to configure distributorId
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Dreiling authored and Viktor Dreiling committed May 12, 2023
1 parent facd0b7 commit d4431dc
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/liveIntentIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ function initializeLiveConnect(configParams) {
}

const liveConnectConfig = parseLiveIntentCollectorConfig(configParams.liCollectConfig);

if (!liveConnectConfig.appId && configParams.distributorId) {
liveConnectConfig.distributorId = configParams.distributorId;
identityResolutionConfig.source = configParams.distributorId;
}

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 distributor id', 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 distributor id when app id and distributor id are 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
52 changes: 52 additions & 0 deletions test/spec/modules/liveIntentIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ describe('LiveIntentId', function() {
}, 200);
});

it('should fire an event with the appId only when appId and distributorId are 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 +171,34 @@ describe('LiveIntentId', function() {
expect(callBackSpy.calledOnceWith({})).to.be.true;
});

it('should call the Identity Exchange endpoint with the privided distributor id', 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 distributor id when app id and distributor id are 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 Expand Up @@ -198,6 +235,21 @@ describe('LiveIntentId', function() {
expect(callBackSpy.calledOnce).to.be.true;
});

it('should call the LiveIntent Identity Exchange endpoint, with no additional query params', function() {
getCookieStub.returns(null);
let callBackSpy = sinon.spy();
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?resolve=nonId');
request.respond(
200,
responseHeader,
JSON.stringify({})
);
expect(callBackSpy.calledOnce).to.be.true;
});

it('should log an error and continue to callback if ajax request errors', function() {
getCookieStub.returns(null);
let callBackSpy = sinon.spy();
Expand Down

0 comments on commit d4431dc

Please sign in to comment.