-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DMD ID System: add new User ID module (#6666)
* feat(prebid): DMD UserID Module reading from 1st party cookie [PREBID-1] * feat(prebid):additional parameter[PREB-1] * feat(prebid):update decode function and cacheobi[PREB-1] * test(prebid):added more test coverage[PREB-11] * feat(typo):cleared typo[PREB-11] * test(prebid):updated test cases[PREB-11] * feat(releasenote):added a release note[PREB-11] * fix(releasenote):removed unnecessary release note[PREB-11] * fix(test):updated failing test cases[PREB-11] Co-authored-by: Matt Fitzgerald <matthewfitz@gmail.com> Co-authored-by: Karthik Boppudi <kboppudi@kboppudimac0518.local> Co-authored-by: mfitzgerald_dmd <mfitzgerald@dmdconnects.com>
- Loading branch information
1 parent
bd38efb
commit 07e5437
Showing
8 changed files
with
221 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* This module adds dmdId to the User ID module | ||
* The {@link module:modules/userId} module is required | ||
* @module modules/dmdIdSystem | ||
* @requires module:modules/userId | ||
*/ | ||
|
||
import * as utils from '../src/utils.js'; | ||
import { submodule } from '../src/hook.js'; | ||
|
||
/** @type {Submodule} */ | ||
export const dmdIdSubmodule = { | ||
/** | ||
* used to link submodule with config | ||
* @type {string} | ||
*/ | ||
name: 'dmdId', | ||
|
||
/** | ||
* decode the stored id value for passing to bid requests | ||
* @function decode | ||
* @param {(Object|string)} value | ||
* @returns {(Object|undefined)} | ||
*/ | ||
decode(value) { | ||
return value && typeof value === 'string' | ||
? { 'dmdId': value } | ||
: undefined; | ||
}, | ||
|
||
/** | ||
* 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, consentData, cacheIdObj) { | ||
try { | ||
const configParams = (config && config.params) || {}; | ||
if ( | ||
!configParams || | ||
!configParams.api_key || | ||
typeof configParams.api_key !== 'string' | ||
) { | ||
utils.logError('dmd submodule requires an api_key.'); | ||
return; | ||
} else { | ||
return cacheIdObj; | ||
} | ||
} catch (e) { | ||
utils.logError(`dmdIdSystem encountered an error`, e); | ||
} | ||
}, | ||
}; | ||
|
||
submodule('userId', dmdIdSubmodule); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
pbjs.setConfig({ | ||
userSync: { | ||
userIds: [{ | ||
name: 'dmdId', | ||
storage: { | ||
name: 'dmd-dgid', | ||
type: 'cookie', | ||
expires: 30 | ||
}, | ||
params: { | ||
api_key: '3fdbe297-3690-4f5c-9e11-ee9186a6d77c', // provided by DMD | ||
} | ||
}] | ||
} | ||
}); | ||
|
||
#### DMD ID Configuration | ||
|
||
{: .table .table-bordered .table-striped } | ||
| Param under userSync.userIds[] | Scope | Type | Description | Example | | ||
| --- | --- | --- | --- | --- | | ||
| name | Required | String | The name of Module | `"dmdId"` | | ||
| storage | Required | Object | | | ||
| storage.name | Required | String | `dmd-dgid` | | ||
| params | Required | Object | Container of all module params. | | | ||
| params.api_key | Required | String | This is your `api_key` as provided by DMD Marketing Corp. | `3fdbe297-3690-4f5c-9e11-ee9186a6d77c` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import * as utils from '../../../src/utils.js'; | ||
|
||
import {dmdIdSubmodule} from 'modules/dmdIdSystem.js'; | ||
|
||
describe('Dmd ID System', function() { | ||
let logErrorStub; | ||
|
||
beforeEach(function () { | ||
logErrorStub = sinon.stub(utils, 'logError'); | ||
}); | ||
|
||
afterEach(function () { | ||
logErrorStub.restore(); | ||
}); | ||
|
||
it('should log an error if no configParams were passed into getId', function () { | ||
dmdIdSubmodule.getId(); | ||
expect(logErrorStub.calledOnce).to.be.true; | ||
}); | ||
|
||
it('should log an error if configParams doesnot have api_key passed to getId', function () { | ||
dmdIdSubmodule.getId({params: {}}); | ||
expect(logErrorStub.calledOnce).to.be.true; | ||
}); | ||
|
||
it('should log an error if configParams has invalid api_key passed into getId', function () { | ||
dmdIdSubmodule.getId({params: {api_key: 123}}); | ||
expect(logErrorStub.calledOnce).to.be.true; | ||
}); | ||
|
||
it('should not log an error if configParams has valid api_key passed into getId', function () { | ||
dmdIdSubmodule.getId({params: {api_key: '3fdbe297-3690-4f5c-9e11-ee9186a6d77c'}}); | ||
expect(logErrorStub.calledOnce).to.be.false; | ||
}); | ||
|
||
it('should return undefined if empty value passed into decode', function () { | ||
expect(dmdIdSubmodule.decode()).to.be.undefined; | ||
}); | ||
|
||
it('should return undefined if invalid dmd-dgid passed into decode', function () { | ||
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('U12345')).to.deep.equal(data); | ||
}); | ||
}); |
Oops, something went wrong.