forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathczechAdIdSystem.js
59 lines (53 loc) · 1.56 KB
/
czechAdIdSystem.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
/**
* This module adds 'caid' to the User ID module
* The {@link module:modules/userId} module is required
* @module modules/czechAdIdSystem
* @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';
/**
* @typedef {import('../modules/userId/index.js').Submodule} Submodule
* @typedef {import('../modules/userId/index.js').IdResponse} IdResponse
*/
// Returns StorageManager
export const storage = getStorageManager({ moduleType: MODULE_TYPE_UID, moduleName: 'czechAdId' })
// Returns the id string from either cookie or localstorage
const readId = () => { return storage.getCookie('czaid') || storage.getDataFromLocalStorage('czaid') }
/** @type {Submodule} */
export const czechAdIdSubmodule = {
version: '0.1.0',
/**
* used to link submodule with config
* @type {string}
*/
name: 'czechAdId',
/**
* Vendor ID of Czech Publisher Exchange
* @type {Number}
*/
gvlid: 570,
/**
* decode the stored id value for passing to bid requests
* @function decode
* @returns {(Object|undefined)}
*/
decode () { return { czechAdId: readId() } },
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
* @returns {IdResponse|undefined}
*/
getId () {
const id = readId()
return id ? { id: id } : undefined
},
eids: {
'czechAdId': {
source: 'czechadid.cz',
atype: 1
},
}
}
submodule('userId', czechAdIdSubmodule)