From 4b2a8f1318eb68c407e5e55a32d653b6973e446e Mon Sep 17 00:00:00 2001 From: Rich Snapp Date: Tue, 18 Jun 2019 13:28:29 -0600 Subject: [PATCH 01/16] prebid-core only contains src and a few node_modules --- webpack.conf.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/webpack.conf.js b/webpack.conf.js index 61cdf82df32..5b11fefa4ce 100644 --- a/webpack.conf.js +++ b/webpack.conf.js @@ -6,11 +6,6 @@ var RequireEnsureWithoutJsonp = require('./plugins/RequireEnsureWithoutJsonp.js' var { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); var argv = require('yargs').argv; -// list of module names to never include in the common bundle chunk -var neverBundle = [ - 'AnalyticsAdapter.js' -]; - var plugins = [ new RequireEnsureWithoutJsonp() ]; @@ -25,8 +20,11 @@ plugins.push( // this plugin must be last so it can be easily removed for karma new webpack.optimize.CommonsChunkPlugin({ name: 'prebid', filename: 'prebid-core.js', - minChunks: function(module, count) { - return !(count < 2 || neverBundle.indexOf(path.basename(module.resource)) !== -1) + minChunks: function(module) { + return ( + module.context && module.context === path.resolve('./src') || + module.resource && module.resource.includes(path.resolve('./node_modules/core-js')) + ); } }) ); From d0362442794bf189dcf9ddfad7ecb547f8138942 Mon Sep 17 00:00:00 2001 From: Rich Snapp Date: Tue, 18 Jun 2019 13:43:37 -0600 Subject: [PATCH 02/16] add back removed neverBundle to webpack build --- webpack.conf.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/webpack.conf.js b/webpack.conf.js index 5b11fefa4ce..8e1787de329 100644 --- a/webpack.conf.js +++ b/webpack.conf.js @@ -6,6 +6,11 @@ var RequireEnsureWithoutJsonp = require('./plugins/RequireEnsureWithoutJsonp.js' var { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); var argv = require('yargs').argv; +// list of module names to never include in the common bundle chunk +var neverBundle = [ + 'AnalyticsAdapter.js' +]; + var plugins = [ new RequireEnsureWithoutJsonp() ]; @@ -22,7 +27,10 @@ plugins.push( // this plugin must be last so it can be easily removed for karma filename: 'prebid-core.js', minChunks: function(module) { return ( - module.context && module.context === path.resolve('./src') || + ( + module.context && module.context === path.resolve('./src') && + !(module.resource && neverBundle.some(name => module.resource.includes(name))) + ) || module.resource && module.resource.includes(path.resolve('./node_modules/core-js')) ); } From 3cd6523528f40822dc08f0eaa01f73aeff1ba66e Mon Sep 17 00:00:00 2001 From: Rich Snapp Date: Wed, 19 Jun 2019 14:58:20 -0600 Subject: [PATCH 03/16] add module and submodule hooks --- gulpHelpers.js | 15 ++++++++++++++- modules/.submodules.json | 7 +++++++ modules/digiTrustIdSystem.js | 4 ++-- modules/pubCommonIdSystem.js | 5 ++++- modules/unifiedIdSystem.js | 3 +++ modules/userId.js | 7 ++----- src/hook.js | 13 +++++++++++++ 7 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 modules/.submodules.json diff --git a/gulpHelpers.js b/gulpHelpers.js index f20a2673ade..06e188341b4 100644 --- a/gulpHelpers.js +++ b/gulpHelpers.js @@ -6,12 +6,14 @@ const MANIFEST = 'package.json'; const through = require('through2'); const _ = require('lodash'); const gutil = require('gulp-util'); +const submodules = require('./modules/.submodules.json'); const MODULE_PATH = './modules'; const BUILD_PATH = './build/dist'; const DEV_PATH = './build/dev'; const ANALYTICS_PATH = '../analytics'; + // get only subdirectories that contain package.json with 'main' property function isModuleDirectory(filePath) { try { @@ -39,7 +41,18 @@ module.exports = { .replace(/\/>/g, '\\/>'); }, getArgModules() { - var modules = (argv.modules || '').split(',').filter(module => !!module); + var modules = (argv.modules || '') + .split(',') + .filter(module => !!module); + + Object.keys(submodules).forEach(parentModule => { + if ( + !modules.includes(parentModule) && + modules.some(module => submodules[parentModule].includes(module)) + ) { + modules.unshift(parentModule); + } + }); try { if (modules.length === 1 && path.extname(modules[0]).toLowerCase() === '.json') { diff --git a/modules/.submodules.json b/modules/.submodules.json new file mode 100644 index 00000000000..5585cae8cc1 --- /dev/null +++ b/modules/.submodules.json @@ -0,0 +1,7 @@ +{ + "userId": [ + "digiTrustIdSystem", + "pubCommonIdSystem", + "unifiedIdSystem" + ] +} diff --git a/modules/digiTrustIdSystem.js b/modules/digiTrustIdSystem.js index 454e6864846..1db65031848 100644 --- a/modules/digiTrustIdSystem.js +++ b/modules/digiTrustIdSystem.js @@ -12,7 +12,7 @@ // import { config } from 'src/config'; import * as utils from '../src/utils' import { ajax } from '../src/ajax'; -import { attachIdSystem } from '../modules/userId'; +import { submodule } from '../src/hook'; // import { getGlobal } from 'src/prebidGlobal'; /** @@ -336,4 +336,4 @@ export const digiTrustIdSubmodule = { _testInit: surfaceTestHook }; -attachIdSystem(digiTrustIdSubmodule); +submodule('userId', digiTrustIdSubmodule); diff --git a/modules/pubCommonIdSystem.js b/modules/pubCommonIdSystem.js index 39d1feea0ad..312404dbe5a 100644 --- a/modules/pubCommonIdSystem.js +++ b/modules/pubCommonIdSystem.js @@ -5,7 +5,8 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils.js' +import * as utils from '../src/utils.js'; +import { submodule } from '../src/hook'; /** @type {Submodule} */ export const pubCommonIdSubmodule = { @@ -40,3 +41,5 @@ export const pubCommonIdSubmodule = { return (pubcid) || utils.generateUUID(); } }; + +submodule('userId', pubCommonIdSubmodule); diff --git a/modules/unifiedIdSystem.js b/modules/unifiedIdSystem.js index 6b67b7bf5f1..613e4bff17d 100644 --- a/modules/unifiedIdSystem.js +++ b/modules/unifiedIdSystem.js @@ -7,6 +7,7 @@ import * as utils from '../src/utils.js' import {ajax} from '../src/ajax.js'; +import { submodule } from '../src/hook'; /** @type {Submodule} */ export const unifiedIdSubmodule = { @@ -53,3 +54,5 @@ export const unifiedIdSubmodule = { } } }; + +submodule('userId', unifiedIdSubmodule); diff --git a/modules/userId.js b/modules/userId.js index ae06dfc4027..82dbdda34de 100644 --- a/modules/userId.js +++ b/modules/userId.js @@ -73,9 +73,8 @@ import events from '../src/events.js'; import * as utils from '../src/utils.js'; import {getGlobal} from '../src/prebidGlobal.js'; import {gdprDataHandler} from '../src/adapterManager.js'; -import {unifiedIdSubmodule} from './unifiedIdSystem.js'; -import {pubCommonIdSubmodule} from './pubCommonIdSystem.js'; import CONSTANTS from '../src/constants.json'; +import { module } from '../src/hook' const MODULE_NAME = 'User ID'; const COOKIE = 'cookie'; @@ -419,6 +418,4 @@ export function init(config) { // init config update listener to start the application init(config); -// add submodules after init has been called -attachIdSystem(pubCommonIdSubmodule); -attachIdSystem(unifiedIdSubmodule); +module('userId', attachIdSystem); diff --git a/src/hook.js b/src/hook.js index ddf0d134357..3f0e630db27 100644 --- a/src/hook.js +++ b/src/hook.js @@ -13,3 +13,16 @@ export function setupBeforeHookFnOnce(baseFn, hookFn, priority = 15) { baseFn.before(hookFn, priority); } } + +export function module(name, install) { + hook('async', function (submodules) { + submodules.forEach(module => install(module)); + }, name)([]); // will be queued until hook.ready() called in pbjs.processQueue(); +} + +export function submodule(name, spec) { + getHook(name).before((next, modules) => { + modules.push(spec); + next(modules); + }); +} From 76cba02090ad0fbc4c92f0e46842784e18f433b0 Mon Sep 17 00:00:00 2001 From: Rich Snapp Date: Thu, 20 Jun 2019 11:07:00 -0600 Subject: [PATCH 04/16] allow vargs for submodules for flexibility --- src/hook.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hook.js b/src/hook.js index 3f0e630db27..220e1c39111 100644 --- a/src/hook.js +++ b/src/hook.js @@ -16,13 +16,13 @@ export function setupBeforeHookFnOnce(baseFn, hookFn, priority = 15) { export function module(name, install) { hook('async', function (submodules) { - submodules.forEach(module => install(module)); + submodules.forEach(args => install(...args)); }, name)([]); // will be queued until hook.ready() called in pbjs.processQueue(); } -export function submodule(name, spec) { +export function submodule(name, ...args) { getHook(name).before((next, modules) => { - modules.push(spec); + modules.push(args); next(modules); }); } From 47d576ef5480c4f106ff0bd31b7ffe6e63ebf31b Mon Sep 17 00:00:00 2001 From: Isaac Dettman Date: Thu, 20 Jun 2019 14:49:42 -0700 Subject: [PATCH 05/16] fix jsdoc type syntax --- modules/userId.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/userId.js b/modules/userId.js index 82dbdda34de..3e0575b0eec 100644 --- a/modules/userId.js +++ b/modules/userId.js @@ -13,7 +13,7 @@ * @name Submodule#getId * @param {SubmoduleParams} configParams * @param {ConsentData} consentData - * @return {(Object|function} id data or a callback, the callback is called on the auction end event + * @return {(Object|function)} id data or a callback, the callback is called on the auction end event */ /** @@ -21,7 +21,7 @@ * @summary decode a stored value for passing to bid requests * @name Submodule#decode * @param {Object|string} value - * @return {(Object|undefined} + * @return {(Object|undefined)} */ /** From 9c0620e78ed9fff4908c0fd4c0d5b05da7c7eea4 Mon Sep 17 00:00:00 2001 From: Isaac Dettman Date: Mon, 24 Jun 2019 13:35:44 -0700 Subject: [PATCH 06/16] updated id5 userid submodule for submodule bundle size duplication fix --- modules/id5IdSystem.js | 6 +++--- modules/unifiedIdSystem.js | 2 +- modules/userId.js | 15 +++------------ modules/userId.md | 24 ++---------------------- test/spec/modules/userId_spec.js | 2 +- 5 files changed, 10 insertions(+), 39 deletions(-) diff --git a/modules/id5IdSystem.js b/modules/id5IdSystem.js index 39ab256a81e..c69f88cd26a 100644 --- a/modules/id5IdSystem.js +++ b/modules/id5IdSystem.js @@ -7,7 +7,7 @@ import * as utils from '../src/utils.js' import {ajax} from '../src/ajax.js'; -import {isGDPRApplicable, attachIdSystem} from './userId.js'; +import {submodule} from '../src/hook'; /** @type {Submodule} */ export const id5IdSubmodule = { @@ -37,7 +37,7 @@ export const id5IdSubmodule = { utils.logError(`User ID - ID5 submodule requires partner to be defined as a number`); return; } - const hasGdpr = isGDPRApplicable(consentData) ? 1 : 0; + const hasGdpr = (consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies) ? 1 : 0; const gdprConsentString = hasGdpr ? consentData.consentString : ''; const url = `https://id5-sync.com/g/v1/${configParams.partner}.json?gdpr=${hasGdpr}&gdpr_consent=${gdprConsentString}`; @@ -57,4 +57,4 @@ export const id5IdSubmodule = { } }; -attachIdSystem(id5IdSubmodule); +submodule('userId', id5IdSubmodule); diff --git a/modules/unifiedIdSystem.js b/modules/unifiedIdSystem.js index 613e4bff17d..42dd7196cde 100644 --- a/modules/unifiedIdSystem.js +++ b/modules/unifiedIdSystem.js @@ -7,7 +7,7 @@ import * as utils from '../src/utils.js' import {ajax} from '../src/ajax.js'; -import { submodule } from '../src/hook'; +import {submodule} from '../src/hook'; /** @type {Submodule} */ export const unifiedIdSubmodule = { diff --git a/modules/userId.js b/modules/userId.js index a04fdbd1f22..fedc65c4836 100644 --- a/modules/userId.js +++ b/modules/userId.js @@ -74,7 +74,7 @@ import * as utils from '../src/utils.js'; import {getGlobal} from '../src/prebidGlobal.js'; import {gdprDataHandler} from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; -import { module } from '../src/hook' +import {module} from '../src/hook'; const MODULE_NAME = 'User ID'; const COOKIE = 'cookie'; @@ -157,22 +157,13 @@ function getStoredValue(storage) { return storedValue; } -/** - * test if consent module is present, and if GDPR applies - * @param {ConsentData} consentData - * @returns {boolean} - */ -export function isGDPRApplicable(consentData) { - return consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies; -} - /** * test if consent module is present, applies, and is valid for local storage or cookies (purpose 1) * @param {ConsentData} consentData * @returns {boolean} */ -export function hasGDPRConsent(consentData) { - if (isGDPRApplicable(consentData)) { +function hasGDPRConsent(consentData) { + if (consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies) { if (!consentData.consentString) { return false; } diff --git a/modules/userId.md b/modules/userId.md index b36b9b1007c..782e7782554 100644 --- a/modules/userId.md +++ b/modules/userId.md @@ -3,12 +3,12 @@ Example showing `cookie` storage for user id data for both submodules ``` pbjs.setConfig({ - usersync: { + userSync: { userIds: [{ name: "unifiedId", params: { partner: "prebid", - url: "http://match.adsrvr.org/track/rid?ttd_pid=prebid&fmt=json" + url: "//match.adsrvr.org/track/rid?ttd_pid=prebid&fmt=json" }, storage: { type: "cookie", @@ -28,26 +28,6 @@ pbjs.setConfig({ }); ``` -Example showing `cookie` storage for user id data for id5 submodule -``` -pbjs.setConfig({ - usersync: { - userIds: [{ - name: "id5Id", - params: { - partner: 173 // @TODO: Set your real ID5 partner ID here for production, please ask for one contact@id5.io - }, - storage: { - type: "cookie", - name: "id5id", - expires: 90 - } - }], - syncDelay: 5000 - } -}); -``` - Example showing `localStorage` for user id data for both submodules ``` pbjs.setConfig({ diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 60df468a903..2c05cedfe08 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -327,7 +327,7 @@ describe('User ID', function() { }, {adUnits}); }); - it('test hook from unifiedid html5', function(done) { + it('test hook from pubcommonid html5', function(done) { // simulate existing browser local storage values localStorage.setItem('unifiedid_alt', JSON.stringify({'TDID': 'testunifiedid_alt'})); localStorage.setItem('unifiedid_alt_exp', ''); From 6b9e976843fa009777d1350fe0d0f39b8006ee20 Mon Sep 17 00:00:00 2001 From: Isaac Dettman Date: Tue, 25 Jun 2019 10:26:39 -0700 Subject: [PATCH 07/16] add id5 userid submodule to .submodules --- modules/.submodules.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/.submodules.json b/modules/.submodules.json index 5585cae8cc1..74ccb94d7c7 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -2,6 +2,7 @@ "userId": [ "digiTrustIdSystem", "pubCommonIdSystem", - "unifiedIdSystem" + "unifiedIdSystem", + "id5IdSystem" ] } From 38b572760fb7977dcd2096c5e6902c461ee5d6b6 Mon Sep 17 00:00:00 2001 From: Isaac Dettman Date: Tue, 25 Jun 2019 10:47:03 -0700 Subject: [PATCH 08/16] fix opt out logic --- modules/userId.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/userId.js b/modules/userId.js index fedc65c4836..b847f9728f1 100644 --- a/modules/userId.js +++ b/modules/userId.js @@ -399,7 +399,7 @@ export function init(config) { return; } // _pubcid_optout is checked for compatiblility with pubCommonId - if (validStorageTypes.indexOf(LOCAL_STORAGE) !== -1 && (localStorage.getItem('_pbjs_id_optout') && localStorage.getItem('_pubcid_optout'))) { + if (validStorageTypes.indexOf(LOCAL_STORAGE) !== -1 && (localStorage.getItem('_pbjs_id_optout') || localStorage.getItem('_pubcid_optout'))) { utils.logInfo(`${MODULE_NAME} - opt-out localStorage found, exit module`); return; } From b42a235790405fda802ed2bf10485054364f55e6 Mon Sep 17 00:00:00 2001 From: Isaac Dettman Date: Tue, 25 Jun 2019 10:48:50 -0700 Subject: [PATCH 09/16] spelling fix to comment --- modules/userId.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/userId.js b/modules/userId.js index b847f9728f1..1a4ea724b6a 100644 --- a/modules/userId.js +++ b/modules/userId.js @@ -321,7 +321,7 @@ function getValidSubmoduleConfigs(configRegistry, submoduleRegistry, activeStora if (!config || utils.isEmptyStr(config.name)) { return carry; } - // alidate storage config contains 'type' and 'name' properties with non-empty string values + // Validate storage config contains 'type' and 'name' properties with non-empty string values // 'type' must be a value currently enabled in the browser if (config.storage && !utils.isEmptyStr(config.storage.type) && From 207fea75e2e94b3c115612268d98f4adf73b591f Mon Sep 17 00:00:00 2001 From: Isaac Dettman Date: Tue, 25 Jun 2019 11:19:36 -0700 Subject: [PATCH 10/16] update to automatically include 'pubcommon' and 'unifiedid' (uncomment to optional submodule for prebid3.0) --- modules/pubCommonIdSystem.js | 4 ++-- modules/unifiedIdSystem.js | 4 ++-- modules/userId.js | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/pubCommonIdSystem.js b/modules/pubCommonIdSystem.js index 312404dbe5a..9a2ac038146 100644 --- a/modules/pubCommonIdSystem.js +++ b/modules/pubCommonIdSystem.js @@ -6,7 +6,7 @@ */ import * as utils from '../src/utils.js'; -import { submodule } from '../src/hook'; +// import { submodule } from '../src/hook'; /** @type {Submodule} */ export const pubCommonIdSubmodule = { @@ -42,4 +42,4 @@ export const pubCommonIdSubmodule = { } }; -submodule('userId', pubCommonIdSubmodule); +// submodule('userId', pubCommonIdSubmodule); diff --git a/modules/unifiedIdSystem.js b/modules/unifiedIdSystem.js index 42dd7196cde..82b9d18ac60 100644 --- a/modules/unifiedIdSystem.js +++ b/modules/unifiedIdSystem.js @@ -7,7 +7,7 @@ import * as utils from '../src/utils.js' import {ajax} from '../src/ajax.js'; -import {submodule} from '../src/hook'; +// import {submodule} from '../src/hook'; /** @type {Submodule} */ export const unifiedIdSubmodule = { @@ -55,4 +55,4 @@ export const unifiedIdSubmodule = { } }; -submodule('userId', unifiedIdSubmodule); +// submodule('userId', unifiedIdSubmodule); diff --git a/modules/userId.js b/modules/userId.js index 1a4ea724b6a..33fc2a7c572 100644 --- a/modules/userId.js +++ b/modules/userId.js @@ -74,6 +74,8 @@ import * as utils from '../src/utils.js'; import {getGlobal} from '../src/prebidGlobal.js'; import {gdprDataHandler} from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; +import {unifiedIdSubmodule} from './unifiedIdSystem.js'; +import {pubCommonIdSubmodule} from './pubCommonIdSystem.js'; import {module} from '../src/hook'; const MODULE_NAME = 'User ID'; @@ -417,5 +419,8 @@ export function init(config) { // init config update listener to start the application init(config); +// add submodules after init has been called +attachIdSystem(pubCommonIdSubmodule); +attachIdSystem(unifiedIdSubmodule); module('userId', attachIdSystem); From 8398037b57bb43130e1d989e207ea03164d10879 Mon Sep 17 00:00:00 2001 From: Isaac Dettman Date: Tue, 25 Jun 2019 11:47:49 -0700 Subject: [PATCH 11/16] additional update to automatically include 'pubcommon' and 'unifiedid' --- modules/.submodules.json | 2 -- modules/aardvarkBidAdapter.js | 2 +- modules/adxcgBidAdapter.js | 4 ++-- modules/id5IdSystem.js | 4 ++-- modules/prebidServerBidAdapter/index.js | 4 ++-- modules/pubmaticBidAdapter.js | 2 +- modules/{userId.js => userId/index.js} | 14 +++++++------- modules/{ => userId}/pubCommonIdSystem.js | 5 +---- modules/{ => userId}/unifiedIdSystem.js | 7 ++----- modules/{ => userId}/userId.md | 0 test/spec/modules/userId_spec.js | 6 +++--- 11 files changed, 21 insertions(+), 29 deletions(-) rename modules/{userId.js => userId/index.js} (97%) rename modules/{ => userId}/pubCommonIdSystem.js (88%) rename modules/{ => userId}/unifiedIdSystem.js (90%) rename modules/{ => userId}/userId.md (100%) diff --git a/modules/.submodules.json b/modules/.submodules.json index 74ccb94d7c7..2d73c46bff8 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -1,8 +1,6 @@ { "userId": [ "digiTrustIdSystem", - "pubCommonIdSystem", - "unifiedIdSystem", "id5IdSystem" ] } diff --git a/modules/aardvarkBidAdapter.js b/modules/aardvarkBidAdapter.js index 9caaaaa747c..b1c72bbc934 100644 --- a/modules/aardvarkBidAdapter.js +++ b/modules/aardvarkBidAdapter.js @@ -42,7 +42,7 @@ export const spec = { height = topWin.innerHeight; } catch (e) {} - if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.tdid'))) { + if (utils.isStr(utils.deepAccess(validBidRequests, 'userId.tdid'))) { tdId = validBidRequests[0].userId.tdid; } diff --git a/modules/adxcgBidAdapter.js b/modules/adxcgBidAdapter.js index 34b5ea25fb0..0e6e3b85353 100644 --- a/modules/adxcgBidAdapter.js +++ b/modules/adxcgBidAdapter.js @@ -160,11 +160,11 @@ export const spec = { beaconParams.prebidBidIds = prebidBidIds.join(',') beaconParams.bidfloors = bidfloors.join(',') - if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.pubcid'))) { + if (utils.isStr(utils.deepAccess(validBidRequests, 'userId.pubcid'))) { beaconParams.pubcid = validBidRequests[0].userId.pubcid; } - if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.tdid'))) { + if (utils.isStr(utils.deepAccess(validBidRequests, 'userId.tdid'))) { beaconParams.tdid = validBidRequests[0].userId.tdid; } diff --git a/modules/id5IdSystem.js b/modules/id5IdSystem.js index c69f88cd26a..7ed1fdf6bf3 100644 --- a/modules/id5IdSystem.js +++ b/modules/id5IdSystem.js @@ -5,8 +5,8 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils.js' -import {ajax} from '../src/ajax.js'; +import * as utils from '../src/utils' +import {ajax} from '../src/ajax'; import {submodule} from '../src/hook'; /** @type {Submodule} */ diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 028f02d9662..5860de9a17c 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -234,7 +234,7 @@ function doClientSideSyncs(bidders) { function _getDigiTrustQueryParams(bidRequest = {}) { function getDigiTrustId(bidRequest) { - const bidRequestDigitrust = utils.deepAccess(bidRequest, 'bids.0.userId.digitrustid.data'); + const bidRequestDigitrust = utils.deepAccess(bidRequest, 'userId.digitrustid.data'); if (bidRequestDigitrust) { return bidRequestDigitrust; } @@ -534,7 +534,7 @@ const OPEN_RTB_PROTOCOL = { request.ext.prebid.aliases = aliases; } - const bidUserId = utils.deepAccess(bidRequests, '0.bids.0.userId'); + const bidUserId = utils.deepAccess(bidRequests, 'userId'); if (bidUserId && typeof bidUserId === 'object' && (bidUserId.tdid || bidUserId.pubcid)) { utils.deepSetValue(request, 'user.ext.eids', []); diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index 245ca3e60c9..827a442e06e 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -604,7 +604,7 @@ function _handleDigitrustId(eids) { function _handleTTDId(eids, validBidRequests) { let ttdId = null; let adsrvrOrgId = config.getConfig('adsrvrOrgId'); - if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.tdid'))) { + if (utils.isStr(utils.deepAccess(validBidRequests, 'userId.tdid'))) { ttdId = validBidRequests[0].userId.tdid; } else if (adsrvrOrgId && utils.isStr(adsrvrOrgId.TDID)) { ttdId = adsrvrOrgId.TDID; diff --git a/modules/userId.js b/modules/userId/index.js similarity index 97% rename from modules/userId.js rename to modules/userId/index.js index 33fc2a7c572..777ffcde3a1 100644 --- a/modules/userId.js +++ b/modules/userId/index.js @@ -68,15 +68,15 @@ */ import find from 'core-js/library/fn/array/find'; -import {config} from '../src/config.js'; -import events from '../src/events.js'; -import * as utils from '../src/utils.js'; -import {getGlobal} from '../src/prebidGlobal.js'; -import {gdprDataHandler} from '../src/adapterManager.js'; -import CONSTANTS from '../src/constants.json'; +import {config} from '../../src/config'; +import events from '../../src/events'; +import * as utils from '../../src/utils'; +import {getGlobal} from '../../src/prebidGlobal'; +import {gdprDataHandler} from '../../src/adapterManager'; +import CONSTANTS from '../../src/constants.json'; +import {module} from '../../src/hook'; import {unifiedIdSubmodule} from './unifiedIdSystem.js'; import {pubCommonIdSubmodule} from './pubCommonIdSystem.js'; -import {module} from '../src/hook'; const MODULE_NAME = 'User ID'; const COOKIE = 'cookie'; diff --git a/modules/pubCommonIdSystem.js b/modules/userId/pubCommonIdSystem.js similarity index 88% rename from modules/pubCommonIdSystem.js rename to modules/userId/pubCommonIdSystem.js index 9a2ac038146..f4d6b41a127 100644 --- a/modules/pubCommonIdSystem.js +++ b/modules/userId/pubCommonIdSystem.js @@ -5,8 +5,7 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils.js'; -// import { submodule } from '../src/hook'; +import * as utils from '../../src/utils'; /** @type {Submodule} */ export const pubCommonIdSubmodule = { @@ -41,5 +40,3 @@ export const pubCommonIdSubmodule = { return (pubcid) || utils.generateUUID(); } }; - -// submodule('userId', pubCommonIdSubmodule); diff --git a/modules/unifiedIdSystem.js b/modules/userId/unifiedIdSystem.js similarity index 90% rename from modules/unifiedIdSystem.js rename to modules/userId/unifiedIdSystem.js index 82b9d18ac60..cf86c049d2a 100644 --- a/modules/unifiedIdSystem.js +++ b/modules/userId/unifiedIdSystem.js @@ -5,9 +5,8 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils.js' -import {ajax} from '../src/ajax.js'; -// import {submodule} from '../src/hook'; +import * as utils from '../../src/utils' +import {ajax} from '../../src/ajax'; /** @type {Submodule} */ export const unifiedIdSubmodule = { @@ -54,5 +53,3 @@ export const unifiedIdSubmodule = { } } }; - -// submodule('userId', unifiedIdSubmodule); diff --git a/modules/userId.md b/modules/userId/userId.md similarity index 100% rename from modules/userId.md rename to modules/userId/userId.md diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 2c05cedfe08..a158d2e9fed 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -4,11 +4,11 @@ import { setSubmoduleRegistry, syncDelay, attachIdSystem -} from 'modules/userId'; +} from 'modules/userId/index.js'; import {config} from 'src/config'; import * as utils from 'src/utils'; -import {unifiedIdSubmodule} from 'modules/unifiedIdSystem'; -import {pubCommonIdSubmodule} from 'modules/pubCommonIdSystem'; +import {unifiedIdSubmodule} from 'modules/userId/unifiedIdSystem'; +import {pubCommonIdSubmodule} from 'modules/userId/pubCommonIdSystem'; import {id5IdSubmodule} from 'modules/id5IdSystem'; let assert = require('chai').assert; let expect = require('chai').expect; From 1bb74d873a8d11f83d51df4a63e62e830a3faedc Mon Sep 17 00:00:00 2001 From: Isaac Dettman Date: Tue, 25 Jun 2019 11:47:49 -0700 Subject: [PATCH 12/16] additional update to automatically include 'pubcommon' and 'unifiedid' --- modules/.submodules.json | 2 -- modules/id5IdSystem.js | 4 ++-- modules/pubmaticBidAdapter.js | 2 +- modules/{userId.js => userId/index.js} | 14 +++++++------- modules/{ => userId}/pubCommonIdSystem.js | 5 +---- modules/{ => userId}/unifiedIdSystem.js | 7 ++----- modules/{ => userId}/userId.md | 0 test/spec/modules/userId_spec.js | 6 +++--- 8 files changed, 16 insertions(+), 24 deletions(-) rename modules/{userId.js => userId/index.js} (97%) rename modules/{ => userId}/pubCommonIdSystem.js (88%) rename modules/{ => userId}/unifiedIdSystem.js (90%) rename modules/{ => userId}/userId.md (100%) diff --git a/modules/.submodules.json b/modules/.submodules.json index 74ccb94d7c7..2d73c46bff8 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -1,8 +1,6 @@ { "userId": [ "digiTrustIdSystem", - "pubCommonIdSystem", - "unifiedIdSystem", "id5IdSystem" ] } diff --git a/modules/id5IdSystem.js b/modules/id5IdSystem.js index c69f88cd26a..7ed1fdf6bf3 100644 --- a/modules/id5IdSystem.js +++ b/modules/id5IdSystem.js @@ -5,8 +5,8 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils.js' -import {ajax} from '../src/ajax.js'; +import * as utils from '../src/utils' +import {ajax} from '../src/ajax'; import {submodule} from '../src/hook'; /** @type {Submodule} */ diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index 245ca3e60c9..827a442e06e 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -604,7 +604,7 @@ function _handleDigitrustId(eids) { function _handleTTDId(eids, validBidRequests) { let ttdId = null; let adsrvrOrgId = config.getConfig('adsrvrOrgId'); - if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.tdid'))) { + if (utils.isStr(utils.deepAccess(validBidRequests, 'userId.tdid'))) { ttdId = validBidRequests[0].userId.tdid; } else if (adsrvrOrgId && utils.isStr(adsrvrOrgId.TDID)) { ttdId = adsrvrOrgId.TDID; diff --git a/modules/userId.js b/modules/userId/index.js similarity index 97% rename from modules/userId.js rename to modules/userId/index.js index 33fc2a7c572..777ffcde3a1 100644 --- a/modules/userId.js +++ b/modules/userId/index.js @@ -68,15 +68,15 @@ */ import find from 'core-js/library/fn/array/find'; -import {config} from '../src/config.js'; -import events from '../src/events.js'; -import * as utils from '../src/utils.js'; -import {getGlobal} from '../src/prebidGlobal.js'; -import {gdprDataHandler} from '../src/adapterManager.js'; -import CONSTANTS from '../src/constants.json'; +import {config} from '../../src/config'; +import events from '../../src/events'; +import * as utils from '../../src/utils'; +import {getGlobal} from '../../src/prebidGlobal'; +import {gdprDataHandler} from '../../src/adapterManager'; +import CONSTANTS from '../../src/constants.json'; +import {module} from '../../src/hook'; import {unifiedIdSubmodule} from './unifiedIdSystem.js'; import {pubCommonIdSubmodule} from './pubCommonIdSystem.js'; -import {module} from '../src/hook'; const MODULE_NAME = 'User ID'; const COOKIE = 'cookie'; diff --git a/modules/pubCommonIdSystem.js b/modules/userId/pubCommonIdSystem.js similarity index 88% rename from modules/pubCommonIdSystem.js rename to modules/userId/pubCommonIdSystem.js index 9a2ac038146..f4d6b41a127 100644 --- a/modules/pubCommonIdSystem.js +++ b/modules/userId/pubCommonIdSystem.js @@ -5,8 +5,7 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils.js'; -// import { submodule } from '../src/hook'; +import * as utils from '../../src/utils'; /** @type {Submodule} */ export const pubCommonIdSubmodule = { @@ -41,5 +40,3 @@ export const pubCommonIdSubmodule = { return (pubcid) || utils.generateUUID(); } }; - -// submodule('userId', pubCommonIdSubmodule); diff --git a/modules/unifiedIdSystem.js b/modules/userId/unifiedIdSystem.js similarity index 90% rename from modules/unifiedIdSystem.js rename to modules/userId/unifiedIdSystem.js index 82b9d18ac60..cf86c049d2a 100644 --- a/modules/unifiedIdSystem.js +++ b/modules/userId/unifiedIdSystem.js @@ -5,9 +5,8 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils.js' -import {ajax} from '../src/ajax.js'; -// import {submodule} from '../src/hook'; +import * as utils from '../../src/utils' +import {ajax} from '../../src/ajax'; /** @type {Submodule} */ export const unifiedIdSubmodule = { @@ -54,5 +53,3 @@ export const unifiedIdSubmodule = { } } }; - -// submodule('userId', unifiedIdSubmodule); diff --git a/modules/userId.md b/modules/userId/userId.md similarity index 100% rename from modules/userId.md rename to modules/userId/userId.md diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 2c05cedfe08..a158d2e9fed 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -4,11 +4,11 @@ import { setSubmoduleRegistry, syncDelay, attachIdSystem -} from 'modules/userId'; +} from 'modules/userId/index.js'; import {config} from 'src/config'; import * as utils from 'src/utils'; -import {unifiedIdSubmodule} from 'modules/unifiedIdSystem'; -import {pubCommonIdSubmodule} from 'modules/pubCommonIdSystem'; +import {unifiedIdSubmodule} from 'modules/userId/unifiedIdSystem'; +import {pubCommonIdSubmodule} from 'modules/userId/pubCommonIdSystem'; import {id5IdSubmodule} from 'modules/id5IdSystem'; let assert = require('chai').assert; let expect = require('chai').expect; From b1e5401f245ee19d5824aa0a372b792e6536566d Mon Sep 17 00:00:00 2001 From: Isaac Dettman Date: Thu, 27 Jun 2019 10:19:51 -0700 Subject: [PATCH 13/16] merged differences from master --- modules/aardvarkBidAdapter.js | 2 +- modules/adxcgBidAdapter.js | 4 ++-- modules/prebidServerBidAdapter/index.js | 4 ++-- modules/pubmaticBidAdapter.js | 2 +- modules/userId/index.js | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/aardvarkBidAdapter.js b/modules/aardvarkBidAdapter.js index b1c72bbc934..9caaaaa747c 100644 --- a/modules/aardvarkBidAdapter.js +++ b/modules/aardvarkBidAdapter.js @@ -42,7 +42,7 @@ export const spec = { height = topWin.innerHeight; } catch (e) {} - if (utils.isStr(utils.deepAccess(validBidRequests, 'userId.tdid'))) { + if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.tdid'))) { tdId = validBidRequests[0].userId.tdid; } diff --git a/modules/adxcgBidAdapter.js b/modules/adxcgBidAdapter.js index 0e6e3b85353..34b5ea25fb0 100644 --- a/modules/adxcgBidAdapter.js +++ b/modules/adxcgBidAdapter.js @@ -160,11 +160,11 @@ export const spec = { beaconParams.prebidBidIds = prebidBidIds.join(',') beaconParams.bidfloors = bidfloors.join(',') - if (utils.isStr(utils.deepAccess(validBidRequests, 'userId.pubcid'))) { + if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.pubcid'))) { beaconParams.pubcid = validBidRequests[0].userId.pubcid; } - if (utils.isStr(utils.deepAccess(validBidRequests, 'userId.tdid'))) { + if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.tdid'))) { beaconParams.tdid = validBidRequests[0].userId.tdid; } diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index bdf6856165f..4ac1bccaeda 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -234,7 +234,7 @@ function doClientSideSyncs(bidders) { function _getDigiTrustQueryParams(bidRequest = {}) { function getDigiTrustId(bidRequest) { - const bidRequestDigitrust = utils.deepAccess(bidRequest, 'userId.digitrustid.data'); + const bidRequestDigitrust = utils.deepAccess(bidRequest, 'bids.0.userId.digitrustid.data'); if (bidRequestDigitrust) { return bidRequestDigitrust; } @@ -534,7 +534,7 @@ const OPEN_RTB_PROTOCOL = { request.ext.prebid.aliases = aliases; } - const bidUserId = utils.deepAccess(bidRequests, 'userId'); + const bidUserId = utils.deepAccess(bidRequests, '0.bids.0.userId'); if (bidUserId && typeof bidUserId === 'object' && (bidUserId.tdid || bidUserId.pubcid)) { utils.deepSetValue(request, 'user.ext.eids', []); diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index 827a442e06e..245ca3e60c9 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -604,7 +604,7 @@ function _handleDigitrustId(eids) { function _handleTTDId(eids, validBidRequests) { let ttdId = null; let adsrvrOrgId = config.getConfig('adsrvrOrgId'); - if (utils.isStr(utils.deepAccess(validBidRequests, 'userId.tdid'))) { + if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.tdid'))) { ttdId = validBidRequests[0].userId.tdid; } else if (adsrvrOrgId && utils.isStr(adsrvrOrgId.TDID)) { ttdId = adsrvrOrgId.TDID; diff --git a/modules/userId/index.js b/modules/userId/index.js index 777ffcde3a1..2091a6a763a 100644 --- a/modules/userId/index.js +++ b/modules/userId/index.js @@ -419,6 +419,7 @@ export function init(config) { // init config update listener to start the application init(config); + // add submodules after init has been called attachIdSystem(pubCommonIdSubmodule); attachIdSystem(unifiedIdSubmodule); From 73d6f5b62e7b7d04111f90a4ac164a6487f4fb40 Mon Sep 17 00:00:00 2001 From: Jaimin Panchal Date: Thu, 27 Jun 2019 14:47:16 -0400 Subject: [PATCH 14/16] adpod changes to support submodules --- modules/.submodules.json | 6 +++- modules/adpod.js | 31 ++++++++++++++++--- modules/freeWheelAdserverVideo.js | 23 +++++++------- .../modules/freeWheelAdserverVideo_spec.js | 5 ++- 4 files changed, 46 insertions(+), 19 deletions(-) diff --git a/modules/.submodules.json b/modules/.submodules.json index 74ccb94d7c7..edd56182549 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -3,6 +3,10 @@ "digiTrustIdSystem", "pubCommonIdSystem", "unifiedIdSystem", - "id5IdSystem" + "id5IdSystem", + "unifiedIdSystem" + ], + "adpod": [ + "freeWheelAdserverVideo" ] } diff --git a/modules/adpod.js b/modules/adpod.js index 021d4722f53..46671e9fb0a 100644 --- a/modules/adpod.js +++ b/modules/adpod.js @@ -16,16 +16,17 @@ import * as utils from '../src/utils'; import { addBidToAuction, doCallbacksIfTimedout, AUCTION_IN_PROGRESS, callPrebidCache } from '../src/auction'; import { checkAdUnitSetup } from '../src/prebid'; import { checkVideoBidSetup } from '../src/video'; -import { setupBeforeHookFnOnce } from '../src/hook'; +import { setupBeforeHookFnOnce, module } from '../src/hook'; import { store } from '../src/videoCache'; import { config } from '../src/config'; import { ADPOD } from '../src/mediaTypes'; import Set from 'core-js/library/fn/set'; import find from 'core-js/library/fn/array/find'; + const from = require('core-js/library/fn/array/from'); -export const TARGETING_KEY_PB_CAT_DUR = 'hb_pb_cat_dur'; -export const TARGETING_KEY_CACHE_ID = 'hb_cache_id' +const TARGETING_KEY_PB_CAT_DUR = 'hb_pb_cat_dur'; +const TARGETING_KEY_CACHE_ID = 'hb_cache_id'; let queueTimeDelay = 50; let queueSizeLimit = 5; @@ -385,12 +386,13 @@ config.getConfig('adpod', config => adpodSetConfig(config.adpod)); /** * This function initializes the adpod module's hooks. This is called by the corresponding adserver video module. */ -export function initAdpodHooks() { +function initAdpodHooks() { setupBeforeHookFnOnce(callPrebidCache, callPrebidCacheHook); setupBeforeHookFnOnce(checkAdUnitSetup, checkAdUnitSetupHook); setupBeforeHookFnOnce(checkVideoBidSetup, checkVideoBidSetupHook); } +initAdpodHooks() /** * * @param {Array[Object]} bids list of 'winning' bids that need to be cached @@ -428,3 +430,24 @@ export function sortByPricePerSecond(a, b) { } return 0; } + +const sharedMethods = { + TARGETING_KEY_PB_CAT_DUR: TARGETING_KEY_PB_CAT_DUR, + TARGETING_KEY_CACHE_ID: TARGETING_KEY_CACHE_ID, + 'sortByPricePerSecond': sortByPricePerSecond, + 'callPrebidCacheAfterAuction': callPrebidCacheAfterAuction +} +Object.freeze(sharedMethods); + +module('adpod', function shareAdpodUtilities(...args) { + if (!utils.isPlainObject(args[0])) { + utils.logError('Adpod module needs plain object to share methods with submodule'); + return; + } + function addMethods(object, func) { + for (let name in func) { + object[name] = func[name]; + } + } + addMethods(args[0], sharedMethods); +}); diff --git a/modules/freeWheelAdserverVideo.js b/modules/freeWheelAdserverVideo.js index c81f3356d71..a93e5ab9159 100644 --- a/modules/freeWheelAdserverVideo.js +++ b/modules/freeWheelAdserverVideo.js @@ -7,8 +7,7 @@ import { auctionManager } from '../src/auctionManager'; import { groupBy, deepAccess, logError, compareOn } from '../src/utils'; import { config } from '../src/config'; import { ADPOD } from '../src/mediaTypes'; -import { initAdpodHooks, TARGETING_KEY_PB_CAT_DUR, TARGETING_KEY_CACHE_ID, callPrebidCacheAfterAuction, sortByPricePerSecond } from './adpod'; -import { getHook } from '../src/hook'; +import { getHook, submodule } from '../src/hook'; export function notifyTranslationModule(fn) { fn.call(this, 'freewheel'); @@ -37,7 +36,7 @@ export function getTargeting({codes, callback} = {}) { let bids = getBidsForAdpod(bidsReceived, adPodAdUnits); bids = (competiveExclusionEnabled || deferCachingEnabled) ? getExclusiveBids(bids) : bids; - bids.sort(sortByPricePerSecond); + bids.sort(adpodUtils.sortByPricePerSecond); let targeting = {}; if (deferCachingEnabled === false) { @@ -50,13 +49,13 @@ export function getTargeting({codes, callback} = {}) { .forEach((bid, index, arr) => { if (bid.video.durationBucket <= adPodDurationSeconds) { adPodTargeting.push({ - [TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR] + [adpodUtils.TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[adpodUtils.TARGETING_KEY_PB_CAT_DUR] }); adPodDurationSeconds -= bid.video.durationBucket; } if (index === arr.length - 1 && adPodTargeting.length > 0) { adPodTargeting.push({ - [TARGETING_KEY_CACHE_ID]: bid.adserverTargeting[TARGETING_KEY_CACHE_ID] + [adpodUtils.TARGETING_KEY_CACHE_ID]: bid.adserverTargeting[adpodUtils.TARGETING_KEY_CACHE_ID] }); } }); @@ -79,7 +78,7 @@ export function getTargeting({codes, callback} = {}) { }); }); - callPrebidCacheAfterAuction(bidsToCache, function(error, bidsSuccessfullyCached) { + adpodUtils.callPrebidCacheAfterAuction(bidsToCache, function(error, bidsSuccessfullyCached) { if (error) { callback(error, null); } else { @@ -89,12 +88,12 @@ export function getTargeting({codes, callback} = {}) { groupedBids[adUnitCode].forEach((bid, index, arr) => { adPodTargeting.push({ - [TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR] + [adpodUtils.TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[adpodUtils.TARGETING_KEY_PB_CAT_DUR] }); if (index === arr.length - 1 && adPodTargeting.length > 0) { adPodTargeting.push({ - [TARGETING_KEY_CACHE_ID]: bid.adserverTargeting[TARGETING_KEY_CACHE_ID] + [adpodUtils.TARGETING_KEY_CACHE_ID]: bid.adserverTargeting[adpodUtils.TARGETING_KEY_CACHE_ID] }); } }); @@ -126,8 +125,8 @@ function getAdPodAdUnits(codes) { */ function getExclusiveBids(bidsReceived) { let bids = bidsReceived - .map((bid) => Object.assign({}, bid, {[TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR]})); - bids = groupBy(bids, TARGETING_KEY_PB_CAT_DUR); + .map((bid) => Object.assign({}, bid, {[adpodUtils.TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[adpodUtils.TARGETING_KEY_PB_CAT_DUR]})); + bids = groupBy(bids, adpodUtils.TARGETING_KEY_PB_CAT_DUR); let filteredBids = []; Object.keys(bids).forEach((targetingKey) => { bids[targetingKey].sort(compareOn('responseTimestamp')); @@ -148,7 +147,9 @@ function getBidsForAdpod(bidsReceived, adPodAdUnits) { .filter((bid) => adUnitCodes.indexOf(bid.adUnitCode) != -1 && (bid.video && bid.video.context === ADPOD)) } -initAdpodHooks(); registerVideoSupport('freewheel', { getTargeting: getTargeting }); + +export const adpodUtils = {}; +submodule('adpod', adpodUtils); diff --git a/test/spec/modules/freeWheelAdserverVideo_spec.js b/test/spec/modules/freeWheelAdserverVideo_spec.js index 5846774c8b1..ffc690e5a92 100644 --- a/test/spec/modules/freeWheelAdserverVideo_spec.js +++ b/test/spec/modules/freeWheelAdserverVideo_spec.js @@ -1,8 +1,7 @@ import { expect } from 'chai'; -import { getTargeting } from 'modules/freeWheelAdserverVideo'; +import { getTargeting, adpodUtils } from 'modules/freeWheelAdserverVideo'; import { auctionManager } from 'src/auctionManager'; import { config } from 'src/config'; -import * as adpod from 'modules/adpod'; describe('freeWheel adserver module', function() { let amStub; @@ -53,7 +52,7 @@ describe('freeWheel adserver module', function() { amGetAdUnitsStub = sinon.stub(auctionManager, 'getAdUnits'); amGetAdUnitsStub.returns(adUnits); amStub = sinon.stub(auctionManager, 'getBidsReceived'); - pbcStub = sinon.stub(adpod, 'callPrebidCacheAfterAuction').callsFake(function (...args) { + pbcStub = sinon.stub(adpodUtils, 'callPrebidCacheAfterAuction').callsFake(function (...args) { args[1](null, getBidsReceived()); }); }); From 058d4488051bf997768c67caef9b381422a2605e Mon Sep 17 00:00:00 2001 From: Rich Snapp Date: Thu, 27 Jun 2019 16:25:23 -0600 Subject: [PATCH 15/16] fix --modules argument with .json to work correctly with submodules --- gulpHelpers.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gulpHelpers.js b/gulpHelpers.js index 06e188341b4..04428133347 100644 --- a/gulpHelpers.js +++ b/gulpHelpers.js @@ -45,15 +45,6 @@ module.exports = { .split(',') .filter(module => !!module); - Object.keys(submodules).forEach(parentModule => { - if ( - !modules.includes(parentModule) && - modules.some(module => submodules[parentModule].includes(module)) - ) { - modules.unshift(parentModule); - } - }); - try { if (modules.length === 1 && path.extname(modules[0]).toLowerCase() === '.json') { var moduleFile = modules[0]; @@ -69,6 +60,15 @@ module.exports = { }); } + Object.keys(submodules).forEach(parentModule => { + if ( + !modules.includes(parentModule) && + modules.some(module => submodules[parentModule].includes(module)) + ) { + modules.unshift(parentModule); + } + }); + return modules; }, getModules: _.memoize(function(externalModules) { From 5d3e818e603cd01f42137f6a68b869666ef799c1 Mon Sep 17 00:00:00 2001 From: Isaac Dettman Date: Fri, 28 Jun 2019 13:06:33 -0700 Subject: [PATCH 16/16] fix to remove included and duplicated submodules --- modules/.submodules.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/.submodules.json b/modules/.submodules.json index edd56182549..f321e075208 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -1,10 +1,7 @@ { "userId": [ "digiTrustIdSystem", - "pubCommonIdSystem", - "unifiedIdSystem", - "id5IdSystem", - "unifiedIdSystem" + "id5IdSystem" ], "adpod": [ "freeWheelAdserverVideo"