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

DMD ID System: add new User ID module #6666

Merged
merged 19 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6e50492
Merge pull request #3 from dmdconnects/master
matthewfitz Apr 16, 2021
9310362
feat(prebid): DMD UserID Module reading from 1st party cookie [PREBID-1]
boppudikarthikc Apr 20, 2021
cea9fe9
Merge pull request #2 from dmdconnects/feature/prebid-1-dmd-userid-mo…
matthewfitz Apr 20, 2021
4791129
feat(prebid):additional parameter[PREB-1]
Apr 22, 2021
9582756
feat(prebid):update decode function and cacheobi[PREB-1]
Apr 22, 2021
54c8909
Merge pull request #4 from dmdconnects/feature/PREB-1-additional-user…
matthewfitz Apr 22, 2021
68ceda8
test(prebid):added more test coverage[PREB-11]
Apr 29, 2021
a2bf7de
feat(typo):cleared typo[PREB-11]
Apr 29, 2021
1dc1e7c
test(prebid):updated test cases[PREB-11]
Apr 29, 2021
08f24c5
feat(releasenote):added a release note[PREB-11]
Apr 29, 2021
697dd3c
Merge pull request #5 from dmdconnects/feature/PREB-11-more-test-cove…
matthewfitz Apr 30, 2021
9badb0b
Merge branch 'master' of github.com:prebid/Prebid.js into fix/merge-r…
Apr 30, 2021
73727a8
ops(merge-resolution): Merge resolution on upstream repository
Apr 30, 2021
3a4311b
fix(releasenote):removed unnecessary release note[PREB-11]
Apr 30, 2021
772b294
Merge pull request #7 from dmdconnects/fix/PREB-11-remove-release-note
matthewfitz Apr 30, 2021
6d6e9b0
Merge pull request #6 from dmdconnects/fix/merge-resolution-on-upstream
matthewfitz Apr 30, 2021
b83fdc9
Merge pull request #8 from dmdconnects/master
boppudikarthikc Apr 30, 2021
c5c6637
fix(test):updated failing test cases[PREB-11]
Apr 30, 2021
a23a4cf
Merge pull request #9 from dmdconnects/fix/PREB-11-failing-tests
matthewfitz Apr 30, 2021
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
3 changes: 2 additions & 1 deletion modules/.submodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"tapadIdSystem",
"novatiqIdSystem",
"uid2IdSystem",
"admixerIdSystem"
"admixerIdSystem",
"dmdIdSystem"
],
"adpod": [
"freeWheelAdserverVideo",
Expand Down
58 changes: 58 additions & 0 deletions modules/dmdIdSystem.js
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'
smenzer marked this conversation as resolved.
Show resolved Hide resolved
) {
utils.logError('dmd submodule requires an api_key.');
return;
} else {
return cacheIdObj;
}
} catch (e) {
utils.logError(`dmdIdSystem encountered an error`, e);
}
},
};

submodule('userId', dmdIdSubmodule);
26 changes: 26 additions & 0 deletions modules/dmdIdSystem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
pbjs.setConfig({
userSync: {
userIds: [{
name: 'dmdId',
storage: {
name: 'dmd-dgid',
smenzer marked this conversation as resolved.
Show resolved Hide resolved
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` |
6 changes: 6 additions & 0 deletions modules/userId/eids.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ const USER_IDS_CONFIG = {
atype: 3
},

// dmdId
'dmdId': {
source: 'hcn.health',
atype: 3
},

// lotamePanoramaId
lotamePanoramaId: {
source: 'crwdcntrl.net',
Expand Down
8 changes: 8 additions & 0 deletions modules/userId/eids.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ userIdAsEids = [
}]
},

{
source: 'hcn.health',
uids: [{
id: 'some-random-id-value',
atype: 3
}]
},

{
source: 'criteo.com',
uids: [{
Expand Down
10 changes: 10 additions & 0 deletions modules/userId/userId.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ pbjs.setConfig({
name: "_pubcid",
expires: 60
}
}, {
name: 'dmdId',
storage: {
name: 'dmd-dgid',
type: 'cookie',
expires: 30
},
params: {
api_key: '3fdbe297-3690-4f5c-9e11-ee9186a6d77c', // provided by DMD
}
}, {
name: "unifiedId",
params: {
Expand Down
48 changes: 48 additions & 0 deletions test/spec/modules/dmdIdSystem_spec.js
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);
});
});
Loading