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

Weborama RTD Module : start Bidder specific handling removal #10005

Merged
merged 15 commits into from
Jun 8, 2023
142 changes: 40 additions & 102 deletions modules/weboramaRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ const WEBO_USER_DATA_SOURCE_LABEL = 'wam';
const SFBX_LITE_DATA_SOURCE_LABEL = 'lite';
/** @type {number} */
const GVLID = 284;
/** @type {string} */
const APPNEXUS_BIDDER = 'appnexus';

export const storage = getStorageManager({
moduleType: MODULE_TYPE_RTD,
Expand Down Expand Up @@ -681,6 +683,12 @@ class WeboramaRtdProvider {
*/
// eslint-disable-next-line no-dupe-class-members
#handleBid(reqBidsConfigObj, bid, profile, metadata) {
if (!isBoolean(metadata.user)) {
logMessage(`SKIP unsupported bidder '${bid.bidder}', data from '${metadata.source}' is not defined as user or site-centric`);

return
}

this.#handleBidViaORTB2(reqBidsConfigObj, bid.bidder, profile, metadata);

/** @type {Object.<string,string>} */
Expand All @@ -689,19 +697,8 @@ class WeboramaRtdProvider {
/** @type {string} */
const bidder = bidderAliasRegistry[bid.bidder] || bid.bidder;

switch (bidder) {
case 'appnexus':
this.#handleAppnexusBid(bid, profile);
break;
case 'pubmatic':
this.#handlePubmaticBid(bid, profile);
break;
case 'smartadserver':
this.#handleSmartadserverBid(bid, profile);
break;
case 'rubicon':
this.#handleRubiconBid(bid, profile, metadata);
break;
if (bidder === APPNEXUS_BIDDER) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To summarize what I think is missing:

  • appnexus (and clones) now parse keywords as key=value pairs. so this should serialize objects like { webo_ctx: ["A", "B"], webo_ds: ["C", "D"]} down to a single string such as webo_ctx=A,webo_ctx=B,webo_ds=C,webo_ds=D.
  • because appnexus has clones, this should ideally not check for appnexus specifically. You could take the list of bidders to set keywords for as config, or you could even set these keywords on all the bidders you want to set segments for (non-appnexus bidders will probably have no use for them but they shouldn't hurt).

this.#handleAppnexusBidder(reqBidsConfigObj, bid, profile, metadata);
}
}

Expand All @@ -716,121 +713,62 @@ class WeboramaRtdProvider {
return [deepClone(ph.data), deepClone(ph.metadata)];
}

/** handle appnexus/xandr bid
* @method
* @private
* @param {Object} bid
* @param {Object} bid.params
* @param {Object} bid.params.keyword
* @param {Profile} profile
* @returns {void}
*/
// eslint-disable-next-line no-dupe-class-members
#handleAppnexusBid(bid, profile) {
const base = 'params.keywords';
this.#assignProfileToObject(bid, base, profile);
}

/** handle pubmatic bid
* @method
* @private
* @param {Object} bid
* @param {Object} bid.params
* @param {string} bid.params.dctr
* @param {Profile} profile
* @returns {void}
*/
// eslint-disable-next-line no-dupe-class-members
#handlePubmaticBid(bid, profile) {
const sep = '|';
const subsep = ',';

bid.params ||= {};

const data = bid.params.dctr || '';
const target = new Set(data.split(sep).filter((x) => x.length > 0));

Object.entries(profile).forEach(([key, values]) => {
const value = values.join(subsep);
const keyword = `${key}=${value}`;
target.add(keyword);
});

bid.params.dctr = Array.from(target).join(sep);
}

/** handle smartadserver bid
/** handle data to appnexus/xandr bidder.
* @method
* @private
* @param {Object} reqBidsConfigObj
* @param {Object} reqBidsConfigObj.ortb2Fragments
* @param {Object} reqBidsConfigObj.ortb2Fragments.bidder
* @param {Object} bid
* @param {Object} bid.params
* @param {string} bid.params.target
* @param {string} bid.bidder
* @param {Object} bid.parameters
* @param {Profile} profile
* @param {dataCallbackMetadata} metadata
* @returns {void}
*/
// eslint-disable-next-line no-dupe-class-members
#handleSmartadserverBid(bid, profile) {
const sep = ';';
#handleAppnexusBidder(reqBidsConfigObj, bid, profile, metadata) {
const bidder = bid.bidder;
const section = metadata.user ? 'user' : 'site';
const path = `${section}.keywords`;

bid.params ||= {};

const data = bid.params.target || '';
const target = new Set(data.split(sep).filter((x) => x.length > 0));

Object.entries(profile).forEach(([key, values]) => {
values.forEach(value => {
const keyword = `${key}=${value}`;
target.add(keyword);
})
});

bid.params.target = Array.from(target).join(sep);
this.#setBidderOrtb2(reqBidsConfigObj.ortb2Fragments?.bidder, bidder, path, profile);
}

/** handle rubicon bid
/** handle generic bid via ortb2 arbitrary data
* @method
* @private
* @param {Object} bid
* @param {string} bid.bidder
* @param {Object} reqBidsConfigObj
* @param {Object} reqBidsConfigObj.ortb2Fragments
* @param {Object} reqBidsConfigObj.ortb2Fragments.bidder
* @param {string} bidder
* @param {Profile} profile
* @param {dataCallbackMetadata} metadata
* @returns {void}
*/
// eslint-disable-next-line no-dupe-class-members
#handleRubiconBid(bid, profile, metadata) {
if (isBoolean(metadata.user)) {
const section = metadata.user ? 'visitor' : 'inventory';
const base = `params.${section}`;
this.#assignProfileToObject(bid, base, profile);
} else {
logMessage(`SKIP bidder '${bid.bidder}', data from '${metadata.source}' is not defined as user or site-centric`);
}
}
#handleBidViaORTB2(reqBidsConfigObj, bidder, profile, metadata) {
logMessage(`bidder '${bidder}' is not directly supported, trying set data via bidder ortb2 fpd`);
const section = metadata.user ? 'user' : 'site';
const path = `${section}.ext.data`;

/** handle generic bid via ortb2 arbitrary data
this.#setBidderOrtb2(reqBidsConfigObj.ortb2Fragments?.bidder, bidder, path, profile);
}
/**
* set bidder ortb2 data
* @method
* @private
* @param {Object} reqBidsConfigObj
* @param {Object} reqBidsConfigObj.ortb2Fragments
* @param {Object} reqBidsConfigObj.ortb2Fragments.bidder
* @param {Object} bidderOrtb2Fragments
* @param {string} bidder
* @param {string} path
* @param {Profile} profile
* @param {dataCallbackMetadata} metadata
* @returns {void}
*/
// eslint-disable-next-line no-dupe-class-members
#handleBidViaORTB2(reqBidsConfigObj, bidder, profile, metadata) {
if (isBoolean(metadata.user)) {
logMessage(`bidder '${bidder}' is not directly supported, trying set data via bidder ortb2 fpd`);
const section = metadata.user ? 'user' : 'site';
const base = `${bidder}.${section}.ext.data`;

this.#assignProfileToObject(reqBidsConfigObj.ortb2Fragments?.bidder, base, profile);
} else {
logMessage(`SKIP unsupported bidder '${bidder}', data from '${metadata.source}' is not defined as user or site-centric`);
}
#setBidderOrtb2(bidderOrtb2Fragments, bidder, path, profile) {
const base = `${bidder}.${path}`;
this.#assignProfileToObject(bidderOrtb2Fragments, base, profile)
}

/**
* assign profile to object
* @method
Expand Down
12 changes: 6 additions & 6 deletions modules/weboramaRtdProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,11 @@ pbjs.que.push(function () {

### Supported Bidders

We currently support the following bidder adapters:
We 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).

* SmartADServer SSP
* PubMatic SSP
* AppNexus SSP
* Rubicon SSP
For `Appnexus SSP` we also set the user data into `users.keywords` fragment.

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).
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
Expand All @@ -605,8 +602,11 @@ We also set the bidder (and global, if no specific bidders are set on `sendToBid
* Opt Out Advertising
* Ozone Project
* Proxistore
* PubMatic SSP
* Rise
* Rubicon SSP
* Smaato
* Smart ADServer SSP
* Sonobi
* TheMediaGrid
* TripleLift
Expand Down
Loading