Skip to content

Commit

Permalink
Weborama RTD Module : start Bidder specific handling removal (#10005)
Browse files Browse the repository at this point in the history
* remove specific code to pubmatic

* remove specific code to smartadserver bidder

* update unit tests

* remove rubicon specific code

* refactor method

* refactor this.#setBidderOrtb2

* fix lint issue

* add ortb2 user.keywords on appnexs

* try fix appnexus case

* small refactor inspired on #9952

* try fix appnexus

* Revert "try fix appnexus"

This reverts commit db1fc08.

* Revert "small refactor inspired on #9952"

This reverts commit 3959260.

* Revert "try fix appnexus case"

This reverts commit 919540a.

* Revert "add ortb2 user.keywords on appnexs"

This reverts commit e2c5747.
  • Loading branch information
peczenyj authored Jun 8, 2023
1 parent cfe7b5c commit d3b7900
Show file tree
Hide file tree
Showing 3 changed files with 360 additions and 304 deletions.
120 changes: 25 additions & 95 deletions modules/weboramaRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,19 +689,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') {
this.#handleAppnexusBid(reqBidsConfigObj, bid, profile);
}
}

Expand All @@ -719,92 +708,19 @@ class WeboramaRtdProvider {
/** handle appnexus/xandr bid
* @method
* @private
* @param {Object} reqBidsConfigObj
* @param {Object} reqBidsConfigObj.ortb2Fragments
* @param {Object} reqBidsConfigObj.ortb2Fragments.bidder
* @param {Object} bid
* @param {Object} bid.params
* @param {Object} bid.params.keyword
* @param {Object} bid.parameters
* @param {Profile} profile
* @returns {void}
*/
// eslint-disable-next-line no-dupe-class-members
#handleAppnexusBid(bid, profile) {
#handleAppnexusBid(reqBidsConfigObj, 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
* @method
* @private
* @param {Object} bid
* @param {Object} bid.params
* @param {string} bid.params.target
* @param {Profile} profile
* @returns {void}
*/
// eslint-disable-next-line no-dupe-class-members
#handleSmartadserverBid(bid, profile) {
const sep = ';';

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);
}

/** handle rubicon bid
* @method
* @private
* @param {Object} bid
* @param {string} bid.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`);
}
// this.#setBidderOrtb2(reqBidsConfigObj.ortb2Fragments?.bidder, bid.bidder, base, profile);
}

/** handle generic bid via ortb2 arbitrary data
Expand All @@ -823,14 +739,28 @@ class WeboramaRtdProvider {
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`;
const path = `${section}.ext.data`;

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

/**
* set bidder ortb2 data
* @method
* @private
* @param {Object} bidderOrtb2Fragments
* @param {string} bidder
* @param {string} path
* @param {Profile} profile
* @returns {void}
*/
// eslint-disable-next-line no-dupe-class-members
#setBidderOrtb2(bidderOrtb2Fragments, bidder, path, profile) {
const base = `${bidder}.${path}`;
this.#assignProfileToObject(bidderOrtb2Fragments, base, profile)
}
/**
* assign profile to object
* @method
Expand Down
8 changes: 4 additions & 4 deletions modules/weboramaRtdProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -575,12 +575,9 @@ pbjs.que.push(function () {
### Supported Bidders
We currently support the following bidder adapters:
We currently support the following bidder adapters with dedicated code:
* SmartADServer SSP
* PubMatic SSP
* AppNexus SSP
* Rubicon 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).
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

0 comments on commit d3b7900

Please sign in to comment.