From 3d6fa0dd4e95fee8fdfe136494216c079336c8b9 Mon Sep 17 00:00:00 2001 From: myerkovich Date: Thu, 10 Dec 2020 17:50:12 +0200 Subject: [PATCH 01/24] User id bidder permission scheme --- integrationExamples/gpt/userId_example.html | 1 + modules/userId/index.js | 40 +++++++++++++++------ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/integrationExamples/gpt/userId_example.html b/integrationExamples/gpt/userId_example.html index 7375293fdf0..e5b8c47e9cb 100644 --- a/integrationExamples/gpt/userId_example.html +++ b/integrationExamples/gpt/userId_example.html @@ -233,6 +233,7 @@ }, { name: "sharedId", + //bidders: ['rubicon', 'exBidder'], // to allow this ID for specific bidders params: { syncTime: 60 // in seconds, default is 24 hours }, diff --git a/modules/userId/index.js b/modules/userId/index.js index 0923a92f516..ef9d01ecd8e 100644 --- a/modules/userId/index.js +++ b/modules/userId/index.js @@ -364,6 +364,26 @@ function getCombinedSubmoduleIds(submodules) { return combinedSubmoduleIds; } +/** + * This function will create a combined object for bidder with allowed subModule Ids + * @param {SubmoduleContainer[]} submodules + * @param {string} bidder + */ +function getCombinedSubmoduleIdsForBidder(submodules, bidder) { + if (!Array.isArray(submodules) || !submodules.length || !bidder) { + return {}; + } + return submodules + .filter(i => !(i.config.bidders && utils.isArray(i.config.bidders)) || i.config.bidders.includes(bidder)) + .filter(i => utils.isPlainObject(i.idObj) && Object.keys(i.idObj).length) + .reduce((carry, i) => { + Object.keys(i.idObj).forEach(key => { + carry[key] = i.idObj[key]; + }); + return carry; + }, {}); +} + /** * @param {AdUnit[]} adUnits * @param {SubmoduleContainer[]} submodules @@ -372,19 +392,19 @@ function addIdDataToAdUnitBids(adUnits, submodules) { if ([adUnits].some(i => !Array.isArray(i) || !i.length)) { return; } - const combinedSubmoduleIds = getCombinedSubmoduleIds(submodules); - const combinedSubmoduleIdsAsEids = createEidsArray(combinedSubmoduleIds); - if (Object.keys(combinedSubmoduleIds).length) { - adUnits.forEach(adUnit => { - if (adUnit.bids && utils.isArray(adUnit.bids)) { - adUnit.bids.forEach(bid => { + adUnits.forEach(adUnit => { + if (adUnit.bids && utils.isArray(adUnit.bids)) { + adUnit.bids.forEach(bid => { + const combinedSubmoduleIds = getCombinedSubmoduleIdsForBidder(submodules, bid.bidder); + if (Object.keys(combinedSubmoduleIds).length) { + const combinedSubmoduleIdsAsEids = createEidsArray(combinedSubmoduleIds); // create a User ID object on the bid, bid.userId = combinedSubmoduleIds; bid.userIdAsEids = combinedSubmoduleIdsAsEids; - }); - } - }); - } + } + }); + } + }); } /** From 4ba6262d386fe41825ca7a8d507fc24f996ea11b Mon Sep 17 00:00:00 2001 From: myerkovich Date: Thu, 10 Dec 2020 18:31:20 +0200 Subject: [PATCH 02/24] styling --- modules/userId/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/userId/index.js b/modules/userId/index.js index ef9d01ecd8e..1742464ee3f 100644 --- a/modules/userId/index.js +++ b/modules/userId/index.js @@ -377,11 +377,11 @@ function getCombinedSubmoduleIdsForBidder(submodules, bidder) { .filter(i => !(i.config.bidders && utils.isArray(i.config.bidders)) || i.config.bidders.includes(bidder)) .filter(i => utils.isPlainObject(i.idObj) && Object.keys(i.idObj).length) .reduce((carry, i) => { - Object.keys(i.idObj).forEach(key => { - carry[key] = i.idObj[key]; - }); - return carry; - }, {}); + Object.keys(i.idObj).forEach(key => { + carry[key] = i.idObj[key]; + }); + return carry; + }, {}); } /** From bed0de2a3c3fd24a039ff66a5f59e2b0a2f02b19 Mon Sep 17 00:00:00 2001 From: myerkovich Date: Mon, 14 Dec 2020 16:47:11 +0200 Subject: [PATCH 03/24] prebidServer support --- integrationExamples/gpt/userId_example.html | 171 ++++---------------- modules/prebidServerBidAdapter/index.js | 5 + modules/userId/eids.js | 26 +++ modules/userId/index.js | 6 +- 4 files changed, 65 insertions(+), 143 deletions(-) diff --git a/integrationExamples/gpt/userId_example.html b/integrationExamples/gpt/userId_example.html index e5b8c47e9cb..908e794c38b 100644 --- a/integrationExamples/gpt/userId_example.html +++ b/integrationExamples/gpt/userId_example.html @@ -104,7 +104,16 @@ var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; - + - +