-
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
Merged
Merged
UID 2.0 Userid submodule #6443
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b05007b
UID 2.0 User id submodule
ec62033
UID 2.0 User id submodule
46a5615
UID 2.0 User id submodule
0e19eaa
UID 2.0 User id submodule
5c99380
Resolving merge conflicts and review comments
b0a23ca
merge master
973038a
Updating documentation
aae9f52
Renaming module
5440b27
Fixing review comments
84ff68d
Fixing review comments
0e775ed
Fixing review comments
8d9b40f
Fixing review comments
dc96f6e
Fixing review comments
fa0d81d
Updating source uid2.com to uidapi.com
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
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 | ||
} | ||
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. what's the purpose of setting this |
||
result.uid20 = bidIds; | ||
logInfo('Decoded value ' + JSON.stringify(result)); | ||
return result; | ||
} | ||
return undefined; | ||
} | ||
|
||
/** @type {Submodule} */ | ||
export const uid20IdSubmodule = { | ||
/** | ||
* 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 {{uid20:{ id: string }} or undefined if value doesn't exists | ||
*/ | ||
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} | ||
patmmccann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
getId(config, consentData) { | ||
logInfo('Creating UID2'); | ||
let value = storage.getCookie(ADVERTISING_COOKIE); | ||
patmmccann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
logInfo('The advertising token: ' + value); | ||
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} | ||
smenzer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}; | ||
|
||
// Register submodule for userId | ||
submodule('userId', uid20IdSubmodule); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: { | ||
patmmccann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
userIds: [{ | ||
name: 'uid20', | ||
storage: { | ||
name: 'uid20id', | ||
type: 'html5' | ||
smenzer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}] | ||
} | ||
}); | ||
``` | ||
## 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 | | ||
patmmccann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| --- | --- | --- | --- | --- | | ||
| 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` | | ||
smenzer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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"}}` | | ||
smenzer marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.