diff --git a/modules/pairIdSystem.js b/modules/pairIdSystem.js index 4d73d4efb7e..b723d14329c 100644 --- a/modules/pairIdSystem.js +++ b/modules/pairIdSystem.js @@ -7,7 +7,7 @@ import { submodule } from '../src/hook.js'; import {getStorageManager} from '../src/storageManager.js' -import { logError } from '../src/utils.js'; +import { logInfo } from '../src/utils.js'; import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const MODULE_NAME = 'pairId'; @@ -17,11 +17,11 @@ const DEFAULT_LIVERAMP_PAIR_ID_KEY = '_lr_pairId'; export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); function pairIdFromLocalStorage(key) { - return storage.localStorageIsEnabled ? storage.getDataFromLocalStorage(key) : null; + return storage.localStorageIsEnabled() ? storage.getDataFromLocalStorage(key) : null; } function pairIdFromCookie(key) { - return storage.cookiesAreEnabled ? storage.getCookie(key) : null; + return storage.cookiesAreEnabled() ? storage.getCookie(key) : null; } /** @type {Submodule} */ @@ -52,7 +52,7 @@ export const pairIdSubmodule = { try { ids = ids.concat(JSON.parse(atob(pairIdsString))) } catch (error) { - logError(error) + logInfo(error) } } @@ -64,12 +64,12 @@ export const pairIdSubmodule = { const obj = JSON.parse(atob(liverampValue)); ids = ids.concat(obj.envelope); } catch (error) { - logError(error) + logInfo(error) } } if (ids.length == 0) { - logError('PairId not found.') + logInfo('PairId not found.') return undefined; } return {'id': ids}; diff --git a/test/spec/modules/pairIdSystem_spec.js b/test/spec/modules/pairIdSystem_spec.js index 4f75666affe..0bb42e56c25 100644 --- a/test/spec/modules/pairIdSystem_spec.js +++ b/test/spec/modules/pairIdSystem_spec.js @@ -3,11 +3,11 @@ import * as utils from 'src/utils.js'; describe('pairId', function () { let sandbox; - let logErrorStub; + let logInfoStub; beforeEach(() => { sandbox = sinon.sandbox.create(); - logErrorStub = sandbox.stub(utils, 'logError'); + logInfoStub = sandbox.stub(utils, 'logInfo'); }); afterEach(() => { sandbox.restore(); @@ -15,7 +15,7 @@ describe('pairId', function () { it('should log an error if no ID is found when getId', function() { pairIdSubmodule.getId({ params: {} }); - expect(logErrorStub.calledOnce).to.be.true; + expect(logInfoStub.calledOnce).to.be.true; }); it('should read pairId from local storage if exists', function() { @@ -65,4 +65,17 @@ describe('pairId', function () { }}) expect(id).to.be.deep.equal({id: pairIds}) }) + + it('should not get data from storage if local storage and cookies are disabled', function () { + sandbox.stub(storage, 'localStorageIsEnabled').returns(false); + sandbox.stub(storage, 'cookiesAreEnabled').returns(false); + let id = pairIdSubmodule.getId({ + params: { + liveramp: { + storageKey: 'lr_pairId_custom' + } + } + }) + expect(id).to.equal(undefined) + }) });