diff --git a/modules/instreamTracking.js b/modules/instreamTracking.js index 68bb4be79de..40a6ecb1939 100644 --- a/modules/instreamTracking.js +++ b/modules/instreamTracking.js @@ -1,8 +1,8 @@ +import { deepClone, getBidRequest, deepAccess } from '../src/utils.js'; import { config } from '../src/config.js'; import { auctionManager } from '../src/auctionManager.js'; import { INSTREAM } from '../src/video.js'; import * as events from '../src/events.js'; -import * as utils from '../src/utils.js'; import { BID_STATUS, EVENTS, TARGETING_KEYS } from '../src/constants.json'; const {CACHE_ID, UUID} = TARGETING_KEYS; @@ -17,7 +17,7 @@ const INSTREAM_TRACKING_DEFAULT_CONFIG = { // Set instreamTracking default values config.setDefaults({ - 'instreamTracking': utils.deepClone(INSTREAM_TRACKING_DEFAULT_CONFIG) + 'instreamTracking': deepClone(INSTREAM_TRACKING_DEFAULT_CONFIG) }); const whitelistedResources = /video|fetch|xmlhttprequest|other/; @@ -50,8 +50,8 @@ export function trackInstreamDeliveredImpressions({adUnits, bidsReceived, bidder // filter for video bids const instreamBids = bidsReceived.filter(bid => { - const bidderRequest = utils.getBidRequest(bid.requestId, bidderRequests); - return bidderRequest && utils.deepAccess(bidderRequest, 'mediaTypes.video.context') === INSTREAM && bid.videoCacheKey; + const bidderRequest = getBidRequest(bid.requestId, bidderRequests); + return bidderRequest && deepAccess(bidderRequest, 'mediaTypes.video.context') === INSTREAM && bid.videoCacheKey; }); if (!instreamBids.length) { return false; @@ -60,7 +60,7 @@ export function trackInstreamDeliveredImpressions({adUnits, bidsReceived, bidder // find unique instream ad units const instreamAdUnitMap = {}; adUnits.forEach(adUnit => { - if (!instreamAdUnitMap[adUnit.code] && utils.deepAccess(adUnit, 'mediaTypes.video.context') === INSTREAM) { + if (!instreamAdUnitMap[adUnit.code] && deepAccess(adUnit, 'mediaTypes.video.context') === INSTREAM) { instreamAdUnitMap[adUnit.code] = true; } }); diff --git a/modules/integr8BidAdapter.js b/modules/integr8BidAdapter.js index c5415951155..321c3c4c1ab 100644 --- a/modules/integr8BidAdapter.js +++ b/modules/integr8BidAdapter.js @@ -1,7 +1,7 @@ +import { deepAccess, isFn, isPlainObject } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { getStorageManager } from '../src/storageManager.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; const BIDDER_CODE = 'integr8'; const ENDPOINT_URL = 'https://integr8.central.gjirafa.tech/bid'; @@ -62,7 +62,7 @@ export const spec = { placementId: bidRequest.params.placementId, bidid: bidRequest.bidId, count: bidRequest.params.count, - skipTime: utils.deepAccess(bidRequest, 'mediaTypes.video.skipafter', bidRequest.params.skipTime), + skipTime: deepAccess(bidRequest, 'mediaTypes.video.skipafter', bidRequest.params.skipTime), floor: getBidFloor(bidRequest) }; }); @@ -130,7 +130,7 @@ function generateSizeParam(sizes) { } export function getBidFloor(bid) { - if (!utils.isFn(bid.getFloor)) { + if (!isFn(bid.getFloor)) { return null; } @@ -140,7 +140,7 @@ export function getBidFloor(bid) { size: '*' }); - if (utils.isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'EUR') { + if (isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'EUR') { return floor.floor; } diff --git a/modules/intentIqIdSystem.js b/modules/intentIqIdSystem.js index e12a765c086..2092f9a185a 100644 --- a/modules/intentIqIdSystem.js +++ b/modules/intentIqIdSystem.js @@ -5,7 +5,7 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils.js' +import { logError, logInfo } from '../src/utils.js'; import {ajax} from '../src/ajax.js'; import {submodule} from '../src/hook.js' import {getStorageManager} from '../src/storageManager.js'; @@ -47,7 +47,7 @@ export function readData(key) { return storage.getCookie(key); } } catch (error) { - utils.logError(error); + logError(error); } } @@ -59,7 +59,7 @@ export function readData(key) { */ function storeData(key, value) { try { - utils.logInfo(MODULE_NAME + ': storing data: key=' + key + ' value=' + value); + logInfo(MODULE_NAME + ': storing data: key=' + key + ' value=' + value); if (value) { if (storage.hasLocalStorage()) { @@ -71,7 +71,7 @@ function storeData(key, value) { } } } catch (error) { - utils.logError(error); + logError(error); } } @@ -84,7 +84,7 @@ function tryParse(data) { try { return JSON.parse(data); } catch (err) { - utils.logError(err); + logError(err); return null; } } @@ -114,7 +114,7 @@ export const intentIqIdSubmodule = { getId(config) { const configParams = (config && config.params) || {}; if (!configParams || typeof configParams.partner !== 'number') { - utils.logError('User ID - intentIqId submodule requires a valid partner to be defined'); + logError('User ID - intentIqId submodule requires a valid partner to be defined'); return; } @@ -155,7 +155,7 @@ export const intentIqIdSubmodule = { } }, 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/interactiveOffersBidAdapter.js b/modules/interactiveOffersBidAdapter.js index 958c671e4b9..c1757198eca 100644 --- a/modules/interactiveOffersBidAdapter.js +++ b/modules/interactiveOffersBidAdapter.js @@ -1,7 +1,7 @@ +import { logWarn, isNumber } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; -import * as utils from '../src/utils.js'; const BIDDER_CODE = 'interactiveOffers'; const ENDPOINT = 'https://prebid.ioadx.com/bidRequest/?partnerId='; @@ -36,15 +36,15 @@ export const spec = { let ret = true; if (bid && bid.params) { if (!bid.params.partnerId) { - utils.logWarn('partnerId must be a valid ID'); + logWarn('partnerId must be a valid ID'); ret = false; } - if (bid.params.tmax && !utils.isNumber(bid.params.tmax)) { - utils.logWarn('tmax must be a valid numeric ID'); + if (bid.params.tmax && !isNumber(bid.params.tmax)) { + logWarn('tmax must be a valid numeric ID'); ret = false; } } else { - utils.logWarn('invalid request'); + logWarn('invalid request'); ret = false; } return ret; diff --git a/modules/invibesBidAdapter.js b/modules/invibesBidAdapter.js index 0441f712a2f..75da1509f19 100644 --- a/modules/invibesBidAdapter.js +++ b/modules/invibesBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { logInfo } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {getStorageManager} from '../src/storageManager.js'; @@ -155,12 +155,12 @@ function buildRequest(bidRequests, bidderRequest) { function handleResponse(responseObj, bidRequests) { if (bidRequests == null || bidRequests.length === 0) { - utils.logInfo('Invibes Adapter - No bids have been requested'); + logInfo('Invibes Adapter - No bids have been requested'); return []; } if (!responseObj) { - utils.logInfo('Invibes Adapter - Bid response is empty'); + logInfo('Invibes Adapter - Bid response is empty'); return []; } @@ -171,7 +171,7 @@ function handleResponse(responseObj, bidRequests) { if (responseObj.MultipositionEnabled === true) { invibes.bidResponse.AdPlacements = invibes.bidResponse.AdPlacements.concat(responseObj.AdPlacements); } else { - utils.logInfo('Invibes Adapter - Bid response already received. Invibes only responds to one bid request per user visit'); + logInfo('Invibes Adapter - Bid response already received. Invibes only responds to one bid request per user visit'); return []; } } else { @@ -183,7 +183,7 @@ function handleResponse(responseObj, bidRequests) { let bidRequest = bidRequests[i]; if (invibes.placementBids.indexOf(bidRequest.params.placementId) > -1) { - utils.logInfo('Invibes Adapter - Placement was previously bid on ' + bidRequest.params.placementId); + logInfo('Invibes Adapter - Placement was previously bid on ' + bidRequest.params.placementId); continue; } @@ -215,7 +215,7 @@ function handleResponse(responseObj, bidRequests) { function createBid(bidRequest, requestPlacement, multipositionEnabled) { if (requestPlacement === null || requestPlacement.BidModel === null) { - utils.logInfo('Invibes Adapter - Placement not configured for bidding ' + bidRequest.params.placementId); + logInfo('Invibes Adapter - Placement not configured for bidding ' + bidRequest.params.placementId); return null; } @@ -223,10 +223,10 @@ function createBid(bidRequest, requestPlacement, multipositionEnabled) { let ads = requestPlacement.Ads; if (!Array.isArray(ads) || ads.length < 1) { if (requestPlacement.AdReason != null) { - utils.logInfo('Invibes Adapter - No ads ' + requestPlacement.AdReason); + logInfo('Invibes Adapter - No ads ' + requestPlacement.AdReason); } - utils.logInfo('Invibes Adapter - No ads available'); + logInfo('Invibes Adapter - No ads available'); return null; } @@ -241,7 +241,7 @@ function createBid(bidRequest, requestPlacement, multipositionEnabled) { }); if (blacklistsPushedCids) { - utils.logInfo('Invibes Adapter - Ad blacklists pushed ids'); + logInfo('Invibes Adapter - Ad blacklists pushed ids'); return null; } } @@ -250,7 +250,7 @@ function createBid(bidRequest, requestPlacement, multipositionEnabled) { return invibes.pushedCids[pushedCid].indexOf(ad.Cid) > -1; }); if (isBlacklisted) { - utils.logInfo('Invibes Adapter - Ad is blacklisted'); + logInfo('Invibes Adapter - Ad is blacklisted'); return null; } } @@ -258,7 +258,7 @@ function createBid(bidRequest, requestPlacement, multipositionEnabled) { invibes.pushedCids[ad.Cid] = ad.Blcids || []; const now = Date.now(); - utils.logInfo('Bid auction started at ' + bidModel.AuctionStartTime + ' . Invibes registered the bid at ' + now + ' ; bid request took a total of ' + (now - bidModel.AuctionStartTime) + ' ms.'); + logInfo('Bid auction started at ' + bidModel.AuctionStartTime + ' . Invibes registered the bid at ' + now + ' ; bid request took a total of ' + (now - bidModel.AuctionStartTime) + ' ms.'); return { requestId: bidRequest.bidId, diff --git a/modules/invisiblyAnalyticsAdapter.js b/modules/invisiblyAnalyticsAdapter.js index d4fd3831210..5d15ae55bfc 100644 --- a/modules/invisiblyAnalyticsAdapter.js +++ b/modules/invisiblyAnalyticsAdapter.js @@ -5,11 +5,11 @@ import { ajaxBuilder } from '../src/ajax.js'; import adapter from '../src/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; +import { generateUUID, logInfo } from '../src/utils.js'; + const DEFAULT_EVENT_URL = 'https://api.pymx5.com/v1/' + 'sites/events'; const analyticsType = 'endpoint'; const analyticsName = 'Invisibly Analytics Adapter:'; - -const utils = require('../src/utils.js'); const CONSTANTS = require('../src/constants.json'); const ajax = ajaxBuilder(0); @@ -33,7 +33,7 @@ const { } = CONSTANTS; const _VERSION = 1; -const _pageViewId = utils.generateUUID(); +const _pageViewId = generateUUID(); let initOptions = null; let _startAuction = 0; let _bidRequestTimeout = 0; @@ -122,7 +122,7 @@ function flush() { }; ajax( initOptions.url, - () => utils.logInfo(`${analyticsName} sent events batch`), + () => logInfo(`${analyticsName} sent events batch`), JSON.stringify(payload), { contentType: 'application/json', @@ -206,7 +206,7 @@ function handleEvent(eventType, eventArgs) { function sendEvent(event) { _eventQueue.push(event); - utils.logInfo(`${analyticsName}Event ${event.eventType}:`, event); + logInfo(`${analyticsName}Event ${event.eventType}:`, event); if (event.eventType === AUCTION_END) { flush(); diff --git a/modules/iqmBidAdapter.js b/modules/iqmBidAdapter.js index e7599fd54c0..75854d39fd5 100644 --- a/modules/iqmBidAdapter.js +++ b/modules/iqmBidAdapter.js @@ -1,6 +1,6 @@ +import { deepAccess, getBidIdParameter, isArray, _each, getWindowTop, parseUrl } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {config} from '../src/config.js'; -import * as utils from '../src/utils.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {INSTREAM} from '../src/video.js'; @@ -28,11 +28,11 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid: function (bid) { - const banner = utils.deepAccess(bid, 'mediaTypes.banner'); - const videoMediaType = utils.deepAccess(bid, 'mediaTypes.video'); - const context = utils.deepAccess(bid, 'mediaTypes.video.context'); + const banner = deepAccess(bid, 'mediaTypes.banner'); + const videoMediaType = deepAccess(bid, 'mediaTypes.video'); + const context = deepAccess(bid, 'mediaTypes.video.context'); if ((videoMediaType && context === INSTREAM)) { - const videoBidderParams = utils.deepAccess(bid, 'params.video', {}); + const videoBidderParams = deepAccess(bid, 'params.video', {}); if (!Array.isArray(videoMediaType.playerSize)) { return false; @@ -85,7 +85,7 @@ export const spec = { buildRequests: function (validBidRequests, bidderRequest) { return validBidRequests.map(bid => { var finalRequest = {}; - let bidfloor = utils.getBidIdParameter('bidfloor', bid.params); + let bidfloor = getBidIdParameter('bidfloor', bid.params); const imp = { id: bid.bidId, @@ -95,10 +95,10 @@ export const spec = { displaymanagerver: VERSION, } - if (utils.deepAccess(bid, 'mediaTypes.banner')) { + if (deepAccess(bid, 'mediaTypes.banner')) { imp.banner = getSize(bid.sizes); imp.mediatype = 'banner'; - } else if (utils.deepAccess(bid, 'mediaTypes.video')) { + } else if (deepAccess(bid, 'mediaTypes.video')) { imp.video = _buildVideoORTB(bid); imp.mediatype = 'video'; } @@ -107,8 +107,8 @@ export const spec = { finalRequest = { sizes: bid.sizes, id: bid.bidId, - publisherId: utils.getBidIdParameter('publisherId', bid.params), - placementId: utils.getBidIdParameter('placementId', bid.params), + publisherId: getBidIdParameter('publisherId', bid.params), + placementId: getBidIdParameter('placementId', bid.params), device: device, site: site, imp: imp, @@ -138,9 +138,9 @@ export const spec = { interpretResponse: function (serverResponse, bidRequest) { const bidResponses = []; serverResponse = serverResponse.body; - if (serverResponse && utils.isArray(serverResponse.seatbid)) { - utils._each(serverResponse.seatbid, function (bidList) { - utils._each(bidList.bid, function (bid) { + if (serverResponse && isArray(serverResponse.seatbid)) { + _each(serverResponse.seatbid, function (bidList) { + _each(bidList.bid, function (bid) { const responseCPM = parseFloat(bid.price); if (responseCPM > 0.0 && bid.impid) { const bidResponse = { @@ -228,16 +228,16 @@ function getSite(bidderRequest) { const {refererInfo} = bidderRequest; if (canAccessTopWindow()) { - const wt = utils.getWindowTop(); + const wt = getWindowTop(); domain = wt.location.hostname; page = wt.location.href; referrer = wt.document.referrer || ''; } else if (refererInfo.reachedTop) { - const url = utils.parseUrl(refererInfo.referer); + const url = parseUrl(refererInfo.referer); domain = url.hostname; page = refererInfo.referer; } else if (refererInfo.stack && refererInfo.stack.length && refererInfo.stack[0]) { - const url = utils.parseUrl(refererInfo.stack[0]); + const url = parseUrl(refererInfo.stack[0]); domain = url.hostname; } @@ -251,7 +251,7 @@ function getSite(bidderRequest) { function canAccessTopWindow() { try { - if (utils.getWindowTop().location.href) { + if (getWindowTop().location.href) { return true; } } catch (error) { @@ -260,8 +260,8 @@ function canAccessTopWindow() { } function _buildVideoORTB(bidRequest) { - const videoAdUnit = utils.deepAccess(bidRequest, 'mediaTypes.video'); - const videoBidderParams = utils.deepAccess(bidRequest, 'params.video', {}); + const videoAdUnit = deepAccess(bidRequest, 'mediaTypes.video'); + const videoBidderParams = deepAccess(bidRequest, 'params.video', {}); const video = {} const videoParams = { diff --git a/modules/iqzoneBidAdapter.js b/modules/iqzoneBidAdapter.js index 77bdcc0188d..5268f8935be 100644 --- a/modules/iqzoneBidAdapter.js +++ b/modules/iqzoneBidAdapter.js @@ -1,6 +1,6 @@ +import { isFn, deepAccess, logMessage } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; import { config } from '../src/config.js'; const BIDDER_CODE = 'iqzone'; @@ -66,8 +66,8 @@ function getPlacementReqData(bid) { } function getBidFloor(bid) { - if (!utils.isFn(bid.getFloor)) { - return utils.deepAccess(bid, 'params.bidfloor', 0); + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); } try { @@ -113,7 +113,7 @@ export const spec = { deviceHeight = winTop.screen.height; winLocation = winTop.location; } catch (e) { - utils.logMessage(e); + logMessage(e); winLocation = window.location; } @@ -122,7 +122,7 @@ export const spec = { try { refferLocation = refferUrl && new URL(refferUrl); } catch (e) { - utils.logMessage(e); + logMessage(e); } let location = refferLocation || winLocation; diff --git a/modules/ixBidAdapter.js b/modules/ixBidAdapter.js index 4ff84e7c104..cf551c4f3db 100644 --- a/modules/ixBidAdapter.js +++ b/modules/ixBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { deepAccess, parseGPTSingleSizeArray, inIframe, deepClone, logError, logWarn, isFn, contains, isInteger, isArray, deepSetValue, parseQueryStringParameters, isEmpty, mergeDeep, convertTypes } from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; import find from 'core-js-pure/features/array/find.js'; @@ -83,17 +83,17 @@ const VIDEO_PARAMS_ALLOW_LIST = [ function bidToBannerImp(bid) { const imp = bidToImp(bid); imp.banner = {}; - const impSize = utils.deepAccess(bid, 'params.size'); + const impSize = deepAccess(bid, 'params.size'); if (impSize) { imp.banner.w = impSize[0]; imp.banner.h = impSize[1]; // populate sid with size if not id - if (!utils.deepAccess(imp, 'ext.sid')) { - imp.ext.sid = utils.parseGPTSingleSizeArray(impSize); + if (!deepAccess(imp, 'ext.sid')) { + imp.ext.sid = parseGPTSingleSizeArray(impSize); } } - imp.banner.topframe = utils.inIframe() ? 0 : 1; + imp.banner.topframe = inIframe() ? 0 : 1; _applyFloor(bid, imp, BANNER); @@ -108,14 +108,14 @@ function bidToBannerImp(bid) { */ function bidToVideoImp(bid) { const imp = bidToImp(bid); - const videoAdUnitRef = utils.deepAccess(bid, 'mediaTypes.video'); - const videoParamRef = utils.deepAccess(bid, 'params.video'); + const videoAdUnitRef = deepAccess(bid, 'mediaTypes.video'); + const videoParamRef = deepAccess(bid, 'params.video'); const videoParamErrors = checkVideoParams(videoAdUnitRef, videoParamRef); if (videoParamErrors.length) { return {}; } - imp.video = videoParamRef ? utils.deepClone(bid.params.video) : {}; + imp.video = videoParamRef ? deepClone(bid.params.video) : {}; // copy all video properties to imp object for (const adUnitProperty in videoAdUnitRef) { @@ -125,7 +125,7 @@ function bidToVideoImp(bid) { } if (imp.video.minduration > imp.video.maxduration) { - utils.logError(`IX Bid Adapter: video minduration [${imp.video.minduration}] cannot be greater than video maxduration [${imp.video.maxduration}]`); + logError(`IX Bid Adapter: video minduration [${imp.video.minduration}] cannot be greater than video maxduration [${imp.video.maxduration}]`); return {}; } @@ -138,21 +138,21 @@ function bidToVideoImp(bid) { } else if (context === OUTSTREAM) { imp.video.placement = 4; } else { - utils.logWarn(`IX Bid Adapter: Video context '${context}' is not supported`); + logWarn(`IX Bid Adapter: Video context '${context}' is not supported`); } } if (!(imp.video.w && imp.video.h)) { // Getting impression Size - const impSize = getFirstSize(utils.deepAccess(imp, 'video.playerSize')) || getFirstSize(utils.deepAccess(bid, 'params.size')); + const impSize = getFirstSize(deepAccess(imp, 'video.playerSize')) || getFirstSize(deepAccess(bid, 'params.size')); if (impSize) { imp.video.w = impSize[0]; imp.video.h = impSize[1]; - if (!(utils.deepAccess(imp, 'ext.sid'))) { - imp.ext.sid = utils.parseGPTSingleSizeArray(impSize); + if (!(deepAccess(imp, 'ext.sid'))) { + imp.ext.sid = parseGPTSingleSizeArray(impSize); } } else { - utils.logWarn('IX Bid Adapter: Video size is missing in [mediaTypes.video] missing'); + logWarn('IX Bid Adapter: Video size is missing in [mediaTypes.video] missing'); return {}; } } @@ -180,7 +180,7 @@ function bidToImp(bid) { imp.ext.sid = String(bid.params.id); } - const dfpAdUnitCode = utils.deepAccess(bid, 'ortb2Imp.ext.data.adserver.adslot'); + const dfpAdUnitCode = deepAccess(bid, 'ortb2Imp.ext.data.adserver.adslot'); if (dfpAdUnitCode) { imp.ext.dfp_ad_unit_code = dfpAdUnitCode; } @@ -202,11 +202,11 @@ function _applyFloor(bid, imp, mediaType) { adapterFloor = { floor: bid.params.bidFloor, currency: bid.params.bidFloorCur }; } - if (utils.isFn(bid.getFloor)) { + if (isFn(bid.getFloor)) { let _mediaType = '*'; let _size = '*'; - if (mediaType && utils.contains(SUPPORTED_AD_TYPES, mediaType)) { + if (mediaType && contains(SUPPORTED_AD_TYPES, mediaType)) { const { w: width, h: height } = imp[mediaType]; _mediaType = mediaType; _size = [width, height]; @@ -218,7 +218,7 @@ function _applyFloor(bid, imp, mediaType) { }); } catch (err) { // continue with no module floors - utils.logWarn('priceFloors module call getFloor failed, error : ', err); + logWarn('priceFloors module call getFloor failed, error : ', err); } } @@ -243,8 +243,8 @@ function _applyFloor(bid, imp, mediaType) { */ function parseBid(rawBid, currency, bidRequest) { const bid = {}; - const isValidExpiry = !!((utils.deepAccess(rawBid, 'exp') && utils.isInteger(rawBid.exp))); - const dealID = utils.deepAccess(rawBid, 'dealid') || utils.deepAccess(rawBid, 'ext.dealid'); + const isValidExpiry = !!((deepAccess(rawBid, 'exp') && isInteger(rawBid.exp))); + const dealID = deepAccess(rawBid, 'dealid') || deepAccess(rawBid, 'ext.dealid'); if (PRICE_TO_DOLLAR_FACTOR.hasOwnProperty(currency)) { bid.cpm = rawBid.price / PRICE_TO_DOLLAR_FACTOR[currency]; @@ -263,7 +263,7 @@ function parseBid(rawBid, currency, bidRequest) { bid.creativeId = rawBid.hasOwnProperty('crid') ? rawBid.crid : '-'; // in the event of a video - if (utils.deepAccess(rawBid, 'ext.vasturl')) { + if (deepAccess(rawBid, 'ext.vasturl')) { bid.vastUrl = rawBid.ext.vasturl bid.width = bidRequest.video.w; bid.height = bidRequest.video.h; @@ -279,9 +279,9 @@ function parseBid(rawBid, currency, bidRequest) { } bid.meta = {}; - bid.meta.networkId = utils.deepAccess(rawBid, 'ext.dspid'); - bid.meta.brandId = utils.deepAccess(rawBid, 'ext.advbrandid'); - bid.meta.brandName = utils.deepAccess(rawBid, 'ext.advbrand'); + bid.meta.networkId = deepAccess(rawBid, 'ext.dspid'); + bid.meta.brandId = deepAccess(rawBid, 'ext.advbrandid'); + bid.meta.brandName = deepAccess(rawBid, 'ext.advbrand'); if (rawBid.adomain && rawBid.adomain.length > 0) { bid.meta.advertiserDomains = rawBid.adomain; } @@ -296,7 +296,7 @@ function parseBid(rawBid, currency, bidRequest) { * @return {boolean} True if this is a valid size format, and false otherwise. */ function isValidSize(size) { - return Array.isArray(size) && size.length === 2 && utils.isInteger(size[0]) && utils.isInteger(size[1]); + return Array.isArray(size) && size.length === 2 && isInteger(size[0]) && isInteger(size[1]); } /** @@ -330,7 +330,7 @@ function checkVideoParams(mediaTypeVideoRef, paramsVideoRef) { const errorList = []; if (!mediaTypeVideoRef) { - utils.logWarn('IX Bid Adapter: mediaTypes.video is the preferred location for video params in ad unit'); + logWarn('IX Bid Adapter: mediaTypes.video is the preferred location for video params in ad unit'); } for (let property of REQUIRED_VIDEO_PARAMS) { @@ -416,9 +416,9 @@ function getBidRequest(id, impressions, validBidRequests) { function getEidInfo(allEids, flocData) { let toSend = []; let seenSources = {}; - if (utils.isArray(allEids)) { + if (isArray(allEids)) { for (const eid of allEids) { - if (SOURCE_RTI_MAPPING[eid.source] && utils.deepAccess(eid, 'uids.0')) { + if (SOURCE_RTI_MAPPING[eid.source] && deepAccess(eid, 'uids.0')) { seenSources[eid.source] = true; eid.uids[0].ext = { rtiPartner: SOURCE_RTI_MAPPING[eid.source] @@ -454,7 +454,7 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) { // Always use secure HTTPS protocol. let baseUrl = SECURE_BID_URL; // Get ids from Prebid User ID Modules - let eidInfo = getEidInfo(utils.deepAccess(validBidRequests, '0.userIdAsEids'), utils.deepAccess(validBidRequests, '0.userId.flocId')); + let eidInfo = getEidInfo(deepAccess(validBidRequests, '0.userIdAsEids'), deepAccess(validBidRequests, '0.userId.flocId')); let userEids = eidInfo.toSend; // RTI ids will be included in the bid request if the function getIdentityInfo() is loaded @@ -543,7 +543,7 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) { } if (bidderRequest.uspConsent) { - utils.deepSetValue(r, 'regs.ext.us_privacy', bidderRequest.uspConsent); + deepSetValue(r, 'regs.ext.us_privacy', bidderRequest.uspConsent); } if (bidderRequest.refererInfo) { @@ -552,7 +552,7 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) { } if (config.getConfig('coppa')) { - utils.deepSetValue(r, 'regs.coppa', 1); + deepSetValue(r, 'regs.coppa', 1); } const payload = {}; @@ -572,10 +572,10 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) { const requests = []; let requestSequenceNumber = 0; const transactionIds = Object.keys(impressions); - const baseRequestSize = `${baseUrl}${utils.parseQueryStringParameters({ ...payload, r: JSON.stringify(r) })}`.length; + const baseRequestSize = `${baseUrl}${parseQueryStringParameters({ ...payload, r: JSON.stringify(r) })}`.length; if (baseRequestSize > MAX_REQUEST_SIZE) { - utils.logError('ix bidder: Base request size has exceeded maximum request size.'); + logError('ix bidder: Base request size has exceeded maximum request size.'); return requests; } @@ -605,7 +605,7 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) { } currentRequestSize += fpdRequestSize; } else { - utils.logError('ix bidder: IX config FPD request size has exceeded maximum request size.'); + logError('ix bidder: IX config FPD request size has exceeded maximum request size.'); } } @@ -673,7 +673,7 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) { const fpd = config.getConfig('ortb2') || {}; - if (!utils.isEmpty(fpd) && !isFpdAdded) { + if (!isEmpty(fpd) && !isFpdAdded) { r.ext.ixdiag.fpd = true; const site = { ...(fpd.site || fpd.context) }; @@ -692,28 +692,28 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) { } }); - const clonedRObject = utils.deepClone(r); + const clonedRObject = deepClone(r); - clonedRObject.site = utils.mergeDeep({}, clonedRObject.site, site); - clonedRObject.user = utils.mergeDeep({}, clonedRObject.user, user); + clonedRObject.site = mergeDeep({}, clonedRObject.site, site); + clonedRObject.user = mergeDeep({}, clonedRObject.user, user); - const requestSize = `${baseUrl}${utils.parseQueryStringParameters({ ...payload, r: JSON.stringify(clonedRObject) })}`.length; + const requestSize = `${baseUrl}${parseQueryStringParameters({ ...payload, r: JSON.stringify(clonedRObject) })}`.length; if (requestSize < MAX_REQUEST_SIZE) { - r.site = utils.mergeDeep({}, r.site, site); - r.user = utils.mergeDeep({}, r.user, user); + r.site = mergeDeep({}, r.site, site); + r.user = mergeDeep({}, r.user, user); isFpdAdded = true; const fpdRequestSize = encodeURIComponent(JSON.stringify({ ...site, ...user })).length; currentRequestSize += fpdRequestSize; } else { - utils.logError('ix bidder: FPD request size has exceeded maximum request size.'); + logError('ix bidder: FPD request size has exceeded maximum request size.'); } } const isLastAdUnit = adUnitIndex === transactionIds.length - 1; if (wasAdUnitImpressionsTrimmed || isLastAdUnit) { - const clonedPayload = utils.deepClone(payload); + const clonedPayload = deepClone(payload); if (!isLastAdUnit || requestSequenceNumber) { r.ext.ixdiag.sn = requestSequenceNumber; clonedPayload.sn = requestSequenceNumber; @@ -778,30 +778,30 @@ function buildIXDiag(validBidRequests) { for (let i = 0; i < adUnitMap.length; i++) { var bid = validBidRequests.filter(bidRequest => bidRequest.transactionId === adUnitMap[i])[0]; - if (utils.deepAccess(bid, 'mediaTypes')) { + if (deepAccess(bid, 'mediaTypes')) { if (Object.keys(bid.mediaTypes).length > 1) { ixdiag.mfu++; } - if (utils.deepAccess(bid, 'mediaTypes.native')) { + if (deepAccess(bid, 'mediaTypes.native')) { ixdiag.nu++; } - if (utils.deepAccess(bid, 'mediaTypes.banner')) { + if (deepAccess(bid, 'mediaTypes.banner')) { ixdiag.bu++; } - if (utils.deepAccess(bid, 'mediaTypes.video.context') === 'outstream') { + if (deepAccess(bid, 'mediaTypes.video.context') === 'outstream') { ixdiag.ou++; // renderer only needed for outstream - const hasRenderer = typeof (utils.deepAccess(bid, 'renderer') || utils.deepAccess(bid, 'mediaTypes.video.renderer')) === 'object'; + const hasRenderer = typeof (deepAccess(bid, 'renderer') || deepAccess(bid, 'mediaTypes.video.renderer')) === 'object'; // if any one ad unit is missing renderer, set ren status to false in diag - ixdiag.ren = ixdiag.ren && hasRenderer ? (utils.deepAccess(ixdiag, 'ren')) : hasRenderer; + ixdiag.ren = ixdiag.ren && hasRenderer ? (deepAccess(ixdiag, 'ren')) : hasRenderer; } - if (utils.deepAccess(bid, 'mediaTypes.video.context') === 'instream') { + if (deepAccess(bid, 'mediaTypes.video.context') === 'instream') { ixdiag.iu++; } @@ -860,7 +860,7 @@ function createBannerImps(validBidRequest, missingBannerSizes, bannerImps) { let imp = bidToBannerImp(validBidRequest); - const bannerSizeDefined = includesSize(utils.deepAccess(validBidRequest, 'mediaTypes.banner.sizes'), utils.deepAccess(validBidRequest, 'params.size')); + const bannerSizeDefined = includesSize(deepAccess(validBidRequest, 'mediaTypes.banner.sizes'), deepAccess(validBidRequest, 'params.size')); // Create IX imps from params.size if (bannerSizeDefined) { @@ -884,7 +884,7 @@ function createBannerImps(validBidRequest, missingBannerSizes, bannerImps) { * @returns {string} */ function detectParamsType(validBidRequest) { - if (utils.deepAccess(validBidRequest, 'params.video') && utils.deepAccess(validBidRequest, 'mediaTypes.video')) { + if (deepAccess(validBidRequest, 'params.video') && deepAccess(validBidRequest, 'mediaTypes.video')) { return VIDEO; } @@ -909,8 +909,8 @@ function updateMissingSizes(validBidRequest, missingBannerSizes, imp) { missingBannerSizes[transactionID].missingSizes = currentSizeList; } else { // New Ad Unit - if (utils.deepAccess(validBidRequest, 'mediaTypes.banner.sizes')) { - let sizeList = utils.deepClone(validBidRequest.mediaTypes.banner.sizes); + if (deepAccess(validBidRequest, 'mediaTypes.banner.sizes')) { + let sizeList = deepClone(validBidRequest.mediaTypes.banner.sizes); removeFromSizes(sizeList, validBidRequest.params.size); let newAdUnitEntry = { 'missingSizes': sizeList, @@ -928,8 +928,8 @@ function updateMissingSizes(validBidRequest, missingBannerSizes, imp) { * @return {object} newImp Updated impression object */ function createMissingBannerImp(bid, imp, newSize) { - const newImp = utils.deepClone(imp); - newImp.ext.sid = utils.parseGPTSingleSizeArray(newSize); + const newImp = deepClone(imp); + newImp.ext.sid = parseGPTSingleSizeArray(newSize); newImp.banner.w = newSize[0]; newImp.banner.h = newSize[1]; @@ -969,7 +969,7 @@ function createRenderer (id) { try { renderer.setRender(outstreamRenderer); } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); + logWarn('Prebid Error calling setRender on renderer', err); } return renderer; @@ -993,19 +993,19 @@ export const spec = { * @return {boolean} True if this is a valid bid, and false otherwise. */ isBidRequestValid: function (bid) { - const paramsVideoRef = utils.deepAccess(bid, 'params.video'); - const paramsSize = utils.deepAccess(bid, 'params.size'); - const mediaTypeBannerSizes = utils.deepAccess(bid, 'mediaTypes.banner.sizes'); - const mediaTypeVideoRef = utils.deepAccess(bid, 'mediaTypes.video'); - const mediaTypeVideoPlayerSize = utils.deepAccess(bid, 'mediaTypes.video.playerSize'); + const paramsVideoRef = deepAccess(bid, 'params.video'); + const paramsSize = deepAccess(bid, 'params.size'); + const mediaTypeBannerSizes = deepAccess(bid, 'mediaTypes.banner.sizes'); + const mediaTypeVideoRef = deepAccess(bid, 'mediaTypes.video'); + const mediaTypeVideoPlayerSize = deepAccess(bid, 'mediaTypes.video.playerSize'); const hasBidFloor = bid.params.hasOwnProperty('bidFloor'); const hasBidFloorCur = bid.params.hasOwnProperty('bidFloorCur'); - if (bid.hasOwnProperty('mediaType') && !(utils.contains(SUPPORTED_AD_TYPES, bid.mediaType))) { + if (bid.hasOwnProperty('mediaType') && !(contains(SUPPORTED_AD_TYPES, bid.mediaType))) { return false; } - if (utils.deepAccess(bid, 'mediaTypes.banner') && !mediaTypeBannerSizes) { + if (deepAccess(bid, 'mediaTypes.banner') && !mediaTypeBannerSizes) { return false; } @@ -1013,26 +1013,26 @@ export const spec = { // since there is an ix bidder level size, make sure its valid const ixSize = getFirstSize(paramsSize); if (!ixSize) { - utils.logError('ix bidder params: size has invalid format.'); + logError('ix bidder params: size has invalid format.'); return false; } // check if the ix bidder level size, is present in ad unit level if (!includesSize(bid.sizes, ixSize) && !(includesSize(mediaTypeVideoPlayerSize, ixSize)) && !(includesSize(mediaTypeBannerSizes, ixSize))) { - utils.logError('ix bidder params: bid size is not included in ad unit sizes or player size.'); + logError('ix bidder params: bid size is not included in ad unit sizes or player size.'); return false; } } if (typeof bid.params.siteId !== 'string' && typeof bid.params.siteId !== 'number') { - utils.logError('ix bidder params: siteId must be string or number value.'); + logError('ix bidder params: siteId must be string or number value.'); return false; } if (hasBidFloor || hasBidFloorCur) { if (!(hasBidFloor && hasBidFloorCur && isValidBidFloorParams(bid.params.bidFloor, bid.params.bidFloorCur))) { - utils.logError('ix bidder params: bidFloor / bidFloorCur parameter has invalid format.'); + logError('ix bidder params: bidFloor / bidFloorCur parameter has invalid format.'); return false; } } @@ -1041,7 +1041,7 @@ export const spec = { const errorList = checkVideoParams(mediaTypeVideoRef, paramsVideoRef); if (errorList.length) { errorList.forEach((err) => { - utils.logError(err); + logError(err); }); return false; } @@ -1065,7 +1065,7 @@ export const spec = { // Step 1: Create impresssions from IX params validBidRequests.forEach((validBidRequest) => { - const adUnitMediaTypes = Object.keys(utils.deepAccess(validBidRequest, 'mediaTypes', {})) + const adUnitMediaTypes = Object.keys(deepAccess(validBidRequest, 'mediaTypes', {})) switch (detectParamsType(validBidRequest)) { case BANNER: @@ -1156,7 +1156,7 @@ export const spec = { const bidRequest = getBidRequest(innerBids[j].impid, requestBid.imp, bidderRequest.validBidRequests); bid = parseBid(innerBids[j], responseBody.cur, bidRequest); - if (!utils.deepAccess(bid, 'mediaTypes.video.renderer') && utils.deepAccess(bid, 'mediaTypes.video.context') === 'outstream') { + if (!deepAccess(bid, 'mediaTypes.video.renderer') && deepAccess(bid, 'mediaTypes.video.context') === 'outstream') { bid.mediaTypes.video.renderer = createRenderer(innerBids[j].bidId); } @@ -1174,7 +1174,7 @@ export const spec = { * @return {Object} params bid params */ transformBidParams: function (params, isOpenRtb) { - return utils.convertTypes({ + return convertTypes({ 'siteID': 'number' }, params); }, diff --git a/modules/jixieBidAdapter.js b/modules/jixieBidAdapter.js index db6c9032e65..0e05616465a 100644 --- a/modules/jixieBidAdapter.js +++ b/modules/jixieBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { logWarn, parseUrl, deepAccess, isArray } from '../src/utils.js'; import { config } from '../src/config.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { getStorageManager } from '../src/storageManager.js'; @@ -95,7 +95,7 @@ function createRenderer_(bidAd, scriptUrl, createFcn) { try { renderer.setRender(createFcn); } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); + logWarn('Prebid Error calling setRender on renderer', err); } return renderer; } @@ -110,7 +110,7 @@ function getMiscDims_() { let refererInfo_ = getRefererInfo(); let url_ = ((refererInfo_ && refererInfo_.referer) ? refererInfo_.referer : window.location.href); ret.pageurl = url_; - ret.domain = utils.parseUrl(url_).host; + ret.domain = parseUrl(url_).host; ret.device = getDevice_(); } catch (error) {} return ret; @@ -194,8 +194,8 @@ export const spec = { device: miscDims.device, pageurl: encodeURIComponent(miscDims.pageurl), domain: encodeURIComponent(miscDims.domain), - auctionid: utils.deepAccess(timeoutData, '0.auctionId'), - timeout: utils.deepAccess(timeoutData, '0.timeout'), + auctionid: deepAccess(timeoutData, '0.auctionId'), + timeout: deepAccess(timeoutData, '0.timeout'), count: timeoutData.length }); }, @@ -224,7 +224,7 @@ export const spec = { }, interpretResponse: function(response, bidRequest) { - if (response && response.body && utils.isArray(response.body.bids)) { + if (response && response.body && isArray(response.body.bids)) { const bidResponses = []; response.body.bids.forEach(function(oneBid) { let bnd = {}; diff --git a/modules/kargoBidAdapter.js b/modules/kargoBidAdapter.js index 610f4558139..895d8a7d259 100644 --- a/modules/kargoBidAdapter.js +++ b/modules/kargoBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { _each } from '../src/utils.js'; import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import { getStorageManager } from '../src/storageManager.js'; @@ -28,7 +28,7 @@ export const spec = { const currency = (currencyObj && currencyObj.adServerCurrency) || 'USD'; const bidIds = {}; const bidSizes = {}; - utils._each(validBidRequests, bid => { + _each(validBidRequests, bid => { bidIds[bid.bidId] = bid.params.placementId; bidSizes[bid.bidId] = bid.sizes; }); diff --git a/modules/kinessoIdSystem.js b/modules/kinessoIdSystem.js index 2cd7f594dd2..ca8fe269a5e 100644 --- a/modules/kinessoIdSystem.js +++ b/modules/kinessoIdSystem.js @@ -5,7 +5,7 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils.js' +import { logError, logInfo } from '../src/utils.js'; import {ajax} from '../src/ajax.js'; import {submodule} from '../src/hook.js'; import {coppaDataHandler, uspDataHandler} from '../src/adapterManager.js'; @@ -111,7 +111,7 @@ function encodeTime(now, len) { * @returns {Error} */ function createError(message) { - utils.logError(message); + logError(message); const err = new Error(message); err.source = 'kinessoId'; return err; @@ -147,10 +147,10 @@ function detectPrng(root) { function syncId(storedId) { return { success: function (responseBody) { - utils.logInfo('KinessoId: id to be synced: ' + storedId); + logInfo('KinessoId: id to be synced: ' + storedId); }, error: function () { - utils.logInfo('KinessoId: Sync error for id : ' + storedId); + logInfo('KinessoId: Sync error for id : ' + storedId); } } } @@ -165,7 +165,7 @@ function encodeId(value) { const knssoId = (value && typeof value === 'string') ? value : undefined; if (knssoId) { result.kpuid = knssoId; - utils.logInfo('KinessoId: Decoded value ' + JSON.stringify(result)); + logInfo('KinessoId: Decoded value ' + JSON.stringify(result)); return result; } return knssoId; @@ -217,17 +217,17 @@ export const kinessoIdSubmodule = { getId(config, consentData) { const configParams = (config && config.params) || {}; if (!configParams || typeof configParams.accountid !== 'number') { - utils.logError('User ID - KinessoId submodule requires a valid accountid to be defined'); + logError('User ID - KinessoId submodule requires a valid accountid to be defined'); return; } const coppa = coppaDataHandler.getCoppa(); if (coppa) { - utils.logInfo('KinessoId: IDs not provided for coppa requests, exiting KinessoId'); + logInfo('KinessoId: IDs not provided for coppa requests, exiting KinessoId'); return; } const accountId = configParams.accountid; const knnsoId = id(); - utils.logInfo('KinessoId: generated id ' + knnsoId); + logInfo('KinessoId: generated id ' + knnsoId); const kinessoIdPayload = {}; kinessoIdPayload.id = knnsoId; const payloadString = JSON.stringify(kinessoIdPayload); diff --git a/modules/koblerBidAdapter.js b/modules/koblerBidAdapter.js index 59d1639a329..49be80e969c 100644 --- a/modules/koblerBidAdapter.js +++ b/modules/koblerBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { deepAccess, isStr, replaceAuctionPrice, triggerPixel, isArray, parseQueryStringParameters, getWindowSelf } from '../src/utils.js'; import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER} from '../src/mediaTypes.js'; @@ -60,34 +60,34 @@ export const interpretResponse = function (serverResponse) { export const onBidWon = function (bid) { const cpm = bid.cpm || 0; const cpmCurrency = bid.currency || SUPPORTED_CURRENCY; - const adServerPrice = utils.deepAccess(bid, 'adserverTargeting.hb_pb', 0); + const adServerPrice = deepAccess(bid, 'adserverTargeting.hb_pb', 0); const adServerPriceCurrency = config.getConfig('currency.adServerCurrency') || SUPPORTED_CURRENCY; - if (utils.isStr(bid.nurl) && bid.nurl !== '') { - const winNotificationUrl = utils.replaceAuctionPrice(bid.nurl, cpm) + if (isStr(bid.nurl) && bid.nurl !== '') { + const winNotificationUrl = replaceAuctionPrice(bid.nurl, cpm) .replace(/\${AUCTION_PRICE_CURRENCY}/g, cpmCurrency) .replace(/\${AD_SERVER_PRICE}/g, adServerPrice) .replace(/\${AD_SERVER_PRICE_CURRENCY}/g, adServerPriceCurrency); - utils.triggerPixel(winNotificationUrl); + triggerPixel(winNotificationUrl); } }; export const onTimeout = function (timeoutDataArray) { - if (utils.isArray(timeoutDataArray)) { + if (isArray(timeoutDataArray)) { const refererInfo = getRefererInfo(); const pageUrl = (refererInfo && refererInfo.referer) ? refererInfo.referer : window.location.href; timeoutDataArray.forEach(timeoutData => { - const query = utils.parseQueryStringParameters({ + const query = parseQueryStringParameters({ ad_unit_code: timeoutData.adUnitCode, auction_id: timeoutData.auctionId, bid_id: timeoutData.bidId, timeout: timeoutData.timeout, - placement_id: utils.deepAccess(timeoutData, 'params.0.placementId'), + placement_id: deepAccess(timeoutData, 'params.0.placementId'), page_url: pageUrl, }); const timeoutNotificationUrl = `${TIMEOUT_NOTIFICATION_ENDPOINT}?${query}`; - utils.triggerPixel(timeoutNotificationUrl); + triggerPixel(timeoutNotificationUrl); }); } }; @@ -143,7 +143,7 @@ function buildOpenRtbImpObject(validBidRequest) { } function getDevice() { - const ws = utils.getWindowSelf(); + const ws = getWindowSelf(); const ua = ws.navigator.userAgent; if (/(tablet|ipad|playbook|silk|android 3.0|xoom|sch-i800|kindle)|(android(?!.*mobi))/i @@ -171,8 +171,8 @@ function getTest(validBidRequest) { } function getSizes(validBidRequest) { - const sizes = utils.deepAccess(validBidRequest, 'mediaTypes.banner.sizes', validBidRequest.sizes); - if (utils.isArray(sizes) && sizes.length > 0) { + const sizes = deepAccess(validBidRequest, 'mediaTypes.banner.sizes', validBidRequest.sizes); + if (isArray(sizes) && sizes.length > 0) { return sizes; } diff --git a/modules/konduitAnalyticsAdapter.js b/modules/konduitAnalyticsAdapter.js index f6b77f23d87..f8a44d7cc94 100644 --- a/modules/konduitAnalyticsAdapter.js +++ b/modules/konduitAnalyticsAdapter.js @@ -1,7 +1,7 @@ +import { parseSizesInput, logError, uniques } from '../src/utils.js'; import { ajax } from '../src/ajax.js'; import adapter from '../src/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; -import * as utils from '../src/utils.js'; import { targeting } from '../src/targeting.js'; import { config } from '../src/config.js'; import CONSTANTS from '../src/constants.json'; @@ -84,7 +84,7 @@ const konduitAnalyticsAdapter = Object.assign( ); function obtainBidTimeoutInfo (args) { - return args.map(item => item.bidder).filter(utils.uniques); + return args.map(item => item.bidder).filter(uniques); } function obtainAuctionInfo (auction) { @@ -109,7 +109,7 @@ function obtainBidRequestsInfo (bidRequests) { adUnitCode: bid.adUnitCode, bidId: bid.bidId, startTime: bid.startTime, - sizes: utils.parseSizesInput(bid.sizes).toString(), + sizes: parseSizesInput(bid.sizes).toString(), params: bid.params }; }), @@ -208,7 +208,7 @@ konduitAnalyticsAdapter.enableAnalytics = function (analyticsConfig) { const konduitId = config.getConfig('konduit.konduitId'); if (!konduitId) { - utils.logError('A konduitId in config is required to use konduitAnalyticsAdapter'); + logError('A konduitId in config is required to use konduitAnalyticsAdapter'); return; } diff --git a/modules/konduitWrapper.js b/modules/konduitWrapper.js index 3ce9bc7a501..f19318e3128 100644 --- a/modules/konduitWrapper.js +++ b/modules/konduitWrapper.js @@ -1,6 +1,6 @@ +import { logInfo, logError, isNumber, isStr, isEmpty } from '../src/utils.js'; import { registerVideoSupport } from '../src/adServerManager.js'; import { targeting } from '../src/targeting.js'; -import * as utils from '../src/utils.js'; import { config } from '../src/config.js'; import { ajaxBuilder } from '../src/ajax.js'; import { getPriceBucketString } from '../src/cpmBucketManager.js'; @@ -49,12 +49,12 @@ function addLogLabel(args) { return args; } -function logInfo() { - utils.logInfo(...addLogLabel(arguments)); +function _logInfo() { + logInfo(...addLogLabel(arguments)); } -function logError() { - utils.logError(...addLogLabel(arguments)); +function _logError() { + logError(...addLogLabel(arguments)); } function sendRequest ({ host = SERVER_HOST, protocol = SERVER_PROTOCOL, method = 'GET', path, payload, callbacks, timeout }) { @@ -113,7 +113,7 @@ function setDefaultKCpmToBid(bid, winnerBid, priceGranularity) { } function addKCpmToBid(kCpm, bid, winnerBid, priceGranularity) { - if (utils.isNumber(kCpm)) { + if (isNumber(kCpm)) { bid.kCpm = kCpm; const priceStringsObj = getPriceBucketString( kCpm, @@ -134,7 +134,7 @@ function addKCpmToBid(kCpm, bid, winnerBid, priceGranularity) { } function addKonduitCacheKeyToBid(cacheKey, bid, winnerBid) { - if (utils.isStr(cacheKey)) { + if (isStr(cacheKey)) { bid.konduitCacheKey = cacheKey; if (config.getConfig(SEND_ALL_BIDS_CONFIG)) { @@ -163,7 +163,7 @@ export function processBids(options = {}) { options = options || {}; if (!konduitId) { - logError(errorMessages.NO_KONDUIT_ID); + _logError(errorMessages.NO_KONDUIT_ID); if (options.callback) { options.callback(new Error(errorMessages.NO_KONDUIT_ID), []); @@ -184,7 +184,7 @@ export function processBids(options = {}) { } if (!bids.length) { - logError(errorMessages.NO_BIDS); + _logError(errorMessages.NO_BIDS); if (options.callback) { options.callback(new Error(errorMessages.NO_BIDS), []); @@ -216,11 +216,11 @@ export function processBids(options = {}) { callbacks: { success: (data) => { let error = null; - logInfo('Bids processed successfully ', data); + _logInfo('Bids processed successfully ', data); try { const { kCpmData, cacheData } = JSON.parse(data); - if (utils.isEmpty(cacheData)) { + if (isEmpty(cacheData)) { throw new Error(errorMessages.CACHE_FAILURE); } @@ -234,7 +234,7 @@ export function processBids(options = {}) { }) } catch (err) { error = err; - logError('Error parsing JSON response for bidsProcessor data: ', err) + _logError('Error parsing JSON response for bidsProcessor data: ', err) } if (options.callback) { @@ -242,9 +242,9 @@ export function processBids(options = {}) { } }, error: (error) => { - logError('Bids were not processed successfully ', error); + _logError('Bids were not processed successfully ', error); if (options.callback) { - options.callback(utils.isStr(error) ? new Error(error) : error, bids); + options.callback(isStr(error) ? new Error(error) : error, bids); } } }