Skip to content
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

DRAFT [Weborama RTD Submodule] Fix appnexus implementation #10113

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 22 additions & 27 deletions modules/weboramaRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ import {
import {
getStorageManager
} from '../src/storageManager.js';
import adapterManager from '../src/adapterManager.js';
import {MODULE_TYPE_RTD} from '../src/activities/modules.js';

/** @type {string} */
Expand Down Expand Up @@ -304,24 +303,25 @@ class WeboramaRtdProvider {
*/
#initSubSection(moduleParams, subSection, ...requiredFields) {
/** @type {CommonConf} */
const weboSectionConf = moduleParams[subSection] || { enabled: false };
const subSectionConf = moduleParams[subSection] || { enabled: false };

if (weboSectionConf.enabled === false) {
if (subSectionConf.enabled === false) {
delete moduleParams[subSection];

return false;
}

try {
this.#normalizeConf(moduleParams, weboSectionConf);
this.#normalizeConf(moduleParams, subSectionConf);

requiredFields.forEach(field => {
if (!(field in weboSectionConf)) {
if (!(field in subSectionConf)) {
throw `missing required field '${field}''`;
}
});
} catch (e) {
logError(`unable to initialize: error on ${subSection} configuration:`, e);

return false;
}

Expand Down Expand Up @@ -667,6 +667,7 @@ class WeboramaRtdProvider {
onData: dataConf.onData,
};
}

/** handle individual bid
* @method
* @private
Expand All @@ -680,18 +681,8 @@ class WeboramaRtdProvider {
* @returns {void}
*/
// eslint-disable-next-line no-dupe-class-members
#handleBid(reqBidsConfigObj, bid, profile, metadata) {
#handleBid(reqBidsConfigObj, bid, profile, metadata, extraConf) {
this.#handleBidViaORTB2(reqBidsConfigObj, bid.bidder, profile, metadata);

/** @type {Object.<string,string>} */
const bidderAliasRegistry = adapterManager.aliasRegistry || {};

/** @type {string} */
const bidder = bidderAliasRegistry[bid.bidder] || bid.bidder;

if (bidder == 'appnexus') {
this.#handleAppnexusBid(reqBidsConfigObj, bid, profile);
}
}

/** function that handles bid request data
Expand All @@ -705,22 +696,26 @@ class WeboramaRtdProvider {
return [deepClone(ph.data), deepClone(ph.metadata)];
}

/** handle appnexus/xandr bid
/** set ortb2 data using path
* @method
* @private
* @param {Object} reqBidsConfigObj
* @param {Object} reqBidsConfigObj.ortb2Fragments
* @param {Object} reqBidsConfigObj.ortb2Fragments.bidder
* @param {Object} bid
* @param {Object} bid.parameters
* @param {Profile} profile
* @param {Object} ortb2Fragments
* @param {Object} ortb2Fragments.bidder
* @param {string} bidder
* @param {string} path
* @param {any} data
* @returns {void}
*/
// eslint-disable-next-line no-dupe-class-members
#handleAppnexusBid(reqBidsConfigObj, bid, profile) {
const base = 'params.keywords';
this.#assignProfileToObject(bid, base, profile);
// this.#setBidderOrtb2(reqBidsConfigObj.ortb2Fragments?.bidder, bid.bidder, base, profile);
#setOrtb2(ortb2Fragments, bidder, path, data) {
let ortb2Conf = {};
deepSetValue(ortb2Conf, path, data);

if (bidder) {
ortb2Conf = {[bidder]: ortb2Conf};
}

mergeDeep(ortb2Fragments, ortb2Conf);
}

/** handle generic bid via ortb2 arbitrary data
Expand Down
58 changes: 18 additions & 40 deletions modules/weboramaRtdProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Weborama provides a Real-Time Data Submodule for `Prebid.js`, allowing to easy i

* LiTE by SFBX® (Local inApp Trust Engine) provides “Zero Party Data” given by users, stored and calculated only on the user’s device. Through a unique cohorting system, it enables better monetization in a consent/consentless and identity-less mode.

Contact prebid-support@weborama.com for more information.
Contact [prebid-support@weborama.com] for more information.

### Publisher Usage

Expand Down Expand Up @@ -79,7 +79,7 @@ pbjs.setConfig({

Each module can perform two actions:

* set targeting on [GPT](https://docs.prebid.org/dev-docs/publisher-api-reference/setTargetingForGPTAsync.html) / [AST](https://docs.prebid.org/dev-docs/publisher-api-reference/setTargetingForAst.html]) via `prebid.js`
* set targeting on [GPT](https://docs.prebid.org/dev-docs/publisher-api-reference/setTargetingForGPTAsync.html) / [AST](https://docs.prebid.org/dev-docs/publisher-api-reference/setTargetingForAst.html) via `prebid.js`

* send data to other `prebid.js` bidder modules (check the complete list at the end of this page)

Expand Down Expand Up @@ -156,9 +156,9 @@ This property support the following types
| Type | Description | Example | Notes |
| :------------ | :------------ | :------------ |:------------ |
| Boolean|If true, set prebid targeting for all adunits, or not in case of false| `true` | default value |
| String|Will set prebid targeting only for one adunit | `'adUnitCode1'` | |
| Array of Strings|Will set prebid targeting only for some adunits| `['adUnitCode1','adUnitCode2']` | |
| Callback |Will be executed for each adunit, expects return a true value to set prebid targeting or not| `function(adUnitCode){return adUnitCode == 'adUnitCode';}` | |
| String|Will set prebid targeting only for one adunit | `'adUnitCode1'` | **DEPRECATED** |
| Array of Strings|Will set prebid targeting only for some adunits| `['adUnitCode1','adUnitCode2']` | **DEPRECATED** |
| Callback |Will be executed for each adunit, expects return a true value to set prebid targeting or not| `function(adUnitCode){return adUnitCode == 'adUnitCode';}` | **DEPRECATED** |

The complete callback function signature is:

Expand All @@ -168,26 +168,7 @@ setPrebidTargeting: function(adUnitCode, data, metadata){
}
```

This callback will be executed with the adUnitCode, profile and a metadata with the following fields

| Name |Type | Description | Notes |
| :------------ | :------------ | :------------ |:------------ |
| user | Boolean | If true, it contains user-centric data | |
| source | String | Represent the source of data | can be `contextual`, `wam` or `lite` |
| isDefault | Boolean | If true, it contains the default profile defined in the configuration | |

It is possible customize the targeting based on the parameters:

```javascript
setPrebidTargeting: function(adUnitCode, data, metadata){
// check metadata.source can be omitted if defined in params.weboUserDataConf
if (adUnitCode == 'adUnitCode1' && metadata.source == 'wam'){
data['foo']=['bar']; // add this section only for adUnitCode1
delete data['other']; // remove this section
}
return true;
}
```
Since `Prebid.js` version 8, we use First Party Data Support to propagate data to differente SSPs. We will deprecate the support to other formats than Boolean.

##### Property sendToBidders supported types

Expand All @@ -198,8 +179,8 @@ This property support the following types
| Boolean|If true, send data to all bidders, or not in case of false| `true` | default value |
| String|Will send data to only one bidder | `'appnexus'` | |
| Array of Strings|Will send data to only some bidders | `['appnexus','pubmatic']` | |
| Object |Will send data to only some bidders and some ad units | `{appnexus: true, pubmatic:['adUnitCode1']}` | |
| Callback |Will be executed for each adunit, expects return a true value to set prebid targeting or not| `function(bid, adUnitCode){return bid.bidder == 'appnexus' && adUnitCode == 'adUnitCode';}` | |
| Object |Will send data to only some bidders and some ad units | `{appnexus: true, pubmatic:['adUnitCode1']}` | **DEPRECATED** |
| Callback |Will be executed for each adunit, expects return a true value to set prebid targeting or not| `function(bid, adUnitCode){return bid.bidder == 'appnexus' && adUnitCode == 'adUnitCode';}` | the parameter `adUnitCode` can be consider **DEPRECATED** |

A better look on the `Object` type

Expand All @@ -218,7 +199,7 @@ sendToBidders: function(bid, adUnitCode, data, metadata){
}
```

This callback will be executed with the bid object (contains a field `bidder` with name), adUnitCode, profile and a metadata with the following fields
This callback will be executed with the bid object (contains a field `bidder` with name), adUnitCode (**deprecated**), profile and a metadata with the following fields

| Name |Type | Description | Notes |
| :------------ | :------------ | :------------ |:------------ |
Expand All @@ -230,14 +211,16 @@ It is possible customize the targeting based on the parameters:

```javascript
sendToBidders: function(bid, adUnitCode, data, metadata){
if (bid.bidder == 'appnexus' && adUnitCode == 'adUnitCode1'){
if (bid.bidder == 'appnexus'){
data['foo']=['bar']; // add this section only for appnexus + adUnitCode1
delete data['other']; // remove this section
}
return true;
}
```

Since `Prebid.js` version 8, we use First Party Data Support to propagate data to differente SSPs. We will deprecate the support to formats that thandle with `adUnitCode` at some point.

To be possible customize the way we send data to bidders via this callback:

```javascript
Expand Down Expand Up @@ -537,10 +520,10 @@ pbjs.que.push(function () {
},
weboUserDataConf: {
accountId: 12345, // recommended
setPrebidTargeting: ['adUnitCode1',...], // set target only on certain adunits
setPrebidTargeting: true
sendToBidders: { // send to only some bidders and adunits
'appnexus': true, // all adunits for appnexus
'pubmatic': ['adUnitCode1',...] // some adunits for pubmatic
'appnexus': true, // enable appnexus
'pubmatic': false // explicit disable pubmatic
// other bidders will be ignored
},
defaultProfile: { // optional
Expand All @@ -552,11 +535,9 @@ pbjs.que.push(function () {
//, onData: function (data, ...) { ...}
},
sfbxLiteDataConf: {
setPrebidTargeting: function(adUnitCode){ // specify set target via callback
return adUnitCode == 'adUnitCode1';
},
setPrebidTargeting: true,
sendToBidders: function(bid, adUnitCode){ // specify sendToBidders via callback
return bid.bidder == 'appnexus' && adUnitCode == 'adUnitCode1';
return bid.bidder == 'appnexus';
}
defaultProfile: { // optional
lite_occupation: ['gérant', 'bénévole'],
Expand All @@ -575,12 +556,9 @@ pbjs.que.push(function () {

### Supported Bidders

We currently support the following bidder adapters with dedicated code:
We set the bidder ortb2 `site.ext.data` and `user.ext.data` sections (as arbitrary data). The following bidders may support it, to be sure, check the `First Party Data Support` on the feature list for the particular bidder from [here](https://docs.prebid.org/dev-docs/bidders). We may set the ortb2 global if no specific bidders are set on `sendToBidders` configuration.

* AppNexus SSP

We also set the bidder (and global, if no specific bidders are set on `sendToBidders`) ortb2 `site.ext.data` and `user.ext.data` sections (as arbitrary data). The following bidders may support it, to be sure, check the `First Party Data Support` on the feature list for the particular bidder from [here](https://docs.prebid.org/dev-docs/bidders).

* Adagio
* AdformOpenRTB
* AdKernel
Expand Down
Loading