forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeepintentDpesIdSystem.js
64 lines (58 loc) · 1.83 KB
/
deepintentDpesIdSystem.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* 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';
import {MODULE_TYPE_UID} from '../src/activities/modules.js';
import {isPlainObject} from '../src/utils.js';
/**
* @typedef {import('../modules/userId/index.js').Submodule} Submodule
* @typedef {import('../modules/userId/index.js').SubmoduleConfig} SubmoduleConfig
* @typedef {import('../modules/userId/index.js').ConsentData} ConsentData
*/
const MODULE_NAME = 'deepintentId';
export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: 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;
},
eids: {
'deepintentId': {
source: 'deepintent.com',
atype: 3,
getValue: (userIdData) => {
if (isPlainObject(userIdData) && userIdData?.id) {
return userIdData.id;
}
return userIdData;
}
},
},
};
submodule('userId', deepintentDpesSubmodule);