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 Id System: fix for parsing response twice #6418

Merged
merged 2 commits into from
Mar 16, 2021
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
10 changes: 1 addition & 9 deletions modules/liveIntentIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,7 @@ export const liveIntentIdSubmodule = {
const result = function(callback) {
liveConnect.resolve(
response => {
let responseObj = {};
if (response) {
try {
responseObj = JSON.parse(response);
} catch (error) {
utils.logError(error);
}
}
callback(responseObj);
callback(response);
},
error => {
utils.logError(`${MODULE_NAME}: ID fetch encountered an error: `, error);
Expand Down
17 changes: 10 additions & 7 deletions test/spec/modules/liveIntentIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('LiveIntentId', function() {
resetLiveIntentIdSubmodule();
});

it('should initialize LiveConnect with a privacy string when getId, and include it in the resolution request', function() {
it('should initialize LiveConnect with a privacy string when getId, and include it in the resolution request', function () {
uspConsentDataStub.returns('1YNY');
gdprConsentDataStub.returns({
gdprApplies: true,
Expand All @@ -47,12 +47,16 @@ describe('LiveIntentId', function() {
submoduleCallback(callBackSpy);
let request = server.requests[1];
expect(request.url).to.match(/.*us_privacy=1YNY.*&gdpr=1&gdpr_consent=consentDataString.*/);
const response = {
unifiedId: 'a_unified_id',
segments: [123, 234]
}
request.respond(
200,
responseHeader,
JSON.stringify({})
JSON.stringify(response)
);
expect(callBackSpy.calledOnce).to.be.true;
expect(callBackSpy.calledOnceWith(response)).to.be.true;
});

it('should fire an event when getId', function() {
Expand Down Expand Up @@ -131,11 +135,10 @@ describe('LiveIntentId', function() {
let request = server.requests[1];
expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899');
request.respond(
200,
responseHeader,
JSON.stringify({})
204,
responseHeader
);
expect(callBackSpy.calledOnce).to.be.true;
expect(callBackSpy.calledOnceWith({})).to.be.true;
});

it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function() {
Expand Down