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.
- Loading branch information
Showing
85 changed files
with
3,848 additions
and
839 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
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 [[email protected]]([email protected]). | ||
|
||
### 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
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.