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

LiveIntentId submodule updates #5407

Merged
merged 6 commits into from
Jun 23, 2020
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: 10 additions & 0 deletions integrationExamples/gpt/userId_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@
name: "sharedid",
expires: 28
}
}, {
name: "liveIntentId",
params: {
publisherId: "9896876"
},
storage: {
type: "cookie",
name: "_li_pbid",
expires: 28
}
}],
syncDelay: 5000,
auctionDelay: 1000
Expand Down
24 changes: 7 additions & 17 deletions modules/liveIntentIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ let liveConnect = null;
* This function is used in tests
*/
export function reset() {
if (window && window.liQ) {
window.liQ = [];
}
eventFired = false;
liveConnect = null;
}
Expand All @@ -45,16 +48,12 @@ function parseLiveIntentCollectorConfig(collectConfig) {
}

function initializeLiveConnect(configParams) {
configParams = configParams || {};
if (liveConnect) {
return liveConnect;
}

const publisherId = configParams && configParams.publisherId;
if (!publisherId && typeof publisherId !== 'string') {
utils.logError(`${MODULE_NAME} - publisherId must be defined, not a '${publisherId}'`);
return;
}

const publisherId = configParams.publisherId || 'any';
const identityResolutionConfig = {
source: 'prebid',
publisherId: publisherId
Expand All @@ -65,20 +64,11 @@ function initializeLiveConnect(configParams) {
if (configParams.partner) {
identityResolutionConfig.source = configParams.partner
}
if (configParams.storage && configParams.storage.expires) {
identityResolutionConfig.expirationDays = configParams.storage.expires;
}
if (configParams.ajaxTimeout) {
identityResolutionConfig.ajaxTimeout = configParams.ajaxTimeout;
}

const liveConnectConfig = parseLiveIntentCollectorConfig(configParams.liCollectConfig);
liveConnectConfig.wrapperName = 'prebid';
liveConnectConfig.identityResolutionConfig = identityResolutionConfig;
liveConnectConfig.identifiersToResolve = configParams.identifiersToResolve || [];
if (configParams.providedIdentifierName) {
liveConnectConfig.providedIdentifierName = configParams.providedIdentifierName;
}
const usPrivacyString = uspDataHandler.getConsentData();
if (usPrivacyString) {
liveConnectConfig.usPrivacyString = usPrivacyString;
Expand Down Expand Up @@ -120,10 +110,10 @@ export const liveIntentIdSubmodule = {
return { 'lipb': { ...base, ...value } };
}

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

return (value && typeof value['unifiedId'] === 'string') ? composeIdObject(value) : undefined;
},
Expand Down
4 changes: 2 additions & 2 deletions modules/userId/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ function initSubmodules(submodules, consentData) {

if (storedId) {
// cache decoded value (this is copied to every adUnit bid)
submodule.idObj = submodule.submodule.decode(storedId, submodule.config);
submodule.idObj = submodule.submodule.decode(storedId, submodule.config.params);
}
} else if (submodule.config.value) {
// cache decoded value (this is copied to every adUnit bid)
Expand All @@ -458,7 +458,7 @@ function initSubmodules(submodules, consentData) {
const response = submodule.submodule.getId(submodule.config.params, consentData, undefined);
if (utils.isPlainObject(response)) {
if (typeof response.callback === 'function') { submodule.callback = response.callback; }
if (response.id) { submodule.idObj = submodule.submodule.decode(response.id, submodule.config); }
if (response.id) { submodule.idObj = submodule.submodule.decode(response.id, submodule.config.params); }
}
}
carry.push(submodule);
Expand Down
18 changes: 6 additions & 12 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 @@ -112,6 +112,6 @@
"fun-hooks": "^0.9.9",
"jsencrypt": "^3.0.0-rc.1",
"just-clone": "^1.0.2",
"live-connect-js": "1.1.1"
"live-connect-js": "1.1.10"
}
}
15 changes: 0 additions & 15 deletions test/spec/modules/liveIntentIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,6 @@ describe('LiveIntentId', function () {
resetLiveIntentIdSubmodule();
});

it('should log an error if no configParams were passed when getId', function () {
liveIntentIdSubmodule.getId();
expect(logErrorStub.calledOnce).to.be.true;
});

it('should log an error if publisherId configParam was not passed when getId', function () {
liveIntentIdSubmodule.getId({});
expect(logErrorStub.calledOnce).to.be.true;
});

it('should log an error if publisherId configParam was not passed when decode', function () {
liveIntentIdSubmodule.decode({}, {});
expect(logErrorStub.calledOnce).to.be.true;
});

it('should initialize LiveConnect with a us privacy string when getId, and include it in all requests', function () {
consentDataStub.returns('1YNY');
let callBackSpy = sinon.spy();
Expand Down