forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
33Across user id sub-module: initial release (prebid#8335)
* wip * Rename lexicon param url to apiUrl and remove envelope param * Rename gvlid spec title - lexicon id system * add missing semicolon * apply code review feedback lexicon id system * Unit test coverage for the callback execution - lexicon id system * Add lexicon to user id integration example * Add lexicon is system markdown documentation * Update modules/lexiconIdSystem.js add colon to error message Co-authored-by: macinjosh32 <macinjosh32@users.noreply.github.com> * Send privacy strings in the lexicon id system request * apply code review feedback markdown lexicon documentation * Rename files with references to lexicon * rename 33across ID from lexicon to 33acrossId * fix failing unit tests incorrect URL and error message * Add 33acrossId reference in submodules & documentation Co-authored-by: macinjosh32 <macinjosh32@users.noreply.github.com>
- Loading branch information
1 parent
f0d09dc
commit 3a73b00
Showing
9 changed files
with
650 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"userId": [ | ||
"33acrossIdSystem", | ||
"admixerIdSystem", | ||
"adtelligentIdSystem", | ||
"akamaiDAPIdSystem", | ||
|
This file contains 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,115 @@ | ||
/** | ||
* This module adds 33acrossId to the User ID module | ||
* The {@link module:modules/userId} module is required | ||
* @module modules/33acrossIdSystem | ||
* @requires module:modules/userId | ||
*/ | ||
|
||
import { logMessage, logError } from '../src/utils.js'; | ||
import { ajaxBuilder } from '../src/ajax.js'; | ||
import { submodule } from '../src/hook.js'; | ||
import { uspDataHandler } from '../src/adapterManager.js'; | ||
|
||
const MODULE_NAME = '33acrossId'; | ||
const API_URL = 'https://lexicon.33across.com/v1/envelope'; | ||
const AJAX_TIMEOUT = 10000; | ||
|
||
function getEnvelope(response) { | ||
if (!response.succeeded) { | ||
logError(`${MODULE_NAME}: Unsuccessful response`); | ||
|
||
return; | ||
} | ||
|
||
if (!response.data.envelope) { | ||
logMessage(`${MODULE_NAME}: No envelope was received`); | ||
|
||
return; | ||
} | ||
|
||
return response.data.envelope; | ||
} | ||
|
||
function calculateQueryStringParams(pid, gdprConsentData) { | ||
const uspString = uspDataHandler.getConsentData(); | ||
const gdprApplies = Boolean(gdprConsentData?.gdprApplies); | ||
const params = { | ||
pid, | ||
gdpr: Number(gdprApplies), | ||
}; | ||
|
||
if (uspString) { | ||
params.us_privacy = uspString; | ||
} | ||
|
||
if (gdprApplies) { | ||
params.gdpr_consent = gdprConsentData.consentString || ''; | ||
} | ||
|
||
return params; | ||
} | ||
|
||
/** @type {Submodule} */ | ||
export const thirthyThreeAcrossIdSubmodule = { | ||
/** | ||
* used to link submodule with config | ||
* @type {string} | ||
*/ | ||
name: MODULE_NAME, | ||
|
||
gvlid: 58, | ||
|
||
/** | ||
* decode the stored id value for passing to bid requests | ||
* @function | ||
* @param {string} id | ||
* @returns {{'33acrossId':{ envelope: string}}} | ||
*/ | ||
decode(id) { | ||
return { | ||
[MODULE_NAME]: { | ||
envelope: id | ||
} | ||
}; | ||
}, | ||
|
||
/** | ||
* performs action to obtain id and return a value in the callback's response argument | ||
* @function | ||
* @param {SubmoduleConfig} [config] | ||
* @returns {IdResponse|undefined} | ||
*/ | ||
getId({ params = { } }, gdprConsentData) { | ||
if (typeof params.pid !== 'string') { | ||
logError(`${MODULE_NAME}: Submodule requires a partner ID to be defined`); | ||
|
||
return; | ||
} | ||
|
||
const { pid, apiUrl = API_URL } = params; | ||
|
||
return { | ||
callback(cb) { | ||
ajaxBuilder(AJAX_TIMEOUT)(apiUrl, { | ||
success(response) { | ||
let envelope; | ||
|
||
try { | ||
envelope = getEnvelope(JSON.parse(response)) | ||
} catch (err) { | ||
logError(`${MODULE_NAME}: ID reading error:`, err); | ||
} | ||
cb(envelope); | ||
}, | ||
error(err) { | ||
logError(`${MODULE_NAME}: ID error response`, err); | ||
|
||
cb(); | ||
} | ||
}, calculateQueryStringParams(pid, gdprConsentData), { method: 'GET', withCredentials: true }); | ||
} | ||
}; | ||
} | ||
}; | ||
|
||
submodule('userId', thirthyThreeAcrossIdSubmodule); |
This file contains 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,53 @@ | ||
# 33ACROSS ID | ||
|
||
For help adding this submodule, please contact [PrebidUIM@33across.com](PrebidUIM@33across.com). | ||
|
||
### Prebid Configuration | ||
|
||
You can configure this submodule in your `userSync.userIds[]` configuration: | ||
|
||
```javascript | ||
pbjs.setConfig({ | ||
userSync: { | ||
userIds: [ | ||
{ | ||
name: "33acrossId", | ||
storage: { | ||
name: "33acrossId", | ||
type: "html5", | ||
expires: 90, | ||
refreshInSeconds: 8*3600 | ||
}, | ||
params: { | ||
pid: "0010b00002GYU4eBAH", | ||
}, | ||
}, | ||
], | ||
}, | ||
}); | ||
``` | ||
|
||
| Parameters under `userSync.userIds[]` | Scope | Type | Description | Example | | ||
| ---| --- | --- | --- | --- | | ||
| name | Required | String | Name for the 33Across ID submodule | `"33acrossId"` | | | ||
| storage | Required | Object | Configures how to cache User IDs locally in the browser | See [storage settings](#storage-settings) | | ||
| params | Required | Object | Parameters for 33Across ID submodule | See [params](#params) | | ||
|
||
### Storage Settings | ||
|
||
The following settings are available for the `storage` property in the `userSync.userIds[]` object: | ||
|
||
| Param name | Scope | Type | Description | Example | | ||
| --- | --- | --- | --- | --- | | ||
| name | Required | String| Name of the cookie or HTML5 local storage where the user ID will be stored | `"33acrossId"` | | ||
| type | Required | String | `"html5"` (preferred) or `"cookie"` | `"html5"` | | ||
| expires | Strongly Recommended | Number | How long (in days) the user ID information will be stored. 33Across recommends `90`. | `90` | | ||
| refreshInSeconds | Strongly Recommended | Number | The interval (in seconds) for refreshing the user ID. 33Across recommends no more than 8 hours between refreshes. | `8*3600` | | ||
|
||
### Params | ||
|
||
The following settings are available in the `params` property in `userSync.userIds[]` object: | ||
|
||
| Param name | Scope | Type | Description | Example | | ||
| --- | --- | --- | --- | --- | | ||
| pid | Required | String | Partner ID provided by 33Across | `"0010b00002GYU4eBAH"` | |
This file contains 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 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 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.