Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepthiNeeladri committed May 26, 2024
2 parents c687e6c + f6a214b commit 4bb3230
Show file tree
Hide file tree
Showing 62 changed files with 2,218 additions and 695 deletions.
39 changes: 30 additions & 9 deletions modules/1plusXRtdProvider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { submodule } from '../src/hook.js';
import { MODULE_TYPE_RTD } from '../src/activities/modules.js';
import { ajax } from '../src/ajax.js';
import { getStorageManager, STORAGE_TYPE_COOKIES, STORAGE_TYPE_LOCALSTORAGE } from '../src/storageManager.js';
import {
logMessage, logError,
deepAccess, deepSetValue, mergeDeep,
Expand All @@ -13,6 +15,9 @@ const ORTB2_NAME = '1plusX.com'
const PAPI_VERSION = 'v1.0';
const LOG_PREFIX = '[1plusX RTD Module]: ';
const OPE_FPID = 'ope_fpid'

export const fpidStorage = getStorageManager({ moduleType: MODULE_TYPE_RTD, moduleName: MODULE_NAME });

export const segtaxes = {
// cf. https://github.com/InteractiveAdvertisingBureau/openrtb/pull/108
AUDIENCE: 526,
Expand Down Expand Up @@ -53,7 +58,19 @@ export const extractConfig = (moduleConfig, reqBidsConfigObj) => {
throw new Error('No bidRequestConfig bidder found in moduleConfig bidders');
}

return { customerId, timeout, bidders };
const fpidStorageType = deepAccess(moduleConfig, 'params.fpidStorageType',
STORAGE_TYPE_LOCALSTORAGE)

if (
fpidStorageType !== STORAGE_TYPE_COOKIES &&
fpidStorageType !== STORAGE_TYPE_LOCALSTORAGE
) {
throw new Error(
`fpidStorageType must be ${STORAGE_TYPE_LOCALSTORAGE} or ${STORAGE_TYPE_COOKIES}`
)
}

return { customerId, timeout, bidders, fpidStorageType };
}

/**
Expand Down Expand Up @@ -81,16 +98,20 @@ export const extractConsent = ({ gdpr }) => {
}

/**
* Extracts the OPE first party id field from local storage
* Extracts the OPE first party id field
* @param {string} fpidStorageType indicates where fpid should be read from
* @returns fpid string if found, else null
*/
export const extractFpid = () => {
export const extractFpid = (fpidStorageType) => {
try {
const fpid = window.localStorage.getItem(OPE_FPID);
if (fpid) {
return fpid;
switch (fpidStorageType) {
case STORAGE_TYPE_COOKIES: return fpidStorage.getCookie(OPE_FPID)
case STORAGE_TYPE_LOCALSTORAGE: return fpidStorage.getDataFromLocalStorage(OPE_FPID)
default: {
logError(`Got unknown fpidStorageType ${fpidStorageType}. Aborting...`)
return null
}
}
return null;
} catch (error) {
return null;
}
Expand Down Expand Up @@ -231,10 +252,10 @@ const init = (config, userConsent) => {
const getBidRequestData = (reqBidsConfigObj, callback, moduleConfig, userConsent) => {
try {
// Get the required config
const { customerId, bidders } = extractConfig(moduleConfig, reqBidsConfigObj);
const { customerId, bidders, fpidStorageType } = extractConfig(moduleConfig, reqBidsConfigObj);
const { ortb2Fragments: { bidder: biddersOrtb2 } } = reqBidsConfigObj;
// Get PAPI URL
const papiUrl = getPapiUrl(customerId, extractConsent(userConsent) || {}, extractFpid())
const papiUrl = getPapiUrl(customerId, extractConsent(userConsent) || {}, extractFpid(fpidStorageType))
// Call PAPI
getTargetingDataFromPapi(papiUrl)
.then((papiResponse) => {
Expand Down
19 changes: 10 additions & 9 deletions modules/1plusXRtdProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ pbjs.setConfig({

### Parameters

| Name | Type | Description | Default |
| :---------------- | :------------ | :--------------------------------------------------------------- |:----------------- |
| name | String | Real time data module name | Always '1plusX' |
| waitForIt | Boolean | Should be `true` if there's an `auctionDelay` defined (optional) | `false` |
| params | Object | | |
| params.customerId | String | Your 1plusX customer id | |
| params.bidders | Array<string> | List of bidders for which you would like data to be set | |
| params.timeout | Integer | timeout (ms) | 1000ms |

| Name | Type | Description | Default |
| :------------------------ | :------------ | :--------------------------------------------------------------- |:----------------- |
| name | String | Real time data module name | Always '1plusX' |
| waitForIt | Boolean | Should be `true` if there's an `auctionDelay` defined (optional) | `false` |
| params | Object | | |
| params.customerId | String | Your 1plusX customer id | |
| params.bidders | Array<string> | List of bidders for which you would like data to be set | |
| params.timeout | Integer | timeout (ms) | 1000ms |
| params.fpidStorageType | String | Specifies where the 1plusX fpid should be read from. Either | html5 |
| | | "html5" (local storage) or "cookie" (first party cookie) | |
## Testing

To view an example of how the 1plusX RTD module works :
Expand Down
2 changes: 1 addition & 1 deletion modules/51DegreesRtdProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ In order to use the module please first obtain a Resource Key using the [Configu
* ScreenInchesWidth
* PixelRatio (optional)

PixelRatio is desirable, but it's a paid property requiring a paid license. Also free API service is limited to 500,000 requests per month - consider picking a [51Degrees pricing plan](https://51degrees.com/pricing) that fits your needs.
PixelRatio is desirable, but it's a paid property requiring a paid license. Free API service is limited. Please check [51Degrees pricing](https://51degrees.com/pricing) to choose a plan that suits your needs.

#### User Agent Client Hint (UA-CH) Permissions

Expand Down
Loading

0 comments on commit 4bb3230

Please sign in to comment.