-
Notifications
You must be signed in to change notification settings - Fork 2.2k
UID 2.0 Userid submodule #6443
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
UID 2.0 Userid submodule #6443
Changes from 2 commits
b05007b
ec62033
46a5615
0e19eaa
5c99380
b0a23ca
973038a
aae9f52
5440b27
84ff68d
0e775ed
8d9b40f
dc96f6e
fa0d81d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
* This module adds uid2 ID support to the User ID module | ||
* The {@link module:modules/userId} module is required. | ||
* @module modules/uid2IdSystem | ||
* @requires module:modules/userId | ||
*/ | ||
|
||
import * as utils from '../src/utils.js' | ||
import {submodule} from '../src/hook.js'; | ||
import {getStorageManager} from '../src/storageManager.js'; | ||
|
||
const storage = getStorageManager(); | ||
|
||
const MODULE_NAME = 'uid20'; | ||
pm-harshad-mane marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const GVLID = 887; | ||
const LOG_PRE_FIX = 'UID20: '; | ||
const ADVERTISING_COOKIE = '__uid2_advertising_token'; | ||
|
||
const logInfo = createLogInfo(LOG_PRE_FIX); | ||
|
||
function createLogInfo(prefix) { | ||
return function (...strings) { | ||
utils.logInfo(prefix + ' ', ...strings); | ||
} | ||
} | ||
|
||
/** | ||
* Encode the id | ||
* @param value | ||
* @returns {string|*} | ||
*/ | ||
function encodeId(value) { | ||
const result = {}; | ||
if (value) { | ||
const bidIds = { | ||
id: value | ||
} | ||
result.uid20 = bidIds; | ||
logInfo('Decoded value ' + JSON.stringify(result)); | ||
return result; | ||
} | ||
return undefined; | ||
} | ||
|
||
/** @type {Submodule} */ | ||
export const uid2IdSubmodule = { | ||
/** | ||
* used to link submodule with config | ||
* @type {string} | ||
*/ | ||
name: MODULE_NAME, | ||
|
||
/** | ||
* Vendor id of Prebid | ||
* @type {Number} | ||
*/ | ||
gvlid: GVLID, | ||
/** | ||
* decode the stored id value for passing to bid requests | ||
* @function | ||
* @param {string} value | ||
* @returns {{sharedid:{ id: string, third:string}} or undefined if value doesn't exists | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. refs: sharedid, is this on purpose? |
||
*/ | ||
decode(value) { | ||
return (value) ? encodeId(value) : undefined; | ||
}, | ||
|
||
/** | ||
* performs action to obtain id and return a value. | ||
* @function | ||
* @param {SubmoduleConfig} [config] | ||
* @param {ConsentData|undefined} consentData | ||
* @returns {sharedId} | ||
*/ | ||
getId(config, consentData) { | ||
logInfo('Creating UID2'); | ||
let value = storage.getCookie(ADVERTISING_COOKIE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this not work with local storage? or is storage.getCookie smart enough to check there if config says this should be in local storage? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UID 2.0 submodule relies on cookie '__uid2_advertising_token' which is set by UID 2.0 SSO |
||
logInfo('The advestising token: ' + value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spelling |
||
return {id: value} | ||
}, | ||
|
||
/** | ||
* performs actions even if the id exists and returns a value | ||
* @param config | ||
* @param consentData | ||
* @param storedId | ||
* @returns {{callback: *}} | ||
*/ | ||
extendId(config, consentData, storedId) { | ||
logInfo('Existing id ' + storedId); | ||
let value = storage.getCookie(ADVERTISING_COOKIE); | ||
return {id: value} | ||
} | ||
}; | ||
|
||
// Register submodule for userId | ||
submodule('userId', uid2IdSubmodule); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
## UID 2.0 User ID Submodule | ||
|
||
UID 2.0 ID Module. | ||
|
||
### Prebid Params | ||
|
||
Individual params may be set for the UID 2.0 Submodule. At least one identifier must be set in the params. | ||
|
||
``` | ||
pbjs.setConfig({ | ||
usersync: { | ||
userIds: [{ | ||
name: 'uid20', | ||
storage: { | ||
name: 'uid20id', | ||
type: 'html5' | ||
} | ||
}] | ||
} | ||
}); | ||
``` | ||
## Parameter Descriptions for the `usersync` Configuration Section | ||
The below parameters apply only to the UID 2.0 User ID Module integration. | ||
|
||
| Param under usersync.userIds[] | Scope | Type | Description | Example | | ||
| --- | --- | --- | --- | --- | | ||
| name | Required | String | ID value for the UID20 module - `"uid20"` | `"uid20"` | | ||
| storage | Required | Object | The publisher must specify the local storage in which to store the results of the call to get the user ID. This can be either cookie or HTML5 storage. | | | ||
| storage.type | Required | String | This is where the results of the user ID will be stored. The recommended method is `localStorage` by specifying `html5`. | `"html5"` | | ||
| storage.name | Required | String | The name of the cookie or html5 local storage where the user ID will be stored. | `"uid20id"` | | ||
| storage.expires | Optional | Integer | How long (in days) the user ID information will be stored. | `365` | | ||
| value | Optional | Object | Used only if the page has a separate mechanism for storing the Halo ID. The value is an object containing the values to be sent to the adapters. In this scenario, no URL is called and nothing is added to local storage | `{"uid20": { "id": "eb33b0cb-8d35-4722-b9c0-1a31d4064888"}}` | |
Uh oh!
There was an error while loading. Please reload this page.