From db1fc089081660753a0a15348508c6be7aba42ff Mon Sep 17 00:00:00 2001 From: Tiago Peczenyj Date: Mon, 5 Jun 2023 15:35:01 +0200 Subject: [PATCH] try fix appnexus --- modules/weboramaRtdProvider.js | 41 ++-- test/spec/modules/weboramaRtdProvider_spec.js | 184 +++++++++++++++--- 2 files changed, 175 insertions(+), 50 deletions(-) diff --git a/modules/weboramaRtdProvider.js b/modules/weboramaRtdProvider.js index 00f5ef41a09..8cd6067466c 100644 --- a/modules/weboramaRtdProvider.js +++ b/modules/weboramaRtdProvider.js @@ -153,7 +153,7 @@ const SFBX_LITE_DATA_SOURCE_LABEL = 'lite'; /** @type {number} */ const GVLID = 284; /** @type {string} */ -const LEGACY_SITE_KEYWORDS_BIDDERS = ['appnexus']; +const APPNEXUS_BIDDER = 'appnexus'; export const storage = getStorageManager({ moduleType: MODULE_TYPE_RTD, @@ -683,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.} */ @@ -691,8 +697,8 @@ class WeboramaRtdProvider { /** @type {string} */ const bidder = bidderAliasRegistry[bid.bidder] || bid.bidder; - if (LEGACY_SITE_KEYWORDS_BIDDERS.includes(bidder)) { - this.#handleSiteLegacyKeywordsBidders(reqBidsConfigObj, bid, profile, metadata); + if (bidder === APPNEXUS_BIDDER) { + this.#handleAppnexusBidder(reqBidsConfigObj, bid, profile, metadata); } } @@ -707,25 +713,26 @@ class WeboramaRtdProvider { return [deepClone(ph.data), deepClone(ph.metadata)]; } - /** handle site legacy keywords bidders like appnexus/xandr + /** handle data to appnexus/xandr bidder. * @method * @private * @param {Object} reqBidsConfigObj * @param {Object} reqBidsConfigObj.ortb2Fragments * @param {Object} reqBidsConfigObj.ortb2Fragments.bidder * @param {Object} bid + * @param {string} bid.bidder * @param {Object} bid.parameters * @param {Profile} profile * @param {dataCallbackMetadata} metadata * @returns {void} */ // eslint-disable-next-line no-dupe-class-members - #handleSiteLegacyKeywordsBidders(reqBidsConfigObj, bid, profile, metadata) { - if (metadata.user) { - this.#setBidderOrtb2(reqBidsConfigObj.ortb2Fragments?.bidder, bid.bidder, 'user.keywords', profile); - } else { - this.#assignProfileToObject(bid, 'params.keywords', profile); - } + #handleAppnexusBidder(reqBidsConfigObj, bid, profile, metadata) { + const bidder = bid.bidder; + const section = metadata.user ? 'user' : 'site'; + const path = `${section}.keywords`; + + this.#setBidderOrtb2(reqBidsConfigObj.ortb2Fragments?.bidder, bidder, path, profile); } /** handle generic bid via ortb2 arbitrary data @@ -741,15 +748,11 @@ class WeboramaRtdProvider { */ // 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 path = `${section}.ext.data`; - - 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`); - } + 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`; + + this.#setBidderOrtb2(reqBidsConfigObj.ortb2Fragments?.bidder, bidder, path, profile); } /** * set bidder ortb2 data diff --git a/test/spec/modules/weboramaRtdProvider_spec.js b/test/spec/modules/weboramaRtdProvider_spec.js index a645123d21b..da9990bd393 100644 --- a/test/spec/modules/weboramaRtdProvider_spec.js +++ b/test/spec/modules/weboramaRtdProvider_spec.js @@ -132,9 +132,21 @@ describe('weboramaRtdProvider', function() { expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); + expect(reqBidsConfigObj.adUnits[0].bids[2].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data, + }, + keywords: data, + } + }); + + return + } expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ site: { ext: { @@ -219,9 +231,21 @@ describe('weboramaRtdProvider', function() { expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); + expect(reqBidsConfigObj.adUnits[0].bids[2].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data, + }, + keywords: data, + } + }); + + return + } expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ site: { ext: { @@ -306,9 +330,21 @@ describe('weboramaRtdProvider', function() { expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); + expect(reqBidsConfigObj.adUnits[0].bids[2].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data, + }, + keywords: data, + } + }); + + return + } expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ site: { ext: { @@ -541,7 +577,7 @@ describe('weboramaRtdProvider', function() { expect(adUnit.bids.length).to.equal(5); expect(adUnit.bids[0].params).to.be.undefined; expect(adUnit.bids[1].params).to.be.undefined; - expect(adUnit.bids[2].params.keywords).to.deep.equal(data); + expect(adUnit.bids[2].params).to.be.undefined; expect(adUnit.bids[3].params).to.be.undefined; }); ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { @@ -549,8 +585,9 @@ describe('weboramaRtdProvider', function() { expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ site: { ext: { - data: data + data: data, }, + keywords: data, } }); @@ -671,7 +708,7 @@ describe('weboramaRtdProvider', function() { expect(adUnit.bids[4].ortb2).to.be.undefined; }); - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); + expect(reqBidsConfigObj.adUnits[0].bids[2].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[1].bids[2].params).to.be.undefined; expect(onDataResponse).to.deep.equal({ @@ -1124,8 +1161,6 @@ describe('weboramaRtdProvider', function() { expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar'); expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ foo: ['bar'], - webo_ctx: ['foo', 'bar'], - webo_ds: ['baz'], }); expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ inventory: { @@ -1136,6 +1171,18 @@ describe('weboramaRtdProvider', function() { } }); ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data, + }, + keywords: data, + } + }); + + return + } expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ site: { ext: { @@ -1213,9 +1260,21 @@ describe('weboramaRtdProvider', function() { expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); + expect(reqBidsConfigObj.adUnits[0].bids[2].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: defaultProfile, + }, + keywords: defaultProfile, + } + }); + + return + } expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ site: { ext: { @@ -1333,6 +1392,7 @@ describe('weboramaRtdProvider', function() { expect(adUnit.bids.length).to.equal(5); expect(adUnit.bids[0].params).to.be.undefined; expect(adUnit.bids[1].params).to.be.undefined; + expect(adUnit.bids[2].params).to.be.undefined; expect(adUnit.bids[3].params).to.be.undefined; }); ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { @@ -1346,6 +1406,11 @@ describe('weboramaRtdProvider', function() { webo_bar: ['baz'], } }, + keywords: { + webo_ctx: ['foo', 'bar'], + webo_ds: ['baz'], + webo_bar: ['baz'], + }, } }); @@ -1360,12 +1425,8 @@ describe('weboramaRtdProvider', function() { } }); }) - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ - webo_ctx: ['foo', 'bar'], - webo_ds: ['baz'], - webo_bar: ['baz'], - }); - expect(reqBidsConfigObj.adUnits[1].bids[2].params.keywords).to.deep.equal(data); + + expect(reqBidsConfigObj.adUnits[1].bids[2].params).to.be.undefined; expect(onDataResponse).to.deep.equal({ data: data, @@ -2607,9 +2668,21 @@ describe('weboramaRtdProvider', function() { expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); + expect(reqBidsConfigObj.adUnits[0].bids[2].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data, + }, + keywords: data, + } + }); + + return + } expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ site: { ext: { @@ -2732,7 +2805,7 @@ describe('weboramaRtdProvider', function() { expect(adUnit.bids.length).to.equal(5); expect(adUnit.bids[0].params).to.be.undefined; expect(adUnit.bids[1].params).to.be.undefined; - expect(adUnit.bids[2].params.keywords).to.deep.equal(data); + expect(adUnit.bids[2].params).to.be.undefined; expect(adUnit.bids[3].params).to.be.undefined; }); ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { @@ -2740,8 +2813,9 @@ describe('weboramaRtdProvider', function() { expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ site: { ext: { - data: data + data: data, }, + keywords: data, } }); @@ -2861,7 +2935,7 @@ describe('weboramaRtdProvider', function() { expect(adUnit.bids[3].params).to.be.undefined; }); - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); + expect(reqBidsConfigObj.adUnits[0].bids[2].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[1].bids[2].params).to.be.undefined; ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { @@ -2871,6 +2945,7 @@ describe('weboramaRtdProvider', function() { ext: { data: data }, + keywords: data, } }); @@ -3335,8 +3410,6 @@ describe('weboramaRtdProvider', function() { expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar'); expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ foo: ['bar'], - lite_occupation: ['gérant', 'bénévole'], - lite_hobbies: ['sport', 'cinéma'], }); expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ inventory: { @@ -3347,6 +3420,18 @@ describe('weboramaRtdProvider', function() { } }); ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data, + }, + keywords: data, + } + }); + + return + } expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ site: { ext: { @@ -3410,13 +3495,25 @@ describe('weboramaRtdProvider', function() { expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); + expect(reqBidsConfigObj.adUnits[0].bids[2].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: defaultProfile, + }, + keywords: defaultProfile, + } + }); + + return + } expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ site: { ext: { - data: defaultProfile + data: defaultProfile, }, } }); @@ -3483,7 +3580,7 @@ describe('weboramaRtdProvider', function() { expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); + expect(reqBidsConfigObj.adUnits[0].bids[2].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ site: { @@ -3493,6 +3590,18 @@ describe('weboramaRtdProvider', function() { }, }); ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: defaultProfile, + }, + keywords: defaultProfile, + } + }); + + return + } expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ site: { ext: { @@ -3570,9 +3679,21 @@ describe('weboramaRtdProvider', function() { expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); + expect(reqBidsConfigObj.adUnits[0].bids[2].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: defaultProfile, + }, + keywords: defaultProfile, + } + }); + + return + } expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ site: { ext: { @@ -3690,6 +3811,7 @@ describe('weboramaRtdProvider', function() { expect(adUnit.bids.length).to.equal(5); expect(adUnit.bids[0].params).to.be.undefined; expect(adUnit.bids[1].params).to.be.undefined; + expect(adUnit.bids[2].params).to.be.undefined; expect(adUnit.bids[3].params).to.be.undefined; }); ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { @@ -3703,6 +3825,11 @@ describe('weboramaRtdProvider', function() { lito_bar: ['baz'], }, }, + keywords: { + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], + lito_bar: ['baz'], + }, } }); @@ -3718,12 +3845,7 @@ describe('weboramaRtdProvider', function() { }); }) - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ - lite_occupation: ['gérant', 'bénévole'], - lite_hobbies: ['sport', 'cinéma'], - lito_bar: ['baz'], - }); - expect(reqBidsConfigObj.adUnits[1].bids[2].params.keywords).to.deep.equal(data); + expect(reqBidsConfigObj.adUnits[1].bids[2].params).to.be.undefined; expect(onDataResponse).to.deep.equal({ data: data,