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

Lotame Panorama Id System: bug fixes #9092

Merged
merged 2 commits into from
Oct 10, 2022
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
16 changes: 10 additions & 6 deletions modules/lotamePanoramaIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const DAYS_TO_CACHE = 7;
const DAY_MS = 60 * 60 * 24 * 1000;
const MISSING_CORE_CONSENT = 111;
const GVLID = 95;
const ID_HOST = 'id.crwdcntrl.net';

export const storage = getStorageManager({gvlid: GVLID, moduleName: MODULE_NAME});
let cookieDomain;
Expand Down Expand Up @@ -57,12 +58,14 @@ function setProfileId(profileId) {
* Get the Lotame profile id by checking cookies first and then local storage
*/
function getProfileId() {
let profileId;
if (storage.cookiesAreEnabled()) {
return storage.getCookie(KEY_PROFILE, undefined);
profileId = storage.getCookie(KEY_PROFILE, undefined);
}
if (storage.hasLocalStorage()) {
return storage.getDataFromLocalStorage(KEY_PROFILE, undefined);
if (!profileId && storage.hasLocalStorage()) {
profileId = storage.getDataFromLocalStorage(KEY_PROFILE, undefined);
}
return profileId;
}

/**
Expand All @@ -78,10 +81,11 @@ function getFromStorage(key) {
const storedValueExp = storage.getDataFromLocalStorage(
`${key}_exp`, undefined
);
if (storedValueExp === '') {

if (storedValueExp === '' || storedValueExp === null) {
value = storage.getDataFromLocalStorage(key, undefined);
} else if (storedValueExp) {
if ((new Date(storedValueExp)).getTime() - Date.now() > 0) {
if ((new Date(parseInt(storedValueExp, 10))).getTime() - Date.now() > 0) {
value = storage.getDataFromLocalStorage(key, undefined);
}
}
Expand Down Expand Up @@ -284,7 +288,7 @@ export const lotamePanoramaIdSubmodule = {

const url = buildUrl({
protocol: 'https',
host: `id.crwdcntrl.net`,
host: ID_HOST,
pathname: '/id',
search: isEmpty(queryParams) ? undefined : queryParams,
});
Expand Down
1 change: 0 additions & 1 deletion test/spec/modules/lotamePanoramaIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ describe('LotameId', function() {

it('should call the remote server when getId is called', function () {
expect(request.url).to.be.eq('https://id.crwdcntrl.net/id');

expect(callBackSpy.calledOnce).to.be.true;
});

Expand Down