diff --git a/modules/dmdIdSystem.js b/modules/dmdIdSystem.js index e08c8a6da82..7cf7b9fac95 100644 --- a/modules/dmdIdSystem.js +++ b/modules/dmdIdSystem.js @@ -23,8 +23,8 @@ export const dmdIdSubmodule = { * @returns {(Object|undefined)} */ decode(value) { - return value && typeof value['dmd-dgid'] === 'string' - ? { 'dmdId': value['dmd-dgid'] } + return value && typeof value === 'string' + ? { 'dmdId': value } : undefined; }, @@ -32,9 +32,11 @@ export const dmdIdSubmodule = { * performs action to obtain id and return a value in the callback's response argument * @function getId * @param {SubmoduleConfig} [config] + * @param {ConsentData} + * @param {Object} cacheIdObj - existing id, if any consentData] * @returns {IdResponse|undefined} */ - getId(config) { + getId(config, consentData, cacheIdObj) { try { const configParams = (config && config.params) || {}; if ( @@ -44,6 +46,8 @@ export const dmdIdSubmodule = { ) { utils.logError('dmd submodule requires an api_key.'); return; + } else { + return cacheIdObj; } } catch (e) { utils.logError(`dmdIdSystem encountered an error`, e); diff --git a/test/spec/modules/dmdIdSystem_spec.js b/test/spec/modules/dmdIdSystem_spec.js index 0de7533e6a7..9c603eebbd5 100644 --- a/test/spec/modules/dmdIdSystem_spec.js +++ b/test/spec/modules/dmdIdSystem_spec.js @@ -38,11 +38,11 @@ describe('Dmd ID System', function() { }); it('should return undefined if invalid dmd-dgid passed into decode', function () { - expect(dmdIdSubmodule.decode({'dmd-dgid': 123})).to.be.undefined; + expect(dmdIdSubmodule.decode(123)).to.be.undefined; }); it('should return dmdId if valid dmd-dgid passed into decode', function () { let data = { 'dmdId': 'U12345' }; - expect(dmdIdSubmodule.decode({'dmd-dgid': 'U12345'})).to.deep.equal(data); + expect(dmdIdSubmodule.decode('U12345')).to.deep.equal(data); }); });