From 06249372b29640fcfee0b8a4193ea1063f7af069 Mon Sep 17 00:00:00 2001 From: Harshad Mane Date: Wed, 29 Sep 2021 04:42:40 -0700 Subject: [PATCH] Multiple Bid/Analytics/ID/ other modules: import utils functions as needed and not the whole module (#7498) * added support for pubcommon, digitrust, id5id * added support for IdentityLink * changed the source for id5 * added unit test cases * changed source param for identityLink * import utils functions as needed and not the whole module * import utils functions as needed and not the whole module * import utils functions as needed and not the whole module * Revert "import utils functions as needed and not the whole module" This reverts commit bc6c9f61f889e9aa2ef8ab207b87d4e7b49e3e57. * Revert "import utils functions as needed and not the whole module" This reverts commit ef500abb06648c763caa066ccd18fd5a18f2a1b5. * Revert "import utils functions as needed and not the whole module" This reverts commit 7e3fa3feba9ec9b8e81524419c3c13e94ee1049e. * import utils functions as needed and not the whole module * import utils functions as needed and not the whole module * import utils functions as needed and not the whole module --- modules/timeoutRtdProvider.js | 30 +++++++++---------- modules/tpmnBidAdapter.js | 6 ++-- modules/trionBidAdapter.js | 30 +++++++++---------- modules/tripleliftBidAdapter.js | 46 +++++++++++++++--------------- modules/truereachBidAdapter.js | 8 +++--- modules/trustxBidAdapter.js | 26 ++++++++--------- modules/ucfunnelBidAdapter.js | 6 ++-- modules/uid2IdSystem.js | 12 ++++---- modules/underdogmediaBidAdapter.js | 8 +++--- modules/unicornBidAdapter.js | 26 ++++++++--------- modules/unifiedIdSystem.js | 8 +++--- modules/unrulyBidAdapter.js | 32 ++++++++++----------- modules/vdoaiBidAdapter.js | 4 +-- modules/verizonMediaIdSystem.js | 10 +++---- modules/vidazooBidAdapter.js | 10 +++---- 15 files changed, 131 insertions(+), 131 deletions(-) diff --git a/modules/timeoutRtdProvider.js b/modules/timeoutRtdProvider.js index 8f68cf1bcc5..323a5291e2d 100644 --- a/modules/timeoutRtdProvider.js +++ b/modules/timeoutRtdProvider.js @@ -1,7 +1,7 @@ import { submodule } from '../src/hook.js'; import * as ajax from '../src/ajax.js'; -import * as utils from '../src/utils.js'; +import { logInfo, deepAccess, logError } from '../src/utils.js'; import { getGlobal } from '../src/prebidGlobal.js'; const SUBMODULE_NAME = 'timeout'; @@ -70,14 +70,14 @@ function getConnectionSpeed() { * @return {int} */ function calculateTimeoutModifier(adUnits, rules) { - utils.logInfo('Timeout rules', rules); + logInfo('Timeout rules', rules); let timeoutModifier = 0; let toAdd = 0; if (rules.includesVideo) { const hasVideo = timeoutRtdFunctions.checkVideo(adUnits); toAdd = rules.includesVideo[hasVideo] || 0; - utils.logInfo(`Adding ${toAdd} to timeout for includesVideo ${hasVideo}`) + logInfo(`Adding ${toAdd} to timeout for includesVideo ${hasVideo}`) timeoutModifier += toAdd; } @@ -89,7 +89,7 @@ function calculateTimeoutModifier(adUnits, rules) { for (const [rangeStr, timeoutVal] of entries(rules.numAdUnits)) { const [lowerBound, upperBound] = rangeStr.split('-'); if (parseInt(lowerBound) <= numAdUnits && numAdUnits <= parseInt(upperBound)) { - utils.logInfo(`Adding ${timeoutVal} to timeout for numAdUnits ${numAdUnits}`) + logInfo(`Adding ${timeoutVal} to timeout for numAdUnits ${numAdUnits}`) timeoutModifier += timeoutVal; break; } @@ -100,18 +100,18 @@ function calculateTimeoutModifier(adUnits, rules) { if (rules.deviceType) { const deviceType = timeoutRtdFunctions.getDeviceType(); toAdd = rules.deviceType[deviceType] || 0; - utils.logInfo(`Adding ${toAdd} to timeout for deviceType ${deviceType}`) + logInfo(`Adding ${toAdd} to timeout for deviceType ${deviceType}`) timeoutModifier += toAdd; } if (rules.connectionSpeed) { const connectionSpeed = timeoutRtdFunctions.getConnectionSpeed(); toAdd = rules.connectionSpeed[connectionSpeed] || 0; - utils.logInfo(`Adding ${toAdd} to timeout for connectionSpeed ${connectionSpeed}`) + logInfo(`Adding ${toAdd} to timeout for connectionSpeed ${connectionSpeed}`) timeoutModifier += toAdd; } - utils.logInfo('timeout Modifier calculated', timeoutModifier); + logInfo('timeout Modifier calculated', timeoutModifier); return timeoutModifier; } @@ -123,30 +123,30 @@ function calculateTimeoutModifier(adUnits, rules) { * @param {Object} userConsent */ function getBidRequestData(reqBidsConfigObj, callback, config, userConsent) { - utils.logInfo('Timeout rtd config', config); - const timeoutUrl = utils.deepAccess(config, 'params.endpoint.url'); + logInfo('Timeout rtd config', config); + const timeoutUrl = deepAccess(config, 'params.endpoint.url'); if (timeoutUrl) { - utils.logInfo('Timeout url', timeoutUrl); + logInfo('Timeout url', timeoutUrl); ajax.ajaxBuilder()(timeoutUrl, { success: function(response) { try { const rules = JSON.parse(response); timeoutRtdFunctions.handleTimeoutIncrement(reqBidsConfigObj, rules); } catch (e) { - utils.logError('Error parsing json response from timeout provider.') + logError('Error parsing json response from timeout provider.') } callback(); }, error: function(errorStatus) { - utils.logError('Timeout request error!', errorStatus); + logError('Timeout request error!', errorStatus); callback(); } }); - } else if (utils.deepAccess(config, 'params.rules')) { - timeoutRtdFunctions.handleTimeoutIncrement(reqBidsConfigObj, utils.deepAccess(config, 'params.rules')); + } else if (deepAccess(config, 'params.rules')) { + timeoutRtdFunctions.handleTimeoutIncrement(reqBidsConfigObj, deepAccess(config, 'params.rules')); callback(); } else { - utils.logInfo('No timeout endpoint or timeout rules found. Exiting timeout rtd module'); + logInfo('No timeout endpoint or timeout rules found. Exiting timeout rtd module'); callback(); } } diff --git a/modules/tpmnBidAdapter.js b/modules/tpmnBidAdapter.js index ec9d30c0e29..006357cd4b9 100644 --- a/modules/tpmnBidAdapter.js +++ b/modules/tpmnBidAdapter.js @@ -1,6 +1,6 @@ /* eslint-disable no-tabs */ import { registerBidder } from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js'; +import { parseUrl, deepAccess } from '../src/utils.js'; import { BANNER } from '../src/mediaTypes.js'; export const ADAPTER_VERSION = '1'; @@ -72,7 +72,7 @@ registerBidder(spec); * Creates site description object */ function createSite(refInfo) { - let url = utils.parseUrl(refInfo.referer); + let url = parseUrl(refInfo.referer); let site = { 'domain': url.hostname, 'page': url.protocol + '://' + url.hostname + url.pathname @@ -102,7 +102,7 @@ function parseSizes(sizes) { } function getBannerSizes(bidRequest) { - return parseSizes(utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes') || bidRequest.sizes); + return parseSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes') || bidRequest.sizes); } function bidToRequest(bid) { diff --git a/modules/trionBidAdapter.js b/modules/trionBidAdapter.js index e9e030ce33f..dd1624f90d7 100644 --- a/modules/trionBidAdapter.js +++ b/modules/trionBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { getBidIdParameter, parseSizesInput, tryAppendQueryString } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import { getStorageManager } from '../src/storageManager.js'; @@ -112,11 +112,11 @@ function getPublisherUrl() { } function buildTrionUrlParams(bid, bidderRequest) { - var pubId = utils.getBidIdParameter('pubId', bid.params); - var sectionId = utils.getBidIdParameter('sectionId', bid.params); + var pubId = getBidIdParameter('pubId', bid.params); + var sectionId = getBidIdParameter('sectionId', bid.params); var url = getPublisherUrl(); var bidSizes = getBidSizesFromBidRequest(bid); - var sizes = utils.parseSizesInput(bidSizes).join(','); + var sizes = parseSizesInput(bidSizes).join(','); var isAutomated = (navigator && navigator.webdriver) ? '1' : '0'; var isHidden = (document.hidden) ? '1' : '0'; var visibilityState = encodeURIComponent(document.visibilityState); @@ -131,10 +131,10 @@ function buildTrionUrlParams(bid, bidderRequest) { setStorageData(BASE_KEY + 'lps', pubId + ':' + sectionId); var trionUrl = ''; - trionUrl = utils.tryAppendQueryString(trionUrl, 'bidId', bid.bidId); - trionUrl = utils.tryAppendQueryString(trionUrl, 'pubId', pubId); - trionUrl = utils.tryAppendQueryString(trionUrl, 'sectionId', sectionId); - trionUrl = utils.tryAppendQueryString(trionUrl, 'vers', '$prebid.version$'); + trionUrl = tryAppendQueryString(trionUrl, 'bidId', bid.bidId); + trionUrl = tryAppendQueryString(trionUrl, 'pubId', pubId); + trionUrl = tryAppendQueryString(trionUrl, 'sectionId', sectionId); + trionUrl = tryAppendQueryString(trionUrl, 'vers', '$prebid.version$'); if (url) { trionUrl += 'url=' + url + '&'; } @@ -142,22 +142,22 @@ function buildTrionUrlParams(bid, bidderRequest) { trionUrl += 'sizes=' + sizes + '&'; } if (intT) { - trionUrl = utils.tryAppendQueryString(trionUrl, 'int_t', encodeURIComponent(intT)); + trionUrl = tryAppendQueryString(trionUrl, 'int_t', encodeURIComponent(intT)); } - trionUrl = utils.tryAppendQueryString(trionUrl, 'tr_wd', isAutomated); - trionUrl = utils.tryAppendQueryString(trionUrl, 'tr_hd', isHidden); - trionUrl = utils.tryAppendQueryString(trionUrl, 'tr_vs', visibilityState); + trionUrl = tryAppendQueryString(trionUrl, 'tr_wd', isAutomated); + trionUrl = tryAppendQueryString(trionUrl, 'tr_hd', isHidden); + trionUrl = tryAppendQueryString(trionUrl, 'tr_vs', visibilityState); if (bidderRequest && bidderRequest.gdprConsent) { var gdpr = bidderRequest.gdprConsent; if (gdpr) { if (gdpr.consentString) { - trionUrl = utils.tryAppendQueryString(trionUrl, 'gdprc', encodeURIComponent(gdpr.consentString)); + trionUrl = tryAppendQueryString(trionUrl, 'gdprc', encodeURIComponent(gdpr.consentString)); } - trionUrl = utils.tryAppendQueryString(trionUrl, 'gdpr', (gdpr.gdprApplies ? 1 : 0)); + trionUrl = tryAppendQueryString(trionUrl, 'gdpr', (gdpr.gdprApplies ? 1 : 0)); } } if (bidderRequest && bidderRequest.uspConsent) { - trionUrl = utils.tryAppendQueryString(trionUrl, 'usp', encodeURIComponent(bidderRequest.uspConsent)); + trionUrl = tryAppendQueryString(trionUrl, 'usp', encodeURIComponent(bidderRequest.uspConsent)); } // remove the trailing "&" if (trionUrl.lastIndexOf('&') === trionUrl.length - 1) { diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 2dc0b069a3c..01df88f62ee 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -1,6 +1,6 @@ +import { tryAppendQueryString, logMessage, isEmpty } from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js'; import { config } from '../src/config.js'; const GVLID = 28; @@ -23,41 +23,41 @@ export const tripleliftAdapterSpec = { let tlCall = STR_ENDPOINT; let data = _buildPostBody(bidRequests); - tlCall = utils.tryAppendQueryString(tlCall, 'lib', 'prebid'); - tlCall = utils.tryAppendQueryString(tlCall, 'v', '$prebid.version$'); + tlCall = tryAppendQueryString(tlCall, 'lib', 'prebid'); + tlCall = tryAppendQueryString(tlCall, 'v', '$prebid.version$'); if (bidderRequest && bidderRequest.refererInfo) { let referrer = bidderRequest.refererInfo.referer; - tlCall = utils.tryAppendQueryString(tlCall, 'referrer', referrer); + tlCall = tryAppendQueryString(tlCall, 'referrer', referrer); } if (bidderRequest && bidderRequest.timeout) { - tlCall = utils.tryAppendQueryString(tlCall, 'tmax', bidderRequest.timeout); + tlCall = tryAppendQueryString(tlCall, 'tmax', bidderRequest.timeout); } if (bidderRequest && bidderRequest.gdprConsent) { if (typeof bidderRequest.gdprConsent.gdprApplies !== 'undefined') { gdprApplies = bidderRequest.gdprConsent.gdprApplies; - tlCall = utils.tryAppendQueryString(tlCall, 'gdpr', gdprApplies.toString()); + tlCall = tryAppendQueryString(tlCall, 'gdpr', gdprApplies.toString()); } if (typeof bidderRequest.gdprConsent.consentString !== 'undefined') { consentString = bidderRequest.gdprConsent.consentString; - tlCall = utils.tryAppendQueryString(tlCall, 'cmp_cs', consentString); + tlCall = tryAppendQueryString(tlCall, 'cmp_cs', consentString); } } if (bidderRequest && bidderRequest.uspConsent) { - tlCall = utils.tryAppendQueryString(tlCall, 'us_privacy', bidderRequest.uspConsent); + tlCall = tryAppendQueryString(tlCall, 'us_privacy', bidderRequest.uspConsent); } if (config.getConfig('coppa') === true) { - tlCall = utils.tryAppendQueryString(tlCall, 'coppa', true); + tlCall = tryAppendQueryString(tlCall, 'coppa', true); } if (tlCall.lastIndexOf('&') === tlCall.length - 1) { tlCall = tlCall.substring(0, tlCall.length - 1); } - utils.logMessage('tlCall request built: ' + tlCall); + logMessage('tlCall request built: ' + tlCall); return { method: 'POST', @@ -81,17 +81,17 @@ export const tripleliftAdapterSpec = { let syncEndpoint = 'https://eb2.3lift.com/sync?'; if (syncType === 'image') { - syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'px', 1); - syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'src', 'prebid'); + syncEndpoint = tryAppendQueryString(syncEndpoint, 'px', 1); + syncEndpoint = tryAppendQueryString(syncEndpoint, 'src', 'prebid'); } if (consentString !== null) { - syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'gdpr', gdprApplies); - syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'cmp_cs', consentString); + syncEndpoint = tryAppendQueryString(syncEndpoint, 'gdpr', gdprApplies); + syncEndpoint = tryAppendQueryString(syncEndpoint, 'cmp_cs', consentString); } if (usPrivacy) { - syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'us_privacy', usPrivacy); + syncEndpoint = tryAppendQueryString(syncEndpoint, 'us_privacy', usPrivacy); } return [{ @@ -124,7 +124,7 @@ function _buildPostBody(bidRequests) { } else if (bidRequest.mediaTypes.banner) { imp.banner = { format: _sizes(bidRequest.sizes) }; }; - if (!utils.isEmpty(bidRequest.ortb2Imp)) { + if (!isEmpty(bidRequest.ortb2Imp)) { imp.fpd = _getAdUnitFpd(bidRequest.ortb2Imp); } return imp; @@ -145,7 +145,7 @@ function _buildPostBody(bidRequests) { let ext = _getExt(schain, globalFpd); - if (!utils.isEmpty(ext)) { + if (!isEmpty(ext)) { data.ext = ext; } return data; @@ -200,10 +200,10 @@ function _getGlobalFpd() { _addEntries(context, fpdContext); _addEntries(user, fpdUser); - if (!utils.isEmpty(context)) { + if (!isEmpty(context)) { fpd.context = context; } - if (!utils.isEmpty(user)) { + if (!isEmpty(user)) { fpd.user = user; } return fpd; @@ -215,7 +215,7 @@ function _getAdUnitFpd(adUnitFpd) { _addEntries(context, adUnitFpd.ext); - if (!utils.isEmpty(context)) { + if (!isEmpty(context)) { fpd.context = context; } @@ -223,7 +223,7 @@ function _getAdUnitFpd(adUnitFpd) { } function _addEntries(target, source) { - if (!utils.isEmpty(source)) { + if (!isEmpty(source)) { Object.keys(source).forEach(key => { if (source[key] != null) { target[key] = source[key]; @@ -234,10 +234,10 @@ function _addEntries(target, source) { function _getExt(schain, fpd) { let ext = {}; - if (!utils.isEmpty(schain)) { + if (!isEmpty(schain)) { ext.schain = { ...schain }; } - if (!utils.isEmpty(fpd)) { + if (!isEmpty(fpd)) { ext.fpd = { ...fpd }; } return ext; diff --git a/modules/truereachBidAdapter.js b/modules/truereachBidAdapter.js index fadc952b5fb..a0244e3a349 100755 --- a/modules/truereachBidAdapter.js +++ b/modules/truereachBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { deepAccess, getUniqueIdentifierStr } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; import { BANNER } from '../src/mediaTypes.js'; @@ -13,7 +13,7 @@ export const spec = { isBidRequestValid: function (bidRequest) { return (bidRequest.params.site_id && bidRequest.params.bidfloor && - utils.deepAccess(bidRequest, 'mediaTypes.banner') && (utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes.length') > 0)); + deepAccess(bidRequest, 'mediaTypes.banner') && (deepAccess(bidRequest, 'mediaTypes.banner.sizes.length') > 0)); }, buildRequests: function (validBidRequests, bidderRequest) { @@ -23,7 +23,7 @@ export const spec = { let queryParams = buildCommonQueryParamsFromBids(validBidRequests, bidderRequest); - let siteId = utils.deepAccess(validBidRequests[0], 'params.site_id'); + let siteId = deepAccess(validBidRequests[0], 'params.site_id'); let url = BIDDER_URL + siteId + '?hb=1&transactionId=' + validBidRequests[0].transactionId; @@ -121,7 +121,7 @@ function buildCommonQueryParamsFromBids(validBidRequests, bidderRequest) { let page = window.location.host + window.location.pathname + location.search + location.hash; let defaultParams = { - id: utils.getUniqueIdentifierStr(), + id: getUniqueIdentifierStr(), imp: [ { id: validBidRequests[0].bidId, diff --git a/modules/trustxBidAdapter.js b/modules/trustxBidAdapter.js index d99dbf0cd87..bd7c5c9a5c3 100644 --- a/modules/trustxBidAdapter.js +++ b/modules/trustxBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { isEmpty, deepAccess, logError, logWarn, parseGPTSingleSizeArrayToRtbSize } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import { Renderer } from '../src/Renderer.js'; import { VIDEO, BANNER } from '../src/mediaTypes.js'; @@ -102,7 +102,7 @@ export const spec = { } }; - if (!utils.isEmpty(keywords)) { + if (!isEmpty(keywords)) { if (!pageKeywords) { pageKeywords = keywords; } @@ -188,8 +188,8 @@ export const spec = { request.user = user; } - const userKeywords = utils.deepAccess(config.getConfig('ortb2.user'), 'keywords') || null; - const siteKeywords = utils.deepAccess(config.getConfig('ortb2.site'), 'keywords') || null; + const userKeywords = deepAccess(config.getConfig('ortb2.user'), 'keywords') || null; + const siteKeywords = deepAccess(config.getConfig('ortb2.site'), 'keywords') || null; if (userKeywords) { pageKeywords = pageKeywords || {}; @@ -267,7 +267,7 @@ export const spec = { _addBidResponse(_getBidFromResponse(respItem), bidRequest, bidResponses, RendererConst); }); } - if (errorMessage) utils.logError(errorMessage); + if (errorMessage) logError(errorMessage); return bidResponses; }, getUserSyncs: function(syncOptions, responses, gdprConsent, uspConsent) { @@ -302,11 +302,11 @@ export const spec = { function _getBidFromResponse(respItem) { if (!respItem) { - utils.logError(LOG_ERROR_MESS.emptySeatbid); + logError(LOG_ERROR_MESS.emptySeatbid); } else if (!respItem.bid) { - utils.logError(LOG_ERROR_MESS.hasNoArrayOfBids + JSON.stringify(respItem)); + logError(LOG_ERROR_MESS.hasNoArrayOfBids + JSON.stringify(respItem)); } else if (!respItem.bid[0]) { - utils.logError(LOG_ERROR_MESS.noBid); + logError(LOG_ERROR_MESS.noBid); } return respItem && respItem.bid && respItem.bid[0]; } @@ -356,7 +356,7 @@ function _addBidResponse(serverBid, bidRequest, bidResponses, RendererConst) { } } if (errorMessage) { - utils.logError(errorMessage); + logError(errorMessage); } } @@ -379,7 +379,7 @@ function createRenderer (bid, rendererParams, RendererConst) { try { rendererInst.setRender(outstreamRender); } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); + logWarn('Prebid Error calling setRender on renderer', err); } return rendererInst; @@ -390,7 +390,7 @@ function createVideoRequest(bid, mediaType) { const size = (playerSize || bid.sizes || [])[0]; if (!size) return; - let result = utils.parseGPTSingleSizeArrayToRtbSize(size); + let result = parseGPTSingleSizeArrayToRtbSize(size); if (mimes) { result.mimes = mimes; @@ -412,8 +412,8 @@ function createBannerRequest(bid, mediaType) { const sizes = mediaType.sizes || bid.sizes; if (!sizes || !sizes.length) return; - let format = sizes.map((size) => utils.parseGPTSingleSizeArrayToRtbSize(size)); - let result = utils.parseGPTSingleSizeArrayToRtbSize(sizes[0]); + let format = sizes.map((size) => parseGPTSingleSizeArrayToRtbSize(size)); + let result = parseGPTSingleSizeArrayToRtbSize(sizes[0]); if (format.length) { result.format = format diff --git a/modules/ucfunnelBidAdapter.js b/modules/ucfunnelBidAdapter.js index 69cbbc697fc..8b85f1ebad3 100644 --- a/modules/ucfunnelBidAdapter.js +++ b/modules/ucfunnelBidAdapter.js @@ -1,8 +1,8 @@ +import { generateUUID, _each } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO, NATIVE} from '../src/mediaTypes.js'; import { getStorageManager } from '../src/storageManager.js'; import { config } from '../src/config.js'; -import * as utils from '../src/utils.js'; const storage = getStorageManager(); const COOKIE_NAME = 'ucf_uid'; const VER = 'ADGENT_PREBID-2018011501'; @@ -283,7 +283,7 @@ function getRequestData(bid, bidderRequest) { ucfUid = storage.getCookie(COOKIE_NAME); bidData.ucfUid = ucfUid; } else { - ucfUid = utils.generateUUID(); + ucfUid = generateUUID(); bidData.ucfUid = ucfUid; storage.setCookie(COOKIE_NAME, ucfUid); } @@ -335,7 +335,7 @@ function getRequestData(bid, bidderRequest) { function addUserId(bidData, userId) { bidData['eids'] = ''; - utils._each(userId, (userIdObjectOrValue, userIdProviderKey) => { + _each(userId, (userIdObjectOrValue, userIdProviderKey) => { switch (userIdProviderKey) { case 'haloId': if (userIdObjectOrValue.haloId) { diff --git a/modules/uid2IdSystem.js b/modules/uid2IdSystem.js index 053b57cb76d..c0cd9166784 100644 --- a/modules/uid2IdSystem.js +++ b/modules/uid2IdSystem.js @@ -5,7 +5,7 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils.js' +import { logInfo } from '../src/utils.js'; import {submodule} from '../src/hook.js'; import { getStorageManager } from '../src/storageManager.js'; @@ -28,11 +28,11 @@ function getStorage() { const storage = getStorage(); -const logInfo = createLogInfo(LOG_PRE_FIX); +const _logInfo = createLogInfo(LOG_PRE_FIX); function createLogInfo(prefix) { return function (...strings) { - utils.logInfo(prefix + ' ', ...strings); + logInfo(prefix + ' ', ...strings); } } @@ -48,7 +48,7 @@ function encodeId(value) { id: value } result.uid2 = bidIds; - logInfo('Decoded value ' + JSON.stringify(result)); + _logInfo('Decoded value ' + JSON.stringify(result)); return result; } return undefined; @@ -85,9 +85,9 @@ export const uid2IdSubmodule = { * @returns {uid2Id} */ getId(config, consentData) { - logInfo('Creating UID 2.0'); + _logInfo('Creating UID 2.0'); let value = readCookie() || readFromLocalStorage(); - logInfo('The advertising token: ' + value); + _logInfo('The advertising token: ' + value); return {id: value} }, diff --git a/modules/underdogmediaBidAdapter.js b/modules/underdogmediaBidAdapter.js index 6268774bc12..2ca4de7a555 100644 --- a/modules/underdogmediaBidAdapter.js +++ b/modules/underdogmediaBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { logMessage, flatten, parseSizesInput } from '../src/utils.js'; import { config } from '../src/config.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'underdogmedia'; @@ -7,7 +7,7 @@ const UDM_VENDOR_ID = '159'; const prebidVersion = '$prebid.version$'; let USER_SYNCED = false; -utils.logMessage(`Initializing UDM Adapter. PBJS Version: ${prebidVersion} with adapter version: ${UDM_ADAPTER_VERSION} Updated 20191028`); +logMessage(`Initializing UDM Adapter. PBJS Version: ${prebidVersion} with adapter version: ${UDM_ADAPTER_VERSION} Updated 20191028`); // helper function for testing user syncs export function resetUserSync() { @@ -29,7 +29,7 @@ export const spec = { validBidRequests.forEach(bidParam => { let bidParamSizes = bidParam.mediaTypes && bidParam.mediaTypes.banner && bidParam.mediaTypes.banner.sizes ? bidParam.mediaTypes.banner.sizes : bidParam.sizes; - sizes = utils.flatten(sizes, utils.parseSizesInput(bidParamSizes)); + sizes = flatten(sizes, parseSizesInput(bidParamSizes)); siteId = bidParam.params.siteId; }); @@ -99,7 +99,7 @@ export const spec = { var sizeNotFound = true; const bidParamSizes = bidParam.mediaTypes && bidParam.mediaTypes.banner && bidParam.mediaTypes.banner.sizes ? bidParam.mediaTypes.banner.sizes : bidParam.sizes - utils.parseSizesInput(bidParamSizes).forEach(size => { + parseSizesInput(bidParamSizes).forEach(size => { if (size === mid.width + 'x' + mid.height) { sizeNotFound = false; } diff --git a/modules/unicornBidAdapter.js b/modules/unicornBidAdapter.js index e74c4425626..d89866ef379 100644 --- a/modules/unicornBidAdapter.js +++ b/modules/unicornBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { logInfo, deepAccess, generateUUID } from '../src/utils.js'; import {BANNER} from '../src/mediaTypes.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {getStorageManager} from '../src/storageManager.js'; @@ -39,8 +39,8 @@ export const buildRequests = (validBidRequests, bidderRequest) => { * @returns {string} */ function buildOpenRtbBidRequestPayload(validBidRequests, bidderRequest) { - utils.logInfo('[UNICORN] buildOpenRtbBidRequestPayload.validBidRequests:', validBidRequests); - utils.logInfo('[UNICORN] buildOpenRtbBidRequestPayload.bidderRequest:', bidderRequest); + logInfo('[UNICORN] buildOpenRtbBidRequestPayload.validBidRequests:', validBidRequests); + logInfo('[UNICORN] buildOpenRtbBidRequestPayload.bidderRequest:', bidderRequest); const imp = validBidRequests.map(br => { return { id: br.bidId, @@ -49,7 +49,7 @@ function buildOpenRtbBidRequestPayload(validBidRequests, bidderRequest) { w: br.sizes[0][0], h: br.sizes[0][1] }, - tagid: utils.deepAccess(br, 'params.placementId') || br.adUnitCode, + tagid: deepAccess(br, 'params.placementId') || br.adUnitCode, secure: 1, bidfloor: parseFloat(0) }; @@ -60,9 +60,9 @@ function buildOpenRtbBidRequestPayload(validBidRequests, bidderRequest) { imp, cur: UNICORN_DEFAULT_CURRENCY, site: { - id: utils.deepAccess(validBidRequests[0], 'params.mediaId') || '', + id: deepAccess(validBidRequests[0], 'params.mediaId') || '', publisher: { - id: utils.deepAccess(validBidRequests[0], 'params.publisherId') || 0 + id: deepAccess(validBidRequests[0], 'params.publisherId') || 0 }, domain: window.location.hostname, page: window.location.href, @@ -75,7 +75,7 @@ function buildOpenRtbBidRequestPayload(validBidRequests, bidderRequest) { user: { id: getUid() }, - bcat: utils.deepAccess(validBidRequests[0], 'params.bcat') || [], + bcat: deepAccess(validBidRequests[0], 'params.bcat') || [], source: { ext: { stype: 'prebid_uncn', @@ -84,16 +84,16 @@ function buildOpenRtbBidRequestPayload(validBidRequests, bidderRequest) { } }, ext: { - accountId: utils.deepAccess(validBidRequests[0], 'params.accountId') + accountId: deepAccess(validBidRequests[0], 'params.accountId') } }; - utils.logInfo('[UNICORN] OpenRTB Formatted Request:', request); + logInfo('[UNICORN] OpenRTB Formatted Request:', request); return JSON.stringify(request); } const interpretResponse = (serverResponse, request) => { - utils.logInfo('[UNICORN] interpretResponse.serverResponse:', serverResponse); - utils.logInfo('[UNICORN] interpretResponse.request:', request); + logInfo('[UNICORN] interpretResponse.serverResponse:', serverResponse); + logInfo('[UNICORN] interpretResponse.request:', request); const res = serverResponse.body; var bids = [] if (res) { @@ -119,7 +119,7 @@ const interpretResponse = (serverResponse, request) => { }) }); } - utils.logInfo('[UNICORN] interpretResponse bids:', bids); + logInfo('[UNICORN] interpretResponse bids:', bids); return bids; }; @@ -132,7 +132,7 @@ const getUid = () => { return JSON.parse(ck)['uid']; } else { const newCk = { - uid: utils.generateUUID() + uid: generateUUID() }; const expireIn = new Date(Date.now() + 24 * 60 * 60 * 10000).toUTCString(); storage.setCookie(UNICORN_PB_COOKIE_KEY, JSON.stringify(newCk), expireIn); diff --git a/modules/unifiedIdSystem.js b/modules/unifiedIdSystem.js index bc033f37992..8ec5fcd3f90 100644 --- a/modules/unifiedIdSystem.js +++ b/modules/unifiedIdSystem.js @@ -5,7 +5,7 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils.js' +import { logError } from '../src/utils.js'; import {ajax} from '../src/ajax.js'; import {submodule} from '../src/hook.js' @@ -40,7 +40,7 @@ export const unifiedIdSubmodule = { getId(config) { const configParams = (config && config.params) || {}; if (!configParams || (typeof configParams.partner !== 'string' && typeof configParams.url !== 'string')) { - utils.logError('User ID - unifiedId submodule requires either partner or url to be defined'); + logError('User ID - unifiedId submodule requires either partner or url to be defined'); return; } // use protocol relative urls for http or https @@ -54,13 +54,13 @@ export const unifiedIdSubmodule = { try { responseObj = JSON.parse(response); } catch (error) { - utils.logError(error); + logError(error); } } callback(responseObj); }, error: error => { - utils.logError(`${MODULE_NAME}: ID fetch encountered an error`, error); + logError(`${MODULE_NAME}: ID fetch encountered an error`, error); callback(); } }; diff --git a/modules/unrulyBidAdapter.js b/modules/unrulyBidAdapter.js index d04192acf15..99fbe63aeb4 100644 --- a/modules/unrulyBidAdapter.js +++ b/modules/unrulyBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js' +import { deepAccess, logError } from '../src/utils.js'; import {Renderer} from '../src/Renderer.js' import {registerBidder} from '../src/adapters/bidderFactory.js' import {VIDEO, BANNER} from '../src/mediaTypes.js' @@ -41,7 +41,7 @@ const addBidFloorInfo = (validBid) => { }; const RemoveDuplicateSizes = (validBid) => { - let bannerMediaType = utils.deepAccess(validBid, 'mediaTypes.banner'); + let bannerMediaType = deepAccess(validBid, 'mediaTypes.banner'); if (bannerMediaType) { let seenSizes = {}; let newSizesArray = []; @@ -87,12 +87,12 @@ const handleBidResponseByMediaType = (bids) => { bids.forEach((bid) => { let parsedBidResponse; - let bidMediaType = utils.deepAccess(bid, 'meta.mediaType'); + let bidMediaType = deepAccess(bid, 'meta.mediaType'); if (bidMediaType && bidMediaType.toLowerCase() === 'banner') { bid.mediaType = BANNER; parsedBidResponse = handleBannerBid(bid); } else if (bidMediaType && bidMediaType.toLowerCase() === 'video') { - let context = utils.deepAccess(bid, 'meta.videoContext'); + let context = deepAccess(bid, 'meta.videoContext'); bid.mediaType = VIDEO; if (context === 'instream') { parsedBidResponse = handleInStreamBid(bid); @@ -111,7 +111,7 @@ const handleBidResponseByMediaType = (bids) => { const handleBannerBid = (bid) => { if (!bid.ad) { - utils.logError(new Error('UnrulyBidAdapter: Missing ad config.')); + logError(new Error('UnrulyBidAdapter: Missing ad config.')); return; } @@ -120,7 +120,7 @@ const handleBannerBid = (bid) => { const handleInStreamBid = (bid) => { if (!(bid.vastUrl || bid.vastXml)) { - utils.logError(new Error('UnrulyBidAdapter: Missing vastUrl or vastXml config.')); + logError(new Error('UnrulyBidAdapter: Missing vastUrl or vastXml config.')); return; } @@ -128,19 +128,19 @@ const handleInStreamBid = (bid) => { }; const handleOutStreamBid = (bid) => { - const hasConfig = !!utils.deepAccess(bid, 'ext.renderer.config'); - const hasSiteId = !!utils.deepAccess(bid, 'ext.renderer.config.siteId'); + const hasConfig = !!deepAccess(bid, 'ext.renderer.config'); + const hasSiteId = !!deepAccess(bid, 'ext.renderer.config.siteId'); if (!hasConfig) { - utils.logError(new Error('UnrulyBidAdapter: Missing renderer config.')); + logError(new Error('UnrulyBidAdapter: Missing renderer config.')); return; } if (!hasSiteId) { - utils.logError(new Error('UnrulyBidAdapter: Missing renderer siteId.')); + logError(new Error('UnrulyBidAdapter: Missing renderer siteId.')); return; } - const exchangeRenderer = utils.deepAccess(bid, 'ext.renderer'); + const exchangeRenderer = deepAccess(bid, 'ext.renderer'); configureUniversalTag(exchangeRenderer, bid.requestId); configureRendererQueue(); @@ -152,7 +152,7 @@ const handleOutStreamBid = (bid) => { bid, { renderer: rendererInstance, - adUnitCode: utils.deepAccess(bid, 'ext.adUnitCode') + adUnitCode: deepAccess(bid, 'ext.adUnitCode') } ); @@ -165,8 +165,8 @@ const handleOutStreamBid = (bid) => { }; const isMediaTypesValid = (bid) => { - const mediaTypeVideoData = utils.deepAccess(bid, 'mediaTypes.video'); - const mediaTypeBannerData = utils.deepAccess(bid, 'mediaTypes.banner'); + const mediaTypeVideoData = deepAccess(bid, 'mediaTypes.video'); + const mediaTypeBannerData = deepAccess(bid, 'mediaTypes.banner'); let isValid = !!(mediaTypeVideoData || mediaTypeBannerData); if (isValid && mediaTypeVideoData) { isValid = isVideoMediaTypeValid(mediaTypeVideoData); @@ -194,7 +194,7 @@ export const adapter = { code: 'unruly', supportedMediaTypes: [VIDEO, BANNER], isBidRequestValid: function (bid) { - let siteId = utils.deepAccess(bid, 'params.siteId'); + let siteId = deepAccess(bid, 'params.siteId'); let isBidValid = siteId && isMediaTypesValid(bid); return !!isBidValid; }, @@ -202,7 +202,7 @@ export const adapter = { buildRequests: function (validBidRequests, bidderRequest) { let endPoint = 'https://targeting.unrulymedia.com/unruly_prebid'; if (validBidRequests[0]) { - endPoint = utils.deepAccess(validBidRequests[0], 'params.endpoint') || endPoint; + endPoint = deepAccess(validBidRequests[0], 'params.endpoint') || endPoint; } const url = endPoint; diff --git a/modules/vdoaiBidAdapter.js b/modules/vdoaiBidAdapter.js index 4bf5a27c002..40e3b3322a7 100644 --- a/modules/vdoaiBidAdapter.js +++ b/modules/vdoaiBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { getAdUnitSizes } from '../src/utils.js'; import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; @@ -32,7 +32,7 @@ export const spec = { } return validBidRequests.map(bidRequest => { - const sizes = utils.getAdUnitSizes(bidRequest); + const sizes = getAdUnitSizes(bidRequest); const payload = { placementId: bidRequest.params.placementId, sizes: sizes, diff --git a/modules/verizonMediaIdSystem.js b/modules/verizonMediaIdSystem.js index ca395087d2d..280a6c47894 100644 --- a/modules/verizonMediaIdSystem.js +++ b/modules/verizonMediaIdSystem.js @@ -7,7 +7,7 @@ import {ajax} from '../src/ajax.js'; import {submodule} from '../src/hook.js'; -import * as utils from '../src/utils.js'; +import { logError, formatQS } from '../src/utils.js'; import includes from 'core-js-pure/features/array/includes.js'; const MODULE_NAME = 'verizonMediaId'; @@ -51,7 +51,7 @@ export const verizonMediaIdSubmodule = { const params = config.params || {}; if (!params || typeof params.he !== 'string' || (typeof params.pixelId === 'undefined' && typeof params.endpoint === 'undefined')) { - utils.logError('The verizonMediaId submodule requires the \'he\' and \'pixelId\' parameters to be defined.'); + logError('The verizonMediaId submodule requires the \'he\' and \'pixelId\' parameters to be defined.'); return; } @@ -75,18 +75,18 @@ export const verizonMediaIdSubmodule = { try { responseObj = JSON.parse(response); } catch (error) { - utils.logError(error); + logError(error); } } callback(responseObj); }, error: error => { - utils.logError(`${MODULE_NAME}: ID fetch encountered an error`, error); + logError(`${MODULE_NAME}: ID fetch encountered an error`, error); callback(); } }; const endpoint = VMCID_ENDPOINT.replace(PLACEHOLDER, params.pixelId); - let url = `${params.endpoint || endpoint}?${utils.formatQS(data)}`; + let url = `${params.endpoint || endpoint}?${formatQS(data)}`; verizonMediaIdSubmodule.getAjaxFn()(url, callbacks, null, {method: 'GET', withCredentials: true}); }; return {callback: resp}; diff --git a/modules/vidazooBidAdapter.js b/modules/vidazooBidAdapter.js index 3fb94870d3f..0e7b4ee63b2 100644 --- a/modules/vidazooBidAdapter.js +++ b/modules/vidazooBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { _each, deepAccess, parseSizesInput } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER } from '../src/mediaTypes.js'; import { getStorageManager } from '../src/storageManager.js'; @@ -94,7 +94,7 @@ function buildRequest(bid, topWindowUrl, sizes, bidderRequest) { data: data }; - utils._each(ext, (value, key) => { + _each(ext, (value, key) => { dto.data['ext.' + key] = value; }); @@ -103,13 +103,13 @@ function buildRequest(bid, topWindowUrl, sizes, bidderRequest) { function appendUserIdsToRequestPayload(payloadRef, userIds) { let key; - utils._each(userIds, (userId, idSystemProviderName) => { + _each(userIds, (userId, idSystemProviderName) => { if (SUPPORTED_ID_SYSTEMS[idSystemProviderName]) { key = `uid.${idSystemProviderName}`; switch (idSystemProviderName) { case 'digitrustid': - payloadRef[key] = utils.deepAccess(userId, 'data.id'); + payloadRef[key] = deepAccess(userId, 'data.id'); break; case 'lipb': payloadRef[key] = userId.lipbid; @@ -131,7 +131,7 @@ function buildRequests(validBidRequests, bidderRequest) { const topWindowUrl = bidderRequest.refererInfo.referer; const requests = []; validBidRequests.forEach(validBidRequest => { - const sizes = utils.parseSizesInput(validBidRequest.sizes); + const sizes = parseSizesInput(validBidRequest.sizes); const request = buildRequest(validBidRequest, topWindowUrl, sizes, bidderRequest); requests.push(request); });