Skip to content

Commit

Permalink
Deepintent ID System: add new ID module (#6537)
Browse files Browse the repository at this point in the history
* initial commit

* feat(deepintent-dpes): adds deepintent user id module

* chore(code-cleanup): removed console logs

* eids config added

* fix for passing the eids

* docs added with minor change

* tests added

* remaining conflict resolution

* kick off circle-ci tests manually

* fix linting error

* changed the atype to 3

* tests added for eids_spec.js

* Change the language

* added cacheIdObject signature

* changed test cases

* eIds passing added to adapter

* docs changed removed params not required

* doc added

* docs added in userId base

* user id tests added

* lint fixes

* lint fixes

* code review comments fix

Co-authored-by: Sourabh Gandhe <sourabh@Sourabhs-MacBook-Pro.local>
Co-authored-by: ChinmoyDebnath <chinmoy@lightbeam.ai>
Co-authored-by: Chris Huie <phoenixtechnerd@gmail.com>
  • Loading branch information
4 people authored Apr 15, 2021
1 parent a3790c2 commit caead3c
Show file tree
Hide file tree
Showing 10 changed files with 302 additions and 18 deletions.
1 change: 1 addition & 0 deletions modules/.submodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"zeotapIdPlusIdSystem",
"haloIdSystem",
"quantcastIdSystem",
"deepintentDpesIdSystem",
"nextrollIdSystem",
"idxIdSystem",
"fabrickIdSystem",
Expand Down
9 changes: 9 additions & 0 deletions modules/deepintentBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export const spec = {
utils.deepSetValue(openRtbBidRequest, 'regs.ext.gdpr', (bidderRequest.gdprConsent.gdprApplies ? 1 : 0));
}

injectEids(openRtbBidRequest, validBidRequests);

return {
method: 'POST',
url: BIDDER_ENDPOINT,
Expand Down Expand Up @@ -128,6 +130,13 @@ function buildUser(bid) {
}
}

function injectEids(openRtbBidRequest, validBidRequests) {
const bidUserIdAsEids = utils.deepAccess(validBidRequests, '0.userIdAsEids');
if (utils.isArray(bidUserIdAsEids) && bidUserIdAsEids.length > 0) {
utils.deepSetValue(openRtbBidRequest, 'user.eids', bidUserIdAsEids);
}
}

function buildBanner(bid) {
if (utils.deepAccess(bid, 'mediaTypes.banner')) {
// Get Sizes from MediaTypes Object, Will always take first size, will be overrided by params for exact w,h
Expand Down
45 changes: 45 additions & 0 deletions modules/deepintentDpesIdSystem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* This module adds DPES to the User ID module
* The {@link module:modules/userId} module is required
* @module modules/deepintentDpesSystem
* @requires module:modules/userId
*/

import { submodule } from '../src/hook.js';
import { getStorageManager } from '../src/storageManager.js';

const MODULE_NAME = 'deepintentId';
export const storage = getStorageManager(null, MODULE_NAME);

/** @type {Submodule} */
export const deepintentDpesSubmodule = {
/**
* used to link submodule with config
* @type {string}
*/
name: MODULE_NAME,
/**
* decode the stored id value for passing to bid requests
* @function
* @param {{value:string}} value
* @returns {{deepintentId:Object}}
*/
decode(value, config) {
return value ? { 'deepintentId': value } : undefined;
},

/**
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleConfig} config
* @param {ConsentData|undefined} consentData
* @param {Object} cacheIdObj - existing id, if any
* @return {{id: string | undefined} | undefined}
*/
getId(config, consentData, cacheIdObj) {
return cacheIdObj;
}

};

submodule('userId', deepintentDpesSubmodule);
43 changes: 43 additions & 0 deletions modules/deepintentDpesIdSystem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Deepintent DPES ID

The Deepintent Id is a shared, healthcare identifier which helps publisher in absence of the 3rd Party cookie matching. This lets publishers set and bid with healthcare identity . Deepintent lets users protect their privacy through advertising value chain, where Healthcare identity when setting the identity takes in consideration of users choices, as well as when passing identity on the cookie itself privacy consent strings are checked. The healthcare identity when set is not stored on Deepintent's servers but is stored on users browsers itself. User can still opt out of the ads by https://option.deepintent.com/adchoices.

## Deepintent DPES ID Registration

The Deepintent DPES ID is free to use, but requires a simple registration with Deepintent. Please reach to prebid@deepintent.com to get started.
Once publisher registers with deepintents platform for healthcare identity Deepintent provides the Tag code to be placed on the page, this tag code works to capture and store information as per publishers and users agreement. DPES User ID module uses this stored id and passes it on the deepintent prebid adapter.


## Deepintent DPES ID Configuration

First, make sure to add the Deepintent submodule to your Prebid.js package with:

```
gulp build --modules=deepintentDpesIdSystem,userId
```

The following configuration parameters are available:

```javascript
pbjs.setConfig({
userSync: {
userIds: [{
name: 'deepintentId',
storage: {
type: 'cookie',
name: '_dpes_id',
expires: 90 // storage lasts for 90 days, optional if storage type is html5
}
}],
auctionDelay: 50 // 50ms maximum auction delay, applies to all userId modules
}
});
```

| Param under userSync.userIds[] | Scope | Type | Description | Example |
| --- | --- | --- | --- | --- |
| name | Required | String | The name of this module: `"deepintentId"` | `"deepintentId"` |
| storage | Required | Object | Storage settings for how the User Id module will cache the Deepintent ID locally | |
| storage.type | Required | String | This is where the results of the user ID will be stored. Deepintent`"html5"` or `"cookie"`. | `"html5"` |
| storage.name | Required | String | The name of the local storage where the user ID will be stored. | `"_dpes_id"` |
| storage.expires | Optional | Integer | How long (in days) the user ID information will be stored. Deepintent recommends `90`. | `90` |
5 changes: 4 additions & 1 deletion modules/userId/eids.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ const USER_IDS_CONFIG = {
return data.id;
}
},

'deepintentId': {
source: 'deepintent.com',
atype: 3
},
// Admixer Id
'admixerId': {
source: 'admixer.net',
Expand Down
7 changes: 7 additions & 0 deletions modules/userId/eids.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ userIdAsEids = [
id: 'some-random-id-value',
atype: 3
}]
},
{
source: 'deepintent.com',
uids: [{
id: 'some-random-id-value',
atype: 3
}]
}
]
```
14 changes: 14 additions & 0 deletions modules/userId/userId.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@ pbjs.setConfig({
name: 'admixerId',
expires: 30
}
},{
name: "deepintentId",
storage: {
type: "html5",
name: "_dpes_id",
expires: 90
}
},{
name: "deepintentId",
storage: {
type: "cookie",
name: "_dpes_id",
expires: 90
}
}],
syncDelay: 5000
}
Expand Down
76 changes: 76 additions & 0 deletions test/spec/modules/deepintentDpesIdsystem_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { expect } from 'chai';
import find from 'core-js-pure/features/array/find.js';
import { storage, deepintentDpesSubmodule } from 'modules/deepintentDpesIdSystem.js';
import { init, requestBidsHook, setSubmoduleRegistry } from 'modules/userId/index.js';
import { config } from 'src/config.js';

const DI_COOKIE_NAME = '_dpes_id';
const DI_COOKIE_STORED = '{"id":"2cf40748c4f7f60d343336e08f80dc99"}';
const DI_COOKIE_OBJECT = {id: '2cf40748c4f7f60d343336e08f80dc99'};

const cookieConfig = {
name: 'deepintentId',
storage: {
type: 'cookie',
name: '_dpes_id',
expires: 28
}
};

const html5Config = {
name: 'deepintentId',
storage: {
type: 'html5',
name: '_dpes_id',
expires: 28
}
}

describe('Deepintent DPES System', () => {
let getDataFromLocalStorageStub, localStorageIsEnabledStub;
let getCookieStub, cookiesAreEnabledStub;

beforeEach(() => {
getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled');
getCookieStub = sinon.stub(storage, 'getCookie');
cookiesAreEnabledStub = sinon.stub(storage, 'cookiesAreEnabled');
});

afterEach(() => {
getDataFromLocalStorageStub.restore();
localStorageIsEnabledStub.restore();
getCookieStub.restore();
cookiesAreEnabledStub.restore();
});

describe('Deepintent Dpes Sytsem: test "getId" method', () => {
it('Wrong config should fail the tests', () => {
// no config
expect(deepintentDpesSubmodule.getId()).to.be.eq(undefined);
expect(deepintentDpesSubmodule.getId({ })).to.be.eq(undefined);

expect(deepintentDpesSubmodule.getId({params: {}, storage: {}})).to.be.eq(undefined);
expect(deepintentDpesSubmodule.getId({params: {}, storage: {type: 'cookie'}})).to.be.eq(undefined);
expect(deepintentDpesSubmodule.getId({params: {}, storage: {name: '_dpes_id'}})).to.be.eq(undefined);
});

it('Get value stored in cookie for getId', () => {
getCookieStub.withArgs(DI_COOKIE_NAME).returns(DI_COOKIE_STORED);
let diId = deepintentDpesSubmodule.getId(cookieConfig, undefined, DI_COOKIE_OBJECT);
expect(diId).to.deep.equal(DI_COOKIE_OBJECT);
});

it('provides the stored deepintentId if cookie is absent but present in local storage', () => {
getDataFromLocalStorageStub.withArgs(DI_COOKIE_NAME).returns(DI_COOKIE_STORED);
let idx = deepintentDpesSubmodule.getId(html5Config, undefined, DI_COOKIE_OBJECT);
expect(idx).to.deep.equal(DI_COOKIE_OBJECT);
});
});

describe('Deepintent Dpes System : test "decode" method', () => {
it('Get the correct decoded value for dpes id', () => {
expect(deepintentDpesSubmodule.decode(DI_COOKIE_OBJECT, cookieConfig)).to.deep.equal({'deepintentId': {'id': '2cf40748c4f7f60d343336e08f80dc99'}});
});
});
});
12 changes: 12 additions & 0 deletions test/spec/modules/eids_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@ describe('eids array generation for known sub-modules', function() {
});
});

it('deepintentId', function() {
const userId = {
deepintentId: 'some-random-id-value'
};
const newEids = createEidsArray(userId);
expect(newEids.length).to.equal(1);
expect(newEids[0]).to.deep.equal({
source: 'deepintent.com',
uids: [{id: 'some-random-id-value', atype: 3}]
});
});

it('NetId', function() {
const userId = {
netId: 'some-random-id-value'
Expand Down
Loading

0 comments on commit caead3c

Please sign in to comment.