Skip to content

Commit

Permalink
Multiple Bid/Analytics/ID/ other modules: import utils functions as n…
Browse files Browse the repository at this point in the history
…eeded and not the whole module (prebid#7486)

* added support for pubcommon, digitrust, id5id

* added support for IdentityLink

* changed the source for id5

* added unit test cases

* changed source param for identityLink

* import utils functions as needed and not the whole module

* import utils functions as needed and not the whole module

* import utils functions as needed and not the whole module

* Revert "import utils functions as needed and not the whole module"

This reverts commit bc6c9f6.

* Revert "import utils functions as needed and not the whole module"

This reverts commit ef500ab.

* Revert "import utils functions as needed and not the whole module"

This reverts commit 7e3fa3f.

* import utils functions as needed and not the whole module

* import utils functions as needed and not the whole module

* import utils functions as needed and not the whole module
  • Loading branch information
pm-harshad-mane authored and Chris Pabst committed Jan 10, 2022
1 parent 7ae15d6 commit c773d2a
Show file tree
Hide file tree
Showing 15 changed files with 179 additions and 179 deletions.
10 changes: 5 additions & 5 deletions modules/instreamTracking.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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/;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
});
Expand Down
8 changes: 4 additions & 4 deletions modules/integr8BidAdapter.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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)
};
});
Expand Down Expand Up @@ -130,7 +130,7 @@ function generateSizeParam(sizes) {
}

export function getBidFloor(bid) {
if (!utils.isFn(bid.getFloor)) {
if (!isFn(bid.getFloor)) {
return null;
}

Expand All @@ -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;
}

Expand Down
14 changes: 7 additions & 7 deletions modules/intentIqIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -47,7 +47,7 @@ export function readData(key) {
return storage.getCookie(key);
}
} catch (error) {
utils.logError(error);
logError(error);
}
}

Expand All @@ -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()) {
Expand All @@ -71,7 +71,7 @@ function storeData(key, value) {
}
}
} catch (error) {
utils.logError(error);
logError(error);
}
}

Expand All @@ -84,7 +84,7 @@ function tryParse(data) {
try {
return JSON.parse(data);
} catch (err) {
utils.logError(err);
logError(err);
return null;
}
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
}
};
Expand Down
10 changes: 5 additions & 5 deletions modules/interactiveOffersBidAdapter.js
Original file line number Diff line number Diff line change
@@ -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=';
Expand Down Expand Up @@ -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;
Expand Down
22 changes: 11 additions & 11 deletions modules/invibesBidAdapter.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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 [];
}

Expand All @@ -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 {
Expand All @@ -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;
}

Expand Down Expand Up @@ -215,18 +215,18 @@ 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;
}

let bidModel = requestPlacement.BidModel;
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;
}

Expand All @@ -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;
}
}
Expand All @@ -250,15 +250,15 @@ 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;
}
}
}

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,
Expand Down
10 changes: 5 additions & 5 deletions modules/invisiblyAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit c773d2a

Please sign in to comment.