From 33762d1ee5abd0363e2b35fbbb07cb2d38287972 Mon Sep 17 00:00:00 2001 From: Harshad Mane Date: Thu, 12 Sep 2019 16:38:12 -0700 Subject: [PATCH 1/7] added support for pubcommon, digitrust, id5id --- modules/pubmaticBidAdapter.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index facecdaa578..2ec353a2f4e 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -624,10 +624,31 @@ function _handleTTDId(eids, validBidRequests) { } } +/** + * Produces external userid object in ortb 3.0 model. + */ +function _addExternalUserId(eids, value, source, atype) { + if (value) { + eids.push({ + source, + uids: [{ + id: value, + atype + }] + }); + } +} + function _handleEids(payload, validBidRequests) { let eids = []; _handleDigitrustId(eids); _handleTTDId(eids, validBidRequests); + const bidRequest = validBidRequests[0]; + if(bidRequest && bidRequest.userId){ + _addExternalUserId(eids, bidRequest.userId.pubcid, 'pubcommon', 1); + _addExternalUserId(eids, utils.deepAccess(bidRequest.userId.digitrustid, 'data.id'), 'digitru.st', 1); + _addExternalUserId(eids, bidRequest.userId.id5id, 'id5id', 1); + } if (eids.length > 0) { payload.user.eids = eids; } From 0722354d7e62dc2237e16f8b7f469557ef388a20 Mon Sep 17 00:00:00 2001 From: Harshad Mane Date: Thu, 12 Sep 2019 20:11:24 -0700 Subject: [PATCH 2/7] added support for IdentityLink --- modules/pubmaticBidAdapter.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index 2ec353a2f4e..8c72367ba6e 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -644,10 +644,12 @@ function _handleEids(payload, validBidRequests) { _handleDigitrustId(eids); _handleTTDId(eids, validBidRequests); const bidRequest = validBidRequests[0]; - if(bidRequest && bidRequest.userId){ - _addExternalUserId(eids, bidRequest.userId.pubcid, 'pubcommon', 1); - _addExternalUserId(eids, utils.deepAccess(bidRequest.userId.digitrustid, 'data.id'), 'digitru.st', 1); - _addExternalUserId(eids, bidRequest.userId.id5id, 'id5id', 1); + if (bidRequest && bidRequest.userId) { + _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.pubcid`), 'pubcommon', 1); + _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.digitrustid.data.id`), 'digitru.st', 1); + _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id`), 'id5id', 1); + _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.criteortus.${BIDDER_CODE}.userid`), 'criteortus', 1); + _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.idl_env`), 'identity_link_envelope', 1); } if (eids.length > 0) { payload.user.eids = eids; From f2c32c07b4a4996e1e7d59510974c07d2eec7d5e Mon Sep 17 00:00:00 2001 From: Harshad Mane Date: Fri, 13 Sep 2019 10:02:20 -0700 Subject: [PATCH 3/7] changed the source for id5 --- modules/pubmaticBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index 8c72367ba6e..c768583b96c 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -647,7 +647,7 @@ function _handleEids(payload, validBidRequests) { if (bidRequest && bidRequest.userId) { _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.pubcid`), 'pubcommon', 1); _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.digitrustid.data.id`), 'digitru.st', 1); - _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id`), 'id5id', 1); + _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id`), 'id5-sync.com', 1); _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.criteortus.${BIDDER_CODE}.userid`), 'criteortus', 1); _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.idl_env`), 'identity_link_envelope', 1); } From eaed9874c1fc91d79118b148bbd740569e562023 Mon Sep 17 00:00:00 2001 From: Harshad Mane Date: Fri, 13 Sep 2019 14:19:36 -0700 Subject: [PATCH 4/7] added unit test cases --- modules/pubmaticBidAdapter.js | 2 +- test/spec/modules/pubmaticBidAdapter_spec.js | 186 +++++++++++++++++++ 2 files changed, 187 insertions(+), 1 deletion(-) diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index c768583b96c..a85a2c8e19c 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -628,7 +628,7 @@ function _handleTTDId(eids, validBidRequests) { * Produces external userid object in ortb 3.0 model. */ function _addExternalUserId(eids, value, source, atype) { - if (value) { + if (utils.isStr(value)) { eids.push({ source, uids: [{ diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js index 3de83c56213..d0d0ce8c08b 100644 --- a/test/spec/modules/pubmaticBidAdapter_spec.js +++ b/test/spec/modules/pubmaticBidAdapter_spec.js @@ -1476,6 +1476,192 @@ describe('PubMatic adapter', function () { }); }); + describe('UserIds from request', function() { + describe('pubcommon Id', function() { + it('send the pubcommon id if it is present', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.pubcid = 'pub_common_user_id'; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal([{ + 'source': 'pubcommon', + 'uids': [{ + 'id': 'pub_common_user_id', + 'atype': 1 + }] + }]); + }); + + it('do not pass if not string', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.pubcid = 1; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.pubcid = []; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.pubcid = null; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.pubcid = {}; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + }); + }); + + describe('Digitrust Id', function() { + it('send the digitrust id if it is present', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.digitrustid = {data: {id: 'digitrust_user_id'}}; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal([{ + 'source': 'digitru.st', + 'uids': [{ + 'id': 'digitrust_user_id', + 'atype': 1 + }] + }]); + }); + + it('do not pass if not string', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.digitrustid = {data: {id: 1}}; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.digitrustid = {data: {id: []}}; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.digitrustid = {data: {id: null}}; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.digitrustid = {data: {id: {}}}; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + }); + }); + + describe('ID5 Id', function() { + it('send the id5 id if it is present', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.id5id = 'id5-user-id'; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal([{ + 'source': 'id5-sync.com', + 'uids': [{ + 'id': 'id5-user-id', + 'atype': 1 + }] + }]); + }); + + it('do not pass if not string', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.id5id = 1; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.id5id = []; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.id5id = null; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.id5id = {}; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + }); + }); + + describe('CriteoRTUS Id', function() { + it('send the criteo id if it is present', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.criteortus = {pubmatic: {userid: 'criteo-rtus-user-id'}}; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal([{ + 'source': 'criteortus', + 'uids': [{ + 'id': 'criteo-rtus-user-id', + 'atype': 1 + }] + }]); + }); + + it('do not pass if not string', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.criteortus = {appnexus: {userid: 'criteo-rtus-user-id'}}; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.criteortus = {pubmatic: {userid: 1}}; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.criteortus = {pubmatic: {userid: []}}; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.criteortus = {pubmatic: {userid: null}}; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.criteortus = {pubmatic: {userid: {}}}; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + }); + }); + + describe('IdentityLink Id', function() { + it('send the identity-link id if it is present', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.idl_env = 'identity-link-user-id'; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal([{ + 'source': 'identity_link_envelope', + 'uids': [{ + 'id': 'identity-link-user-id', + 'atype': 1 + }] + }]); + }); + + it('do not pass if not string', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.idl_env = 1; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.idl_env = []; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.idl_env = null; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.idl_env = {}; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + }); + }); + }) + it('Request params check for video ad', function () { let request = spec.buildRequests(videoBidRequests); let data = JSON.parse(request.data); From 602ee7ea83c07cf1ff83f6c000473512a9525b4c Mon Sep 17 00:00:00 2001 From: Harshad Mane Date: Mon, 16 Sep 2019 14:24:27 -0700 Subject: [PATCH 5/7] changed source param for identityLink --- modules/pubmaticBidAdapter.js | 2 +- test/spec/modules/pubmaticBidAdapter_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index a85a2c8e19c..d1e1d072673 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -649,7 +649,7 @@ function _handleEids(payload, validBidRequests) { _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.digitrustid.data.id`), 'digitru.st', 1); _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id`), 'id5-sync.com', 1); _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.criteortus.${BIDDER_CODE}.userid`), 'criteortus', 1); - _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.idl_env`), 'identity_link_envelope', 1); + _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.idl_env`), 'liveramp.com', 1); } if (eids.length > 0) { payload.user.eids = eids; diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js index d0d0ce8c08b..ababf2dcf5f 100644 --- a/test/spec/modules/pubmaticBidAdapter_spec.js +++ b/test/spec/modules/pubmaticBidAdapter_spec.js @@ -1632,7 +1632,7 @@ describe('PubMatic adapter', function () { let request = spec.buildRequests(bidRequests, {}); let data = JSON.parse(request.data); expect(data.user.eids).to.deep.equal([{ - 'source': 'identity_link_envelope', + 'source': 'liveramp.com', 'uids': [{ 'id': 'identity-link-user-id', 'atype': 1 From ed83320655521ff60674839f622591fbfc96b206 Mon Sep 17 00:00:00 2001 From: Harshad Mane Date: Thu, 23 Sep 2021 15:53:41 -0700 Subject: [PATCH 6/7] import utils as needed; dont import all --- modules/33acrossBidAdapter.js | 43 ++++---- modules/a4gBidAdapter.js | 6 +- modules/ablidaBidAdapter.js | 4 +- modules/adagioAnalyticsAdapter.js | 8 +- modules/adagioBidAdapter.js | 167 +++++++++++++++--------------- 5 files changed, 117 insertions(+), 111 deletions(-) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 4b8028d97fd..2bdbdd6414b 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -1,6 +1,9 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; -import * as utils from '../src/utils.js'; +import { + deepAccess, uniques, isArray, getWindowTop, isGptPubadsDefined, isSlotMatchingAdUnitCode, logInfo, logWarn, + getWindowSelf +} from '../src/utils.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; const BIDDER_CODE = '33across'; @@ -61,7 +64,7 @@ function _validateBasic(bid) { } function _validateGUID(bid) { - const siteID = utils.deepAccess(bid, 'params.siteId', '') || ''; + const siteID = deepAccess(bid, 'params.siteId', '') || ''; if (siteID.trim().match(GUID_PATTERN) === null) { return false; } @@ -70,7 +73,7 @@ function _validateGUID(bid) { } function _validateBanner(bid) { - const banner = utils.deepAccess(bid, 'mediaTypes.banner'); + const banner = deepAccess(bid, 'mediaTypes.banner'); // If there's no banner no need to validate against banner rules if (banner === undefined) { return true; @@ -84,8 +87,8 @@ function _validateBanner(bid) { } function _validateVideo(bid) { - const videoAdUnit = utils.deepAccess(bid, 'mediaTypes.video'); - const videoBidderParams = utils.deepAccess(bid, 'params.video', {}); + const videoAdUnit = deepAccess(bid, 'mediaTypes.video'); + const videoBidderParams = deepAccess(bid, 'params.video', {}); // If there's no video no need to validate against video rules if (videoAdUnit === undefined) { @@ -145,7 +148,7 @@ function buildRequests(bidRequests, bidderRequest) { const uspConsent = bidderRequest && bidderRequest.uspConsent; const pageUrl = (bidderRequest && bidderRequest.refererInfo) ? (bidderRequest.refererInfo.referer) : (undefined); - adapterState.uniqueSiteIds = bidRequests.map(req => req.params.siteId).filter(utils.uniques); + adapterState.uniqueSiteIds = bidRequests.map(req => req.params.siteId).filter(uniques); return bidRequests.map(bidRequest => _createServerRequest( { @@ -168,13 +171,13 @@ function _createServerRequest({bidRequest, gdprConsent = {}, uspConsent, pageUrl */ ttxRequest.imp = [{}]; - if (utils.deepAccess(bidRequest, 'mediaTypes.banner')) { + if (deepAccess(bidRequest, 'mediaTypes.banner')) { ttxRequest.imp[0].banner = { ..._buildBannerORTB(bidRequest) } } - if (utils.deepAccess(bidRequest, 'mediaTypes.video')) { + if (deepAccess(bidRequest, 'mediaTypes.video')) { ttxRequest.imp[0].video = _buildVideoORTB(bidRequest); } @@ -279,7 +282,7 @@ function setExtension(obj = {}, key, value) { // BUILD REQUESTS: SIZE INFERENCE function _transformSizes(sizes) { - if (utils.isArray(sizes) && sizes.length === 2 && !utils.isArray(sizes[0])) { + if (isArray(sizes) && sizes.length === 2 && !isArray(sizes[0])) { return [ _getSize(sizes) ]; } @@ -308,7 +311,7 @@ function _getProduct(bidRequest) { // BUILD REQUESTS: BANNER function _buildBannerORTB(bidRequest) { - const bannerAdUnit = utils.deepAccess(bidRequest, 'mediaTypes.banner', {}); + const bannerAdUnit = deepAccess(bidRequest, 'mediaTypes.banner', {}); const element = _getAdSlotHTMLElement(bidRequest.adUnitCode); const sizes = _transformSizes(bannerAdUnit.sizes); @@ -340,7 +343,7 @@ function _buildBannerORTB(bidRequest) { const minSize = _getMinSize(sizes); const viewabilityAmount = _isViewabilityMeasurable(element) - ? _getViewability(element, utils.getWindowTop(), minSize) + ? _getViewability(element, getWindowTop(), minSize) : NON_MEASURABLE; const ext = contributeViewability(viewabilityAmount); @@ -354,8 +357,8 @@ function _buildBannerORTB(bidRequest) { // BUILD REQUESTS: VIDEO // eslint-disable-next-line no-unused-vars 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 videoParams = { ...videoAdUnit, @@ -429,23 +432,23 @@ function _getViewability(element, topWin, { w, h } = {}) { } function _mapAdUnitPathToElementId(adUnitCode) { - if (utils.isGptPubadsDefined()) { + if (isGptPubadsDefined()) { // eslint-disable-next-line no-undef const adSlots = googletag.pubads().getSlots(); - const isMatchingAdSlot = utils.isSlotMatchingAdUnitCode(adUnitCode); + const isMatchingAdSlot = isSlotMatchingAdUnitCode(adUnitCode); for (let i = 0; i < adSlots.length; i++) { if (isMatchingAdSlot(adSlots[i])) { const id = adSlots[i].getSlotElementId(); - utils.logInfo(`[33Across Adapter] Map ad unit path to HTML element id: '${adUnitCode}' -> ${id}`); + logInfo(`[33Across Adapter] Map ad unit path to HTML element id: '${adUnitCode}' -> ${id}`); return id; } } } - utils.logWarn(`[33Across Adapter] Unable to locate element for ad unit code: '${adUnitCode}'`); + logWarn(`[33Across Adapter] Unable to locate element for ad unit code: '${adUnitCode}'`); return null; } @@ -546,7 +549,7 @@ function contributeViewability(viewabilityAmount) { function _isIframe() { try { - return utils.getWindowSelf() !== utils.getWindowTop(); + return getWindowSelf() !== getWindowTop(); } catch (e) { return true; } @@ -579,7 +582,7 @@ function _createBidResponse(response) { ad: response.seatbid[0].bid[0].adm, ttl: response.seatbid[0].bid[0].ttl || 60, creativeId: response.seatbid[0].bid[0].crid, - mediaType: utils.deepAccess(response.seatbid[0].bid[0], 'ext.ttx.mediaType', BANNER), + mediaType: deepAccess(response.seatbid[0].bid[0], 'ext.ttx.mediaType', BANNER), currency: response.cur, netRevenue: true } @@ -591,7 +594,7 @@ function _createBidResponse(response) { } if (bid.mediaType === VIDEO) { - const vastType = utils.deepAccess(response.seatbid[0].bid[0], 'ext.ttx.vastType', 'xml'); + const vastType = deepAccess(response.seatbid[0].bid[0], 'ext.ttx.vastType', 'xml'); if (vastType === 'xml') { bid.vastXml = bid.ad; diff --git a/modules/a4gBidAdapter.js b/modules/a4gBidAdapter.js index 01c59616dc0..03f9d6fd726 100644 --- a/modules/a4gBidAdapter.js +++ b/modules/a4gBidAdapter.js @@ -1,5 +1,5 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; -import * as utils from '../src/utils.js'; +import { _each } from '../src/utils.js'; const A4G_BIDDER_CODE = 'a4g'; const A4G_CURRENCY = 'USD'; @@ -28,7 +28,7 @@ export const spec = { const sizeParams = []; const zoneIds = []; - utils._each(validBidRequests, function(bid) { + _each(validBidRequests, function(bid) { if (!deliveryUrl && typeof bid.params.deliveryUrl === 'string') { deliveryUrl = bid.params.deliveryUrl; } @@ -66,7 +66,7 @@ export const spec = { interpretResponse: function(serverResponses, request) { const bidResponses = []; - utils._each(serverResponses.body, function(response) { + _each(serverResponses.body, function(response) { if (response.cpm > 0) { const bidResponse = { requestId: response.id, diff --git a/modules/ablidaBidAdapter.js b/modules/ablidaBidAdapter.js index 2400952367f..cb4f4ef2724 100644 --- a/modules/ablidaBidAdapter.js +++ b/modules/ablidaBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { triggerPixel } from '../src/utils.js'; import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; @@ -79,7 +79,7 @@ export const spec = { }, onBidWon: function (bid) { if (!bid['nurl']) { return; } - utils.triggerPixel(bid['nurl']); + triggerPixel(bid['nurl']); } }; diff --git a/modules/adagioAnalyticsAdapter.js b/modules/adagioAnalyticsAdapter.js index fd7a742d9e7..f929f7e660b 100644 --- a/modules/adagioAnalyticsAdapter.js +++ b/modules/adagioAnalyticsAdapter.js @@ -5,7 +5,7 @@ import adapter from '../src/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; -import * as utils from '../src/utils.js'; +import { getWindowTop } from '../src/utils.js'; const emptyUrl = ''; const analyticsType = 'endpoint'; @@ -13,12 +13,12 @@ const events = Object.keys(CONSTANTS.EVENTS).map(key => CONSTANTS.EVENTS[key]); const VERSION = '2.0.0'; const adagioEnqueue = function adagioEnqueue(action, data) { - utils.getWindowTop().ADAGIO.queue.push({ action, data, ts: Date.now() }); + getWindowTop().ADAGIO.queue.push({ action, data, ts: Date.now() }); } function canAccessTopWindow() { try { - if (utils.getWindowTop().location.href) { + if (getWindowTop().location.href) { return true; } } catch (error) { @@ -41,7 +41,7 @@ adagioAdapter.enableAnalytics = config => { return; } - const w = utils.getWindowTop(); + const w = getWindowTop(); w.ADAGIO = w.ADAGIO || {}; w.ADAGIO.queue = w.ADAGIO.queue || []; diff --git a/modules/adagioBidAdapter.js b/modules/adagioBidAdapter.js index ffa955290be..264cf5f9fcb 100644 --- a/modules/adagioBidAdapter.js +++ b/modules/adagioBidAdapter.js @@ -1,5 +1,8 @@ import find from 'core-js-pure/features/array/find.js'; -import * as utils from '../src/utils.js'; +import { + isInteger, isArray, deepAccess, mergeDeep, logWarn, logInfo, logError, getWindowTop, getWindowSelf, generateUUID, _map, + getDNT, parseUrl, getUniqueIdentifierStr, isNumber, cleanObj, isFn, inIframe, deepClone, getGptSlotInfoForAdUnitCode +} from '../src/utils.js'; import { config } from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import { loadExternalScript } from '../src/adloader.js'; @@ -31,22 +34,22 @@ const DEFAULT_FLOOR = 0.1; // https://www.iab.com/wp-content/uploads/2016/03/OpenRTB-API-Specification-Version-2-5-FINAL.pdf export const ORTB_VIDEO_PARAMS = { 'mimes': (value) => Array.isArray(value) && value.length > 0 && value.every(v => typeof v === 'string'), - 'minduration': (value) => utils.isInteger(value), - 'maxduration': (value) => utils.isInteger(value), + 'minduration': (value) => isInteger(value), + 'maxduration': (value) => isInteger(value), 'protocols': (value) => Array.isArray(value) && value.every(v => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].indexOf(v) !== -1), - 'w': (value) => utils.isInteger(value), - 'h': (value) => utils.isInteger(value), - 'startdelay': (value) => utils.isInteger(value), + 'w': (value) => isInteger(value), + 'h': (value) => isInteger(value), + 'startdelay': (value) => isInteger(value), 'placement': (value) => Array.isArray(value) && value.every(v => [1, 2, 3, 4, 5].indexOf(v) !== -1), 'linearity': (value) => [1, 2].indexOf(value) !== -1, 'skip': (value) => [0, 1].indexOf(value) !== -1, - 'skipmin': (value) => utils.isInteger(value), - 'skipafter': (value) => utils.isInteger(value), - 'sequence': (value) => utils.isInteger(value), + 'skipmin': (value) => isInteger(value), + 'skipafter': (value) => isInteger(value), + 'sequence': (value) => isInteger(value), 'battr': (value) => Array.isArray(value) && value.every(v => Array.from({length: 17}, (_, i) => i + 1).indexOf(v) !== -1), - 'maxextended': (value) => utils.isInteger(value), - 'minbitrate': (value) => utils.isInteger(value), - 'maxbitrate': (value) => utils.isInteger(value), + 'maxextended': (value) => isInteger(value), + 'minbitrate': (value) => isInteger(value), + 'maxbitrate': (value) => isInteger(value), 'boxingallowed': (value) => [0, 1].indexOf(value) !== -1, 'playbackmethod': (value) => Array.isArray(value) && value.every(v => [1, 2, 3, 4, 5, 6].indexOf(v) !== -1), 'playbackend': (value) => [1, 2, 3].indexOf(value) !== -1, @@ -88,7 +91,7 @@ export const GlobalExchange = (function() { return value; } }); - let random = utils.deepAccess(adagioStorage, 'session.rnd'); + let random = deepAccess(adagioStorage, 'session.rnd'); let newSession = false; if (internal.isNewSession(adagioStorage)) { @@ -103,7 +106,7 @@ export const GlobalExchange = (function() { } } - utils.mergeDeep(exchangeData, adagioStorage, data); + mergeDeep(exchangeData, adagioStorage, data); internal.enqueue({ action: 'session', @@ -121,14 +124,14 @@ export const GlobalExchange = (function() { export function adagioScriptFromLocalStorageCb(ls) { try { if (!ls) { - utils.logWarn(`${LOG_PREFIX} script not found.`); + logWarn(`${LOG_PREFIX} script not found.`); return; } const hashRgx = /^(\/\/ hash: (.+)\n)(.+\n)$/; if (!hashRgx.test(ls)) { - utils.logWarn(`${LOG_PREFIX} no hash found.`); + logWarn(`${LOG_PREFIX} no hash found.`); storage.removeDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY); } else { const r = ls.match(hashRgx); @@ -136,15 +139,15 @@ export function adagioScriptFromLocalStorageCb(ls) { const content = r[3]; if (verify(content, hash, ADAGIO_PUBKEY, ADAGIO_PUBKEY_E)) { - utils.logInfo(`${LOG_PREFIX} start script.`); + logInfo(`${LOG_PREFIX} start script.`); Function(ls)(); // eslint-disable-line no-new-func } else { - utils.logWarn(`${LOG_PREFIX} invalid script found.`); + logWarn(`${LOG_PREFIX} invalid script found.`); storage.removeDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY); } } } catch (err) { - utils.logError(LOG_PREFIX, err); + logError(LOG_PREFIX, err); } } @@ -167,7 +170,7 @@ export function getAdagioScript() { // This key is removed only if localStorage is not accessible. window.localStorage.removeItem('adagio'); } catch (e) { - utils.logInfo(`${LOG_PREFIX} unable to clear Adagio scripts from localstorage.`); + logInfo(`${LOG_PREFIX} unable to clear Adagio scripts from localstorage.`); } } }); @@ -175,7 +178,7 @@ export function getAdagioScript() { function canAccessTopWindow() { try { - if (utils.getWindowTop().location.href) { + if (getWindowTop().location.href) { return true; } } catch (error) { @@ -184,17 +187,17 @@ function canAccessTopWindow() { } function getCurrentWindow() { - return currentWindow || utils.getWindowSelf(); + return currentWindow || getWindowSelf(); } function isSafeFrameWindow() { - const ws = utils.getWindowSelf(); + const ws = getWindowSelf(); return !!(ws.$sf && ws.$sf.ext); } function initAdagio() { if (canAccessTopWindow()) { - currentWindow = (canAccessTopWindow()) ? utils.getWindowTop() : utils.getWindowSelf(); + currentWindow = (canAccessTopWindow()) ? getWindowTop() : getWindowSelf(); } const w = internal.getCurrentWindow(); @@ -211,7 +214,7 @@ function initAdagio() { try { GlobalExchange.prepareExchangeData(storageData); } catch (e) { - utils.logError(LOG_PREFIX, e); + logError(LOG_PREFIX, e); } }); @@ -230,7 +233,7 @@ function getPageviewId() { const w = internal.getCurrentWindow(); w.ADAGIO = w.ADAGIO || {}; - w.ADAGIO.pageviewId = w.ADAGIO.pageviewId || utils.generateUUID(); + w.ADAGIO.pageviewId = w.ADAGIO.pageviewId || generateUUID(); return w.ADAGIO.pageviewId; }; @@ -240,7 +243,7 @@ function getDevice() { return { userAgent: navigator.userAgent, language: navigator[language], - dnt: utils.getDNT() ? 1 : 0, + dnt: getDNT() ? 1 : 0, geo: {}, js: 1 }; @@ -254,12 +257,12 @@ 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]) { @@ -267,7 +270,7 @@ function getSite(bidderRequest) { // will be considered as "localhost" by the parseUrl function. // As the isBidRequestValid returns false when it does not reach the referer // this should never called. - const url = utils.parseUrl(refererInfo.stack[0]); + const url = parseUrl(refererInfo.stack[0]); domain = url.hostname; } @@ -280,9 +283,9 @@ function getSite(bidderRequest) { function getElementFromTopWindow(element, currentWindow) { try { - if (utils.getWindowTop() === currentWindow) { + if (getWindowTop() === currentWindow) { if (!element.getAttribute('id')) { - element.setAttribute('id', `adg-${utils.getUniqueIdentifierStr()}`); + element.setAttribute('id', `adg-${getUniqueIdentifierStr()}`); } return element; } else { @@ -297,13 +300,13 @@ function getElementFromTopWindow(element, currentWindow) { return getElementFromTopWindow(frame, currentWindow.parent); } } catch (err) { - utils.logWarn(`${LOG_PREFIX}`, err); + logWarn(`${LOG_PREFIX}`, err); return false; } }; function autoDetectAdUnitElementIdFromGpt(adUnitCode) { - const autoDetectedAdUnit = utils.getGptSlotInfoForAdUnitCode(adUnitCode); + const autoDetectedAdUnit = getGptSlotInfoForAdUnitCode(adUnitCode); if (autoDetectedAdUnit && autoDetectedAdUnit.divId) { return autoDetectedAdUnit.divId; @@ -312,11 +315,11 @@ function autoDetectAdUnitElementIdFromGpt(adUnitCode) { function isRendererPreferredFromPublisher(bidRequest) { // renderer defined at adUnit level - const adUnitRenderer = utils.deepAccess(bidRequest, 'renderer'); + const adUnitRenderer = deepAccess(bidRequest, 'renderer'); const hasValidAdUnitRenderer = !!(adUnitRenderer && adUnitRenderer.url && adUnitRenderer.render); // renderer defined at adUnit.mediaTypes level - const mediaTypeRenderer = utils.deepAccess(bidRequest, 'mediaTypes.video.renderer'); + const mediaTypeRenderer = deepAccess(bidRequest, 'mediaTypes.video.renderer'); const hasValidMediaTypeRenderer = !!(mediaTypeRenderer && mediaTypeRenderer.url && mediaTypeRenderer.render); return !!( @@ -332,10 +335,10 @@ function isRendererPreferredFromPublisher(bidRequest) { */ function isNewSession(adagioStorage) { const now = Date.now(); - const { lastActivityTime, vwSmplg } = utils.deepAccess(adagioStorage, 'session', {}); + const { lastActivityTime, vwSmplg } = deepAccess(adagioStorage, 'session', {}); return ( - !utils.isNumber(lastActivityTime) || - !utils.isNumber(vwSmplg) || + !isNumber(lastActivityTime) || + !isNumber(vwSmplg) || (now - lastActivityTime) > MAX_SESS_DURATION ) } @@ -344,7 +347,7 @@ function setPlayerName(bidRequest) { const playerName = (internal.isRendererPreferredFromPublisher(bidRequest)) ? 'other' : 'adagio'; if (playerName === 'other') { - utils.logWarn(`${LOG_PREFIX} renderer.backupOnly has not been set. Adagio recommends to use its own player to get expected behavior.`); + logWarn(`${LOG_PREFIX} renderer.backupOnly has not been set. Adagio recommends to use its own player to get expected behavior.`); } return playerName; @@ -365,7 +368,7 @@ export const internal = { }; function _getGdprConsent(bidderRequest) { - if (!utils.deepAccess(bidderRequest, 'gdprConsent')) { + if (!deepAccess(bidderRequest, 'gdprConsent')) { return false; } @@ -376,7 +379,7 @@ function _getGdprConsent(bidderRequest) { allowAuctionWithoutConsent } = bidderRequest.gdprConsent; - return utils.cleanObj({ + return cleanObj({ apiVersion, consentString, consentRequired: gdprApplies ? 1 : 0, @@ -391,22 +394,22 @@ function _getCoppa() { } function _getUspConsent(bidderRequest) { - return (utils.deepAccess(bidderRequest, 'uspConsent')) ? { uspConsent: bidderRequest.uspConsent } : false; + return (deepAccess(bidderRequest, 'uspConsent')) ? { uspConsent: bidderRequest.uspConsent } : false; } function _getSchain(bidRequest) { - return utils.deepAccess(bidRequest, 'schain'); + return deepAccess(bidRequest, 'schain'); } function _getEids(bidRequest) { - if (utils.deepAccess(bidRequest, 'userId')) { + if (deepAccess(bidRequest, 'userId')) { return createEidsArray(bidRequest.userId); } } function _buildVideoBidRequest(bidRequest) { - const videoAdUnitParams = utils.deepAccess(bidRequest, 'mediaTypes.video', {}); - const videoBidderParams = utils.deepAccess(bidRequest, 'params.video', {}); + const videoAdUnitParams = deepAccess(bidRequest, 'mediaTypes.video', {}); + const videoBidderParams = deepAccess(bidRequest, 'params.video', {}); const computedParams = {}; // Special case for playerSize. @@ -436,7 +439,7 @@ function _buildVideoBidRequest(bidRequest) { bidRequest.mediaTypes.video[paramName] = videoParams[paramName]; } else { delete bidRequest.mediaTypes.video[paramName]; - utils.logWarn(`${LOG_PREFIX} The OpenRTB video param ${paramName} has been skipped due to misformating. Please refer to OpenRTB 2.5 spec.`); + logWarn(`${LOG_PREFIX} The OpenRTB video param ${paramName} has been skipped due to misformating. Please refer to OpenRTB 2.5 spec.`); } } }); @@ -447,14 +450,14 @@ function _renderer(bid) { if (typeof window.ADAGIO.outstreamPlayer === 'function') { window.ADAGIO.outstreamPlayer(bid); } else { - utils.logError(`${LOG_PREFIX} Adagio outstream player is not defined`); + logError(`${LOG_PREFIX} Adagio outstream player is not defined`); } }); } function _parseNativeBidResponse(bid) { if (!bid.admNative || !Array.isArray(bid.admNative.assets)) { - utils.logError(`${LOG_PREFIX} Invalid native response`); + logError(`${LOG_PREFIX} Invalid native response`); return; } @@ -559,7 +562,7 @@ function _parseNativeBidResponse(bid) { } function _getFloors(bidRequest) { - if (!utils.isFn(bidRequest.getFloor)) { + if (!isFn(bidRequest.getFloor)) { return false; } @@ -572,9 +575,9 @@ function _getFloors(bidRequest) { size: [] }); - floors.push(utils.cleanObj({ + floors.push(cleanObj({ mt: mediaType, - s: utils.isArray(size) ? `${size[0]}x${size[1]}` : undefined, + s: isArray(size) ? `${size[0]}x${size[1]}` : undefined, f: (!isNaN(info.floor) && info.currency === CURRENCY) ? info.floor : DEFAULT_FLOOR })); } @@ -584,7 +587,7 @@ function _getFloors(bidRequest) { const sizeProp = mediaType === VIDEO ? 'playerSize' : 'sizes'; if (bidRequest.mediaTypes[mediaType][sizeProp] && bidRequest.mediaTypes[mediaType][sizeProp].length) { - if (utils.isArray(bidRequest.mediaTypes[mediaType][sizeProp][0])) { + if (isArray(bidRequest.mediaTypes[mediaType][sizeProp][0])) { bidRequest.mediaTypes[mediaType][sizeProp].forEach(size => { getAndPush(mediaType, [size[0], size[1]]); }); @@ -621,7 +624,7 @@ export function setExtraParam(bid, paramName) { const adgGlobalConf = config.getConfig('adagio') || {}; const ortb2Conf = config.getConfig('ortb2'); - const detected = adgGlobalConf[paramName] || utils.deepAccess(ortb2Conf, `site.ext.data.${paramName}`, null); + const detected = adgGlobalConf[paramName] || deepAccess(ortb2Conf, `site.ext.data.${paramName}`, null); if (detected) { bid.params[paramName] = detected; } @@ -644,7 +647,7 @@ function autoFillParams(bid) { bid.params.placement = bid.adUnitCode; } - bid.params.adUnitElementId = utils.deepAccess(bid, 'ortb2Imp.ext.data.elementId', null) || bid.params.adUnitElementId; + bid.params.adUnitElementId = deepAccess(bid, 'ortb2Imp.ext.data.elementId', null) || bid.params.adUnitElementId; if (!bid.params.adUnitElementId) { if (adgGlobalConf.useAdUnitCodeAsAdUnitElementId === true || bid.params.useAdUnitCodeAsAdUnitElementId === true) { @@ -667,7 +670,7 @@ function getPageDimensions() { } // the page dimension can be computed on window.top only. - const wt = utils.getWindowTop(); + const wt = getWindowTop(); const body = wt.document.querySelector('body'); if (!body) { @@ -692,17 +695,17 @@ function getViewPortDimensions() { const viewportDims = { w: 0, h: 0 }; if (isSafeFrameWindow()) { - const ws = utils.getWindowSelf(); + const ws = getWindowSelf(); if (typeof ws.$sf.ext.geom !== 'function') { - utils.logWarn(LOG_PREFIX, 'Unable to compute from safeframe api.'); + logWarn(LOG_PREFIX, 'Unable to compute from safeframe api.'); return ''; } const sfGeom = ws.$sf.ext.geom(); if (!sfGeom || !sfGeom.win) { - utils.logWarn(LOG_PREFIX, 'Unable to compute from safeframe api. Missing `geom().win` property'); + logWarn(LOG_PREFIX, 'Unable to compute from safeframe api. Missing `geom().win` property'); return ''; } @@ -710,7 +713,7 @@ function getViewPortDimensions() { viewportDims.h = Math.round(sfGeom.h); } else { // window.top based computing - const wt = utils.getWindowTop(); + const wt = getWindowTop(); viewportDims.w = wt.innerWidth; viewportDims.h = wt.innerHeight; } @@ -730,17 +733,17 @@ function getSlotPosition(adUnitElementId) { const position = { x: 0, y: 0 }; if (isSafeFrameWindow()) { - const ws = utils.getWindowSelf(); + const ws = getWindowSelf(); if (typeof ws.$sf.ext.geom !== 'function') { - utils.logWarn(LOG_PREFIX, 'Unable to compute from safeframe api.'); + logWarn(LOG_PREFIX, 'Unable to compute from safeframe api.'); return ''; } const sfGeom = ws.$sf.ext.geom(); if (!sfGeom || !sfGeom.self) { - utils.logWarn(LOG_PREFIX, 'Unable to compute from safeframe api. Missing `geom().self` property'); + logWarn(LOG_PREFIX, 'Unable to compute from safeframe api. Missing `geom().self` property'); return ''; } @@ -748,13 +751,13 @@ function getSlotPosition(adUnitElementId) { position.y = Math.round(sfGeom.l); } else if (canAccessTopWindow()) { // window.top based computing - const wt = utils.getWindowTop(); + const wt = getWindowTop(); const d = wt.document; let domElement; - if (utils.inIframe() === true) { - const ws = utils.getWindowSelf(); + if (inIframe() === true) { + const ws = getWindowSelf(); const currentElement = ws.document.getElementById(adUnitElementId); domElement = internal.getElementFromTopWindow(currentElement, ws); } else { @@ -813,7 +816,7 @@ function getDomLoadingDuration() { let domLoadingDuration = -1; let performance; - performance = (canAccessTopWindow()) ? utils.getWindowTop().performance : utils.getWindowSelf().performance; + performance = (canAccessTopWindow()) ? getWindowTop().performance : getWindowSelf().performance; if (performance && performance.timing && performance.timing.navigationStart > 0) { const val = performance.timing.domLoading - performance.timing.navigationStart; @@ -871,13 +874,13 @@ export const spec = { autoFillParams(bid); if (!internal.getRefererInfo().reachedTop) { - utils.logWarn(`${LOG_PREFIX} the main page url is unreachabled.`); + logWarn(`${LOG_PREFIX} the main page url is unreachabled.`); // internal.enqueue(debugData()); return false; } if (!(bid.params.organizationId && bid.params.site && bid.params.placement)) { - utils.logWarn(`${LOG_PREFIX} at least one required param is missing.`); + logWarn(`${LOG_PREFIX} at least one required param is missing.`); // internal.enqueue(debugData()); return false; } @@ -896,7 +899,7 @@ export const spec = { const schain = _getSchain(validBidRequests[0]); const eids = _getEids(validBidRequests[0]) || []; - const adUnits = utils._map(validBidRequests, (bidRequest) => { + const adUnits = _map(validBidRequests, (bidRequest) => { const globalFeatures = GlobalExchange.getOrSetGlobalFeatures(); const features = { ...globalFeatures, @@ -925,7 +928,7 @@ export const spec = { // Handle priceFloors module bidRequest.floors = _getFloors(bidRequest); - if (utils.deepAccess(bidRequest, 'mediaTypes.video')) { + if (deepAccess(bidRequest, 'mediaTypes.video')) { _buildVideoBidRequest(bidRequest); } @@ -936,7 +939,7 @@ export const spec = { // Group ad units by organizationId const groupedAdUnits = adUnits.reduce((groupedAdUnits, adUnit) => { - const adUnitCopy = utils.deepClone(adUnit); + const adUnitCopy = deepClone(adUnit); adUnitCopy.params.organizationId = adUnitCopy.params.organizationId.toString(); // remove useless props @@ -950,12 +953,12 @@ export const spec = { }, {}); // Build one request per organizationId - const requests = utils._map(Object.keys(groupedAdUnits), organizationId => { + const requests = _map(Object.keys(groupedAdUnits), organizationId => { return { method: 'POST', url: ENDPOINT, data: { - id: utils.generateUUID(), + id: generateUUID(), organizationId: organizationId, secure: secure, device: device, @@ -1001,12 +1004,12 @@ export const spec = { const bidReq = (find(bidRequest.data.adUnits, bid => bid.bidId === bidObj.requestId)); if (bidReq) { - bidObj.meta = utils.deepAccess(bidObj, 'meta', {}); + bidObj.meta = deepAccess(bidObj, 'meta', {}); bidObj.meta.mediaType = bidObj.mediaType; bidObj.meta.advertiserDomains = (Array.isArray(bidObj.aDomain) && bidObj.aDomain.length) ? bidObj.aDomain : []; if (bidObj.mediaType === VIDEO) { - const mediaTypeContext = utils.deepAccess(bidReq, 'mediaTypes.video.context'); + const mediaTypeContext = deepAccess(bidReq, 'mediaTypes.video.context'); // Adagio SSP returns a `vastXml` only. No `vastUrl` nor `videoCacheKey`. if (!bidObj.vastUrl && bidObj.vastXml) { bidObj.vastUrl = 'data:text/xml;charset=utf-8;base64,' + btoa(bidObj.vastXml.replace(/\\"/g, '"')); @@ -1018,8 +1021,8 @@ export const spec = { adUnitCode: bidObj.adUnitCode, url: bidObj.urlRenderer || RENDERER_URL, config: { - ...utils.deepAccess(bidReq, 'mediaTypes.video'), - ...utils.deepAccess(bidObj, 'outstream', {}) + ...deepAccess(bidReq, 'mediaTypes.video'), + ...deepAccess(bidObj, 'outstream', {}) } }); @@ -1043,7 +1046,7 @@ export const spec = { } } } catch (err) { - utils.logError(err); + logError(err); } return bidResponses; }, @@ -1077,7 +1080,7 @@ export const spec = { if (isOrtb) { autoFillParams(adagioBid); - adagioBid.params.auctionId = utils.deepAccess(adagioBidderRequest, 'auctionId'); + adagioBid.params.auctionId = deepAccess(adagioBidderRequest, 'auctionId'); const globalFeatures = GlobalExchange.getOrSetGlobalFeatures(); adagioBid.params.features = { @@ -1090,7 +1093,7 @@ export const spec = { adagioBid.params.prebidVersion = '$prebid.version$'; adagioBid.params.data = GlobalExchange.getExchangeData(); - if (utils.deepAccess(adagioBid, 'mediaTypes.video.context') === OUTSTREAM) { + if (deepAccess(adagioBid, 'mediaTypes.video.context') === OUTSTREAM) { adagioBid.params.playerName = setPlayerName(adagioBid); } From 9c7d944ecc597bd0d93aae22b82ff81fee93f1b4 Mon Sep 17 00:00:00 2001 From: Harshad Mane Date: Thu, 23 Sep 2021 20:38:45 -0700 Subject: [PATCH 7/7] import utils as needed; dont import all --- modules/adbookpspBidAdapter.js | 110 +++++++++++++------------ modules/adfBidAdapter.js | 30 +++---- modules/adgenerationBidAdapter.js | 30 +++---- modules/adkernelAdnAnalyticsAdapter.js | 12 +-- modules/adkernelAdnBidAdapter.js | 46 +++++------ 5 files changed, 115 insertions(+), 113 deletions(-) diff --git a/modules/adbookpspBidAdapter.js b/modules/adbookpspBidAdapter.js index d3f3ba295b9..ca4795c574f 100644 --- a/modules/adbookpspBidAdapter.js +++ b/modules/adbookpspBidAdapter.js @@ -3,7 +3,10 @@ import find from 'core-js-pure/features/array/find'; import { config } from '../src/config.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import { getStorageManager } from '../src/storageManager.js'; -import * as utils from '../src/utils.js'; +import { + isPlainObject, deepSetValue, deepAccess, logWarn, inIframe, isNumber, logError, isArray, uniques, + flatten, triggerPixel, isStr, isEmptyStr, generateUUID +} from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; /** @@ -150,7 +153,7 @@ function buildDevice() { const deviceConfig = common.getConfig('device'); - if (utils.isPlainObject(deviceConfig)) { + if (isPlainObject(deviceConfig)) { return { ...device, ...deviceConfig }; } @@ -163,12 +166,12 @@ function buildRegs(bidderRequest) { }; if (bidderRequest.gdprConsent) { - utils.deepSetValue( + deepSetValue( regs, 'ext.gdpr', bidderRequest.gdprConsent.gdprApplies ? 1 : 0 ); - utils.deepSetValue( + deepSetValue( regs, 'ext.gdprConsentString', bidderRequest.gdprConsent.consentString || '' @@ -176,7 +179,7 @@ function buildRegs(bidderRequest) { } if (bidderRequest.uspConsent) { - utils.deepSetValue(regs, 'ext.us_privacy', bidderRequest.uspConsent); + deepSetValue(regs, 'ext.us_privacy', bidderRequest.uspConsent); } return regs; @@ -187,10 +190,10 @@ function buildSource(bidRequests, bidderRequest) { fd: 1, tid: bidderRequest.auctionId, }; - const schain = utils.deepAccess(bidRequests, '0.schain'); + const schain = deepAccess(bidRequests, '0.schain'); if (schain) { - utils.deepSetValue(source, 'ext.schain', schain); + deepSetValue(source, 'ext.schain', schain); } return source; @@ -232,7 +235,7 @@ function buildMediaTypeObject(mediaType, bidRequest) { case VIDEO: return buildVideoObject(bidRequest); default: - utils.logWarn(`${BIDDER_CODE}: Unsupported media type ${mediaType}!`); + logWarn(`${BIDDER_CODE}: Unsupported media type ${mediaType}!`); } } @@ -246,7 +249,7 @@ function buildBannerObject(bidRequest) { return { pos: 0, - topframe: utils.inIframe() ? 0 : 1, + topframe: inIframe() ? 0 : 1, format, w, h, @@ -261,8 +264,8 @@ function buildVideoObject(bidRequest) { }; for (const param of VIDEO_PARAMS) { - const paramsValue = utils.deepAccess(bidRequest, `params.video.${param}`); - const mediaTypeValue = utils.deepAccess( + const paramsValue = deepAccess(bidRequest, `params.video.${param}`); + const mediaTypeValue = deepAccess( bidRequest, `mediaTypes.video.${param}` ); @@ -276,10 +279,10 @@ function buildVideoObject(bidRequest) { } function getVideoSize(bidRequest) { - const playerSize = utils.deepAccess(bidRequest, 'mediaTypes.video.playerSize', [[]]); - const { w, h } = utils.deepAccess(bidRequest, 'mediaTypes.video', {}); + const playerSize = deepAccess(bidRequest, 'mediaTypes.video.playerSize', [[]]); + const { w, h } = deepAccess(bidRequest, 'mediaTypes.video', {}); - if (utils.isNumber(w) && utils.isNumber(h)) { + if (isNumber(w) && isNumber(h)) { return { w, h }; } @@ -296,11 +299,11 @@ function buildImpExt(validBidRequest) { const ext = {}; if (placementId) { - utils.deepSetValue(ext, 'adbook.placementId', placementId); + deepSetValue(ext, 'adbook.placementId', placementId); } if (effectiverOrgId) { - utils.deepSetValue(ext, 'adbook.orgId', effectiverOrgId); + deepSetValue(ext, 'adbook.orgId', effectiverOrgId); } return ext; @@ -314,20 +317,19 @@ function interpretResponse(bidResponse, bidderRequest) { const bidderRequestBody = safeJSONparse(bidderRequest.data); if ( - utils.deepAccess(bidderRequestBody, 'id') != - utils.deepAccess(bidResponse, 'body.id') + deepAccess(bidderRequestBody, 'id') != + deepAccess(bidResponse, 'body.id') ) { - utils.logError( + logError( `${BIDDER_CODE}: Bid response id does not match bidder request id` ); return []; } - const referrer = utils.deepAccess(bidderRequestBody, 'site.ref', ''); - const incomingBids = utils - .deepAccess(bidResponse, 'body.seatbid', []) - .filter((seat) => utils.isArray(seat.bid)) + const referrer = deepAccess(bidderRequestBody, 'site.ref', ''); + const incomingBids = deepAccess(bidResponse, 'body.seatbid', []) + .filter((seat) => isArray(seat.bid)) .reduce((bids, seat) => bids.concat(seat.bid), []) .filter(validateBid(bidderRequestBody)); const targetingMap = buildTargetingMap(incomingBids); @@ -366,11 +368,11 @@ const impToPrebidBid = const bidRequest = findBidRequest(bidderRequestBody, bid); if (!bidRequest) { - utils.logError(`${BIDDER_CODE}: Could not match bid to bid request`); + logError(`${BIDDER_CODE}: Could not match bid to bid request`); return null; } - const categories = utils.deepAccess(bid, 'cat', []); + const categories = deepAccess(bid, 'cat', []); const mediaType = getMediaType(bid.adm); let prebidBid = { ad: bid.adm, @@ -383,7 +385,7 @@ const impToPrebidBid = creativeId: bid.crid || bid.id, currency: bidResponseCurrency || getBidderConfig('defaultCurrency'), height: bid.h, - lineItemId: utils.deepAccess(bid, 'ext.liid'), + lineItemId: deepAccess(bid, 'ext.liid'), mediaType, meta: { advertiserDomains: bid.adomain, @@ -408,7 +410,7 @@ const impToPrebidBid = return prebidBid; } catch (error) { - utils.logError(`${BIDDER_CODE}: Error while building bid`, error); + logError(`${BIDDER_CODE}: Error while building bid`, error); return null; } @@ -423,7 +425,7 @@ function getVideoSpecificParams(bidRequest, bid) { } function buildTargetingMap(bids) { - const impIds = bids.map(({ impid }) => impid).filter(utils.uniques); + const impIds = bids.map(({ impid }) => impid).filter(uniques); const values = impIds.reduce((result, id) => { result[id] = { lineItemIds: [], @@ -459,12 +461,12 @@ function buildTargetingMap(bids) { function hasRequiredParams(bidRequest) { const value = - utils.deepAccess(bidRequest, 'params.placementId') != null || - utils.deepAccess(bidRequest, 'params.orgId') != null || + deepAccess(bidRequest, 'params.placementId') != null || + deepAccess(bidRequest, 'params.orgId') != null || getBidderConfig('orgId') != null; if (!value) { - utils.logError(`${BIDDER_CODE}: missing orgId and placementId parameter`); + logError(`${BIDDER_CODE}: missing orgId and placementId parameter`); } return value; @@ -472,7 +474,7 @@ function hasRequiredParams(bidRequest) { function isValidBannerRequest(bidRequest) { const value = validateSizes( - utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes', []) + deepAccess(bidRequest, 'mediaTypes.banner.sizes', []) ); return value; @@ -480,28 +482,28 @@ function isValidBannerRequest(bidRequest) { function isValidVideoRequest(bidRequest) { const value = - utils.isArray(utils.deepAccess(bidRequest, 'mediaTypes.video.mimes')) && + isArray(deepAccess(bidRequest, 'mediaTypes.video.mimes')) && validateVideoSizes(bidRequest); return value; } function validateSize(size) { - return utils.isArray(size) && size.length === 2 && size.every(utils.isNumber); + return isArray(size) && size.length === 2 && size.every(isNumber); } function validateSizes(sizes) { - return utils.isArray(sizes) && sizes.length > 0 && sizes.every(validateSize); + return isArray(sizes) && sizes.length > 0 && sizes.every(validateSize); } function validateVideoSizes(bidRequest) { - const { w, h } = utils.deepAccess(bidRequest, 'mediaTypes.video', {}); + const { w, h } = deepAccess(bidRequest, 'mediaTypes.video', {}); return ( validateSizes( - utils.deepAccess(bidRequest, 'mediaTypes.video.playerSize') + deepAccess(bidRequest, 'mediaTypes.video.playerSize') ) || - (utils.isNumber(w) && utils.isNumber(h)) + (isNumber(w) && isNumber(h)) ); } @@ -518,7 +520,7 @@ function validateBid(bidderRequestBody) { const value = validators.every((validator) => validator(bid, bidRequest)); if (!value) { - utils.logWarn(`${BIDDER_CODE}: Invalid bid`, bid); + logWarn(`${BIDDER_CODE}: Invalid bid`, bid); } return value; @@ -526,13 +528,13 @@ function validateBid(bidderRequestBody) { } const commonBidValidators = [ - (bid) => utils.isPlainObject(bid), + (bid) => isPlainObject(bid), (bid) => isNonEmptyStr(bid.adid), (bid) => isNonEmptyStr(bid.adm), (bid) => isNonEmptyStr(bid.id), (bid) => isNonEmptyStr(bid.impid), - (bid) => isNonEmptyStr(utils.deepAccess(bid, 'ext.liid')), - (bid) => utils.isNumber(bid.price), + (bid) => isNonEmptyStr(deepAccess(bid, 'ext.liid')), + (bid) => isNumber(bid.price), ]; const bannerBidValidators = [ @@ -546,12 +548,12 @@ function validateBannerDimension(dimension) { return bannerHasSingleSize(bidRequest); } - return utils.isNumber(bid[dimension]); + return isNumber(bid[dimension]); }; } function bannerHasSingleSize(bidRequest) { - return utils.deepAccess(bidRequest, 'banner.format', []).length === 1; + return deepAccess(bidRequest, 'banner.format', []).length === 1; } /** @@ -562,9 +564,9 @@ export const storage = getStorageManager(); function getUserSyncs(syncOptions, responses, gdprConsent, uspConsent) { return responses - .map((response) => utils.deepAccess(response, 'body.ext.sync')) - .filter(utils.isArray) - .reduce(utils.flatten, []) + .map((response) => deepAccess(response, 'body.ext.sync')) + .filter(isArray) + .reduce(flatten, []) .filter(validateSync(syncOptions)) .map(applyConsents(gdprConsent, uspConsent)); } @@ -644,11 +646,11 @@ function onBidWon(bid) { const wurl = buildWinUrl(bid); if (wurl !== null) { - utils.triggerPixel(wurl); + triggerPixel(wurl); } - if (utils.isStr(bid.nurl)) { - utils.triggerPixel(bid.nurl); + if (isStr(bid.nurl)) { + triggerPixel(bid.nurl); } } @@ -662,7 +664,7 @@ function buildWinUrl(bid) { return url.toString(); } catch (_) { - utils.logError( + logError( `${BIDDER_CODE}: Could not build win tracking URL with %s`, getBidderConfig('winTrackingUrl') ); @@ -686,7 +688,7 @@ function getMediaType(adm) { const markup = safeJSONparse(adm.replace(/\\/g, '')); - if (markup && utils.isPlainObject(markup.native)) { + if (markup && isPlainObject(markup.native)) { return NATIVE; } @@ -702,7 +704,7 @@ function safeJSONparse(...args) { } function isNonEmptyStr(value) { - return utils.isStr(value) && !utils.isEmptyStr(value); + return isStr(value) && !isEmptyStr(value); } function findBidRequest(bidderRequest, bid) { @@ -782,7 +784,7 @@ const getUrlBuilder = function (url) { export const common = { generateUUID: function () { - return utils.generateUUID(); + return generateUUID(); }, getConfig: function (property) { return config.getConfig(property); diff --git a/modules/adfBidAdapter.js b/modules/adfBidAdapter.js index 2153f12316f..f7727a168b8 100644 --- a/modules/adfBidAdapter.js +++ b/modules/adfBidAdapter.js @@ -7,7 +7,7 @@ import { import { NATIVE, BANNER, VIDEO } from '../src/mediaTypes.js'; -import * as utils from '../src/utils.js'; +import { mergeDeep, _map, deepAccess, parseSizesInput, deepSetValue } from '../src/utils.js'; import { config } from '../src/config.js'; import { Renderer } from '../src/Renderer.js'; @@ -68,12 +68,12 @@ export const spec = { if (typeof getConfig('app') === 'object') { app = getConfig('app') || {}; if (commonFpd.app) { - utils.mergeDeep(app, commonFpd.app); + mergeDeep(app, commonFpd.app); } } else { site = getConfig('site') || {}; if (commonFpd.site) { - utils.mergeDeep(site, commonFpd.site); + mergeDeep(site, commonFpd.site); } if (!site.page) { @@ -112,7 +112,7 @@ export const spec = { bidfloorcur }; - const assets = utils._map(bid.nativeParams, (bidParams, key) => { + const assets = _map(bid.nativeParams, (bidParams, key) => { const props = NATIVE_PARAMS[key]; const asset = { required: bidParams.required & 1, @@ -158,10 +158,10 @@ export const spec = { return imp; } - const bannerParams = utils.deepAccess(bid, 'mediaTypes.banner'); + const bannerParams = deepAccess(bid, 'mediaTypes.banner'); if (bannerParams && bannerParams.sizes) { - const sizes = utils.parseSizesInput(bannerParams.sizes); + const sizes = parseSizesInput(bannerParams.sizes); const format = sizes.map(size => { const [ width, height ] = size.split('x'); const w = parseInt(width, 10); @@ -177,7 +177,7 @@ export const spec = { return imp; } - const videoParams = utils.deepAccess(bid, 'mediaTypes.video'); + const videoParams = deepAccess(bid, 'mediaTypes.video'); if (videoParams) { imp.video = videoParams; bid.mediaType = VIDEO; @@ -202,21 +202,21 @@ export const spec = { request.is_debug = !!test; request.test = 1; } - if (utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies') !== undefined) { - utils.deepSetValue(request, 'user.ext.consent', bidderRequest.gdprConsent.consentString); - utils.deepSetValue(request, 'regs.ext.gdpr', bidderRequest.gdprConsent.gdprApplies & 1); + if (deepAccess(bidderRequest, 'gdprConsent.gdprApplies') !== undefined) { + deepSetValue(request, 'user.ext.consent', bidderRequest.gdprConsent.consentString); + deepSetValue(request, 'regs.ext.gdpr', bidderRequest.gdprConsent.gdprApplies & 1); } if (bidderRequest.uspConsent) { - utils.deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent); + deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent); } if (eids) { - utils.deepSetValue(request, 'user.ext.eids', eids); + deepSetValue(request, 'user.ext.eids', eids); } if (schain) { - utils.deepSetValue(request, 'source.ext.schain', schain); + deepSetValue(request, 'source.ext.schain', schain); } return { @@ -266,7 +266,7 @@ export const spec = { result[ bid.mediaType === VIDEO ? 'vastXml' : 'ad' ] = bidResponse.adm; } - if (!bid.renderer && bid.mediaType === VIDEO && utils.deepAccess(bid, 'mediaTypes.video.context') === 'outstream') { + if (!bid.renderer && bid.mediaType === VIDEO && deepAccess(bid, 'mediaTypes.video.context') === 'outstream') { result.renderer = Renderer.install({id: bid.bidId, url: OUTSTREAM_RENDERER_URL, adUnitCode: bid.adUnitCode}); result.renderer.setRender(renderer); } @@ -300,7 +300,7 @@ function parseNative(bid) { function setOnAny(collection, key) { for (let i = 0, result; i < collection.length; i++) { - result = utils.deepAccess(collection[i], key); + result = deepAccess(collection[i], key); if (result) { return result; } diff --git a/modules/adgenerationBidAdapter.js b/modules/adgenerationBidAdapter.js index f43fd284bad..2696915ea0a 100644 --- a/modules/adgenerationBidAdapter.js +++ b/modules/adgenerationBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { tryAppendQueryString, getBidIdParameter } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; @@ -33,23 +33,23 @@ export const spec = { const URL = 'https://d.socdm.com/adsv/v1'; const url = validReq.params.debug ? DEBUG_URL : URL; let data = ``; - data = utils.tryAppendQueryString(data, 'posall', 'SSPLOC'); - const id = utils.getBidIdParameter('id', validReq.params); - data = utils.tryAppendQueryString(data, 'id', id); - data = utils.tryAppendQueryString(data, 'sdktype', '0'); - data = utils.tryAppendQueryString(data, 'hb', 'true'); - data = utils.tryAppendQueryString(data, 't', 'json3'); - data = utils.tryAppendQueryString(data, 'transactionid', validReq.transactionId); - data = utils.tryAppendQueryString(data, 'sizes', getSizes(validReq)); - data = utils.tryAppendQueryString(data, 'currency', getCurrencyType()); - data = utils.tryAppendQueryString(data, 'pbver', '$prebid.version$'); - data = utils.tryAppendQueryString(data, 'sdkname', 'prebidjs'); - data = utils.tryAppendQueryString(data, 'adapterver', ADGENE_PREBID_VERSION); + data = tryAppendQueryString(data, 'posall', 'SSPLOC'); + const id = getBidIdParameter('id', validReq.params); + data = tryAppendQueryString(data, 'id', id); + data = tryAppendQueryString(data, 'sdktype', '0'); + data = tryAppendQueryString(data, 'hb', 'true'); + data = tryAppendQueryString(data, 't', 'json3'); + data = tryAppendQueryString(data, 'transactionid', validReq.transactionId); + data = tryAppendQueryString(data, 'sizes', getSizes(validReq)); + data = tryAppendQueryString(data, 'currency', getCurrencyType()); + data = tryAppendQueryString(data, 'pbver', '$prebid.version$'); + data = tryAppendQueryString(data, 'sdkname', 'prebidjs'); + data = tryAppendQueryString(data, 'adapterver', ADGENE_PREBID_VERSION); // native以外にvideo等の対応が入った場合は要修正 if (!validReq.mediaTypes || !validReq.mediaTypes.native) { - data = utils.tryAppendQueryString(data, 'imark', '1'); + data = tryAppendQueryString(data, 'imark', '1'); } - data = utils.tryAppendQueryString(data, 'tp', bidderRequest.refererInfo.referer); + data = tryAppendQueryString(data, 'tp', bidderRequest.refererInfo.referer); // remove the trailing "&" if (data.lastIndexOf('&') === data.length - 1) { data = data.substring(0, data.length - 1); diff --git a/modules/adkernelAdnAnalyticsAdapter.js b/modules/adkernelAdnAnalyticsAdapter.js index 23501f7dd63..2b4e67736f3 100644 --- a/modules/adkernelAdnAnalyticsAdapter.js +++ b/modules/adkernelAdnAnalyticsAdapter.js @@ -1,7 +1,7 @@ import adapter from '../src/AnalyticsAdapter.js'; import CONSTANTS from '../src/constants.json'; import adapterManager from '../src/adapterManager.js'; -import * as utils from '../src/utils.js'; +import { logError, parseUrl, _each } from '../src/utils.js'; import {ajax} from '../src/ajax.js'; import {getStorageManager} from '../src/storageManager.js'; import {config} from '../src/config.js'; @@ -90,7 +90,7 @@ analyticsAdapter.originEnableAnalytics = analyticsAdapter.enableAnalytics; analyticsAdapter.enableAnalytics = (config) => { if (!config.options.pubId) { - utils.logError('PubId is not defined. Analytics won\'t work'); + logError('PubId is not defined. Analytics won\'t work'); return; } analyticsAdapter.context = { @@ -215,7 +215,7 @@ export function getUmtSource(pageUrl, referrer) { if (se) { return asUtm(se, ORGANIC, ORGANIC); } - let parsedUrl = utils.parseUrl(pageUrl); + let parsedUrl = parseUrl(pageUrl); let [refHost, refPath] = getReferrer(referrer); if (refHost && refHost !== parsedUrl.hostname) { return asUtm(refHost, REFERRAL, REFERRAL, '', refPath); @@ -242,17 +242,17 @@ export function getUmtSource(pageUrl, referrer) { } function getReferrer(referrer) { - let ref = utils.parseUrl(referrer); + let ref = parseUrl(referrer); return [ref.hostname, ref.pathname]; } function getUTM(pageUrl) { - let urlParameters = utils.parseUrl(pageUrl).search; + let urlParameters = parseUrl(pageUrl).search; if (!urlParameters['utm_campaign'] || !urlParameters['utm_source']) { return; } let utmArgs = []; - utils._each(UTM_TAGS, (utmTagName) => { + _each(UTM_TAGS, (utmTagName) => { let utmValue = urlParameters[utmTagName] || ''; utmArgs.push(utmValue); }); diff --git a/modules/adkernelAdnBidAdapter.js b/modules/adkernelAdnBidAdapter.js index dc56ed6abbb..39f7b9fd2b2 100644 --- a/modules/adkernelAdnBidAdapter.js +++ b/modules/adkernelAdnBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { deepAccess, parseSizesInput, isArray, deepSetValue, parseUrl, isStr, isNumber, logInfo } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; @@ -19,12 +19,12 @@ function buildImp(bidRequest) { tagid: bidRequest.adUnitCode }; let mediaType; - let bannerReq = utils.deepAccess(bidRequest, `mediaTypes.banner`); - let videoReq = utils.deepAccess(bidRequest, `mediaTypes.video`); + let bannerReq = deepAccess(bidRequest, `mediaTypes.banner`); + let videoReq = deepAccess(bidRequest, `mediaTypes.video`); if (bannerReq) { let sizes = canonicalizeSizesArray(bannerReq.sizes); imp.banner = { - format: utils.parseSizesInput(sizes) + format: parseSizesInput(sizes) }; mediaType = BANNER; } else if (videoReq) { @@ -51,7 +51,7 @@ function buildImp(bidRequest) { * @return Array[Array[Number]] */ function canonicalizeSizesArray(sizes) { - if (sizes.length === 2 && !utils.isArray(sizes[0])) { + if (sizes.length === 2 && !isArray(sizes[0])) { return [sizes]; } return sizes; @@ -67,23 +67,23 @@ function buildRequestParams(tags, bidderRequest) { }; if (gdprConsent) { if (gdprConsent.gdprApplies !== undefined) { - utils.deepSetValue(req, 'user.gdpr', ~~gdprConsent.gdprApplies); + deepSetValue(req, 'user.gdpr', ~~gdprConsent.gdprApplies); } if (gdprConsent.consentString !== undefined) { - utils.deepSetValue(req, 'user.consent', gdprConsent.consentString); + deepSetValue(req, 'user.consent', gdprConsent.consentString); } } if (uspConsent) { - utils.deepSetValue(req, 'user.us_privacy', uspConsent); + deepSetValue(req, 'user.us_privacy', uspConsent); } if (config.getConfig('coppa')) { - utils.deepSetValue(req, 'user.coppa', 1); + deepSetValue(req, 'user.coppa', 1); } return req; } function buildSite(refInfo) { - let loc = utils.parseUrl(refInfo.referer); + let loc = parseUrl(refInfo.referer); let result = { page: `${loc.protocol}://${loc.hostname}${loc.pathname}`, secure: ~~(loc.protocol === 'https') @@ -126,23 +126,23 @@ function buildBid(tag) { } function fillBidMeta(bid, tag) { - if (utils.isStr(tag.agencyName)) { - utils.deepSetValue(bid, 'meta.agencyName', tag.agencyName); + if (isStr(tag.agencyName)) { + deepSetValue(bid, 'meta.agencyName', tag.agencyName); } - if (utils.isNumber(tag.advertiserId)) { - utils.deepSetValue(bid, 'meta.advertiserId', tag.advertiserId); + if (isNumber(tag.advertiserId)) { + deepSetValue(bid, 'meta.advertiserId', tag.advertiserId); } - if (utils.isStr(tag.advertiserName)) { - utils.deepSetValue(bid, 'meta.advertiserName', tag.advertiserName); + if (isStr(tag.advertiserName)) { + deepSetValue(bid, 'meta.advertiserName', tag.advertiserName); } - if (utils.isArray(tag.advertiserDomains)) { - utils.deepSetValue(bid, 'meta.advertiserDomains', tag.advertiserDomains); + if (isArray(tag.advertiserDomains)) { + deepSetValue(bid, 'meta.advertiserDomains', tag.advertiserDomains); } - if (utils.isStr(tag.primaryCatId)) { - utils.deepSetValue(bid, 'meta.primaryCatId', tag.primaryCatId); + if (isStr(tag.primaryCatId)) { + deepSetValue(bid, 'meta.primaryCatId', tag.primaryCatId); } - if (utils.isArray(tag.secondaryCatIds)) { - utils.deepSetValue(bid, 'meta.secondaryCatIds', tag.secondaryCatIds); + if (isArray(tag.secondaryCatIds)) { + deepSetValue(bid, 'meta.secondaryCatIds', tag.secondaryCatIds); } } @@ -204,7 +204,7 @@ export const spec = { return []; } if (response.debug) { - utils.logInfo(`ADKERNEL DEBUG:\n${response.debug}`); + logInfo(`ADKERNEL DEBUG:\n${response.debug}`); } return response.tags.map(buildBid); },