Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Bid/Analytics/ID/ other modules: import utils functions as needed and not the whole module #7495

Merged
merged 90 commits into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
33762d1
added support for pubcommon, digitrust, id5id
pm-harshad-mane Sep 12, 2019
0722354
added support for IdentityLink
pm-harshad-mane Sep 13, 2019
f2c32c0
changed the source for id5
pm-harshad-mane Sep 13, 2019
37163d1
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 13, 2019
eaed987
added unit test cases
pm-harshad-mane Sep 13, 2019
602ee7e
changed source param for identityLink
pm-harshad-mane Sep 16, 2019
b6fcd36
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 23, 2019
58381f3
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 26, 2019
c9fb11b
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Oct 10, 2019
8ece7fd
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Oct 16, 2019
28d12a0
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Oct 16, 2019
05a55e1
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Oct 31, 2019
e8b10d5
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Nov 5, 2019
870085f
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Nov 12, 2019
844ce4e
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Nov 12, 2019
704eca3
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Nov 13, 2019
2565cb9
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 4, 2019
1d75bd4
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 4, 2019
6adde1e
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 6, 2019
477c98a
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 9, 2019
cef5422
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 10, 2019
c110a7d
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jan 9, 2020
e8fb062
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 5, 2020
d77cd71
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 17, 2020
817ce3f
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 24, 2020
cda825e
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 26, 2020
f34a3ec
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 27, 2020
f106dc8
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 4, 2020
1f6937e
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 6, 2020
06ffe84
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 6, 2020
5448ceb
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 6, 2020
e9b90fe
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 11, 2020
a7a1d12
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 11, 2020
30b72df
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 26, 2020
76adbc9
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 30, 2020
50e13bc
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 30, 2020
a1c7ca1
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 30, 2020
96fbadc
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 1, 2020
4b026e2
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 9, 2020
38740bc
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 10, 2020
9daf778
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 20, 2020
eff8828
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 21, 2020
ede95de
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 21, 2020
c98f1a1
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 23, 2020
312da6d
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane May 18, 2020
d92972c
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jun 1, 2020
fd4fb2e
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jun 26, 2020
e551136
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jun 30, 2020
cfdca3c
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jul 7, 2020
22505ff
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jul 28, 2020
795a54a
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Aug 10, 2020
433c98b
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 3, 2020
a0521ac
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 24, 2020
635fe74
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 25, 2020
2759212
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Oct 12, 2020
84737d8
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 2, 2020
df5fada
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 2, 2020
9ab7840
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 2, 2020
ed4b566
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jan 8, 2021
f57d220
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jan 20, 2021
6a6d1f4
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 9, 2021
3650c9d
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 10, 2021
85c9d49
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 18, 2021
ca82340
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 23, 2021
12e8f47
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 8, 2021
5d024e7
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 15, 2021
4c87d00
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 22, 2021
93ea6ca
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane May 6, 2021
1eaefc8
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jun 2, 2021
cd4a279
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jun 7, 2021
4e9ff9f
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Aug 6, 2021
f971232
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Aug 11, 2021
24b2cd0
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 6, 2021
6d3d8a1
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 10, 2021
ae6dbb2
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 21, 2021
a691bc0
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 23, 2021
bb3ceb1
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 23, 2021
05b7793
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 24, 2021
51755a1
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 24, 2021
64fdc3b
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 24, 2021
bc6c9f6
import utils functions as needed and not the whole module
pm-harshad-mane Sep 24, 2021
ef500ab
import utils functions as needed and not the whole module
pm-harshad-mane Sep 24, 2021
7e3fa3f
import utils functions as needed and not the whole module
pm-harshad-mane Sep 24, 2021
0a32ede
Revert "import utils functions as needed and not the whole module"
pm-harshad-mane Sep 24, 2021
e4dc495
Revert "import utils functions as needed and not the whole module"
pm-harshad-mane Sep 24, 2021
9e42ba5
Revert "import utils functions as needed and not the whole module"
pm-harshad-mane Sep 24, 2021
e14def7
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 27, 2021
f43b61d
import utils functions as needed and not the whole module
pm-harshad-mane Sep 27, 2021
ac9ef03
import utils functions as needed and not the whole module
pm-harshad-mane Sep 27, 2021
9850435
import utils functions as needed and not the whole module
pm-harshad-mane Sep 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions modules/realvuAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import adapter from '../src/AnalyticsAdapter.js';
import adapterManager from '../src/adapterManager.js';
import CONSTANTS from '../src/constants.json';
import { getStorageManager } from '../src/storageManager.js';

import { logMessage, logError } from '../src/utils.js';
const storage = getStorageManager();

const utils = require('../src/utils.js');

let realvuAnalyticsAdapter = adapter({
global: 'realvuAnalytics',
handler: 'on',
Expand Down Expand Up @@ -401,7 +399,7 @@ export let lib = {
// @if NODE_ENV='debug'
let now = new Date();
let msg = (now.getTime() - time0) / 1000 + ' RENDERED ' + a.unit_id;
utils.logMessage(msg);
logMessage(msg);
// @endif
let rpt = z.bids_rpt(a, true);
z.track(a, 'rend', rpt);
Expand Down Expand Up @@ -885,7 +883,7 @@ realvuAnalyticsAdapter.originEnableAnalytics = realvuAnalyticsAdapter.enableAnal
realvuAnalyticsAdapter.enableAnalytics = function (config) {
_options = config.options;
if (typeof (_options.partnerId) == 'undefined' || _options.partnerId == '') {
utils.logError('Missed realvu.com partnerId parameter', 101, 'Missed partnerId parameter');
logError('Missed realvu.com partnerId parameter', 101, 'Missed partnerId parameter');
}
realvuAnalyticsAdapter.originEnableAnalytics(config);
return _options.partnerId;
Expand All @@ -905,7 +903,7 @@ realvuAnalyticsAdapter.track = function ({eventType, args}) {
' creativei_id=' + args.creative_id;
}
// msg += '\nargs=' + JSON.stringify(args) + '<br>';
utils.logMessage(msg);
logMessage(msg);
// @endif

const boost = window.top1.realvu_aa;
Expand Down Expand Up @@ -935,7 +933,7 @@ realvuAnalyticsAdapter.track = function ({eventType, args}) {
realvuAnalyticsAdapter.checkIn = function (bid, partnerId) {
// find (or add if not registered yet) the unit in boost
if (typeof (partnerId) == 'undefined' || partnerId == '') {
utils.logError('Missed realvu.com partnerId parameter', 102, 'Missed partnerId parameter');
logError('Missed realvu.com partnerId parameter', 102, 'Missed partnerId parameter');
}
let a = window.top1.realvu_aa.check({
unit_id: bid.adUnitCode,
Expand Down
12 changes: 6 additions & 6 deletions modules/reconciliationRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import { submodule } from '../src/hook.js';
import { ajaxBuilder } from '../src/ajax.js';
import * as utils from '../src/utils.js';
import { isGptPubadsDefined, timestamp, generateUUID, logError } from '../src/utils.js';
import find from 'core-js-pure/features/array/find.js';

/** @type {Object} */
Expand Down Expand Up @@ -52,7 +52,7 @@ function handleAdMessage(e) {
}

if (data.type === MessageType.IMPRESSION_REQUEST) {
if (utils.isGptPubadsDefined()) {
if (isGptPubadsDefined()) {
// 1. Find the last iframed window before window.top where the tracker was injected
// (the tracker could be injected in nested iframes)
const adWin = getTopIFrameWin(e.source);
Expand All @@ -65,7 +65,7 @@ function handleAdMessage(e) {
adDeliveryId = adSlot.getTargeting('RSDK_ADID');
adDeliveryId = adDeliveryId.length
? adDeliveryId[0]
: `${utils.timestamp()}-${utils.generateUUID()}`;
: `${timestamp()}-${generateUUID()}`;
}
}
}
Expand Down Expand Up @@ -136,7 +136,7 @@ export function getTopIFrameWin(win, topWin) {
* @return {Object[]} slot GoogleTag slots
*/
function getAllSlots() {
return utils.isGptPubadsDefined() && window.googletag.pubads().getSlots();
return isGptPubadsDefined() && window.googletag.pubads().getSlots();
}

/**
Expand Down Expand Up @@ -246,7 +246,7 @@ function getReconciliationData(adUnitsCodes) {

const adSlot = getSlotByCode(adUnitCode);
const adUnitId = adSlot ? adSlot.getAdUnitPath() : adUnitCode;
const adDeliveryId = `${utils.timestamp()}-${utils.generateUUID()}`;
const adDeliveryId = `${timestamp()}-${generateUUID()}`;

dataToReturn[adUnitCode] = {
RSDK_AUID: adUnitId,
Expand Down Expand Up @@ -287,7 +287,7 @@ function init(moduleConfig) {
_moduleParams = Object.assign({}, DEFAULT_PARAMS, params);
initListeners();
} else {
utils.logError('missing params for Reconciliation provider');
logError('missing params for Reconciliation provider');
}
return true;
}
Expand Down
72 changes: 36 additions & 36 deletions modules/relaidoBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as utils from '../src/utils.js';
import { deepAccess, logWarn, getBidIdParameter, parseQueryStringParameters, triggerPixel, generateUUID, isArray } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { Renderer } from '../src/Renderer.js';
Expand All @@ -13,19 +13,19 @@ const UUID_KEY = 'relaido_uuid';
const storage = getStorageManager();

function isBidRequestValid(bid) {
if (!utils.deepAccess(bid, 'params.placementId')) {
utils.logWarn('placementId param is reqeuired.');
if (!deepAccess(bid, 'params.placementId')) {
logWarn('placementId param is reqeuired.');
return false;
}
if (hasVideoMediaType(bid) && isVideoValid(bid)) {
return true;
} else {
utils.logWarn('Invalid mediaType video.');
logWarn('Invalid mediaType video.');
}
if (hasBannerMediaType(bid) && isBannerValid(bid)) {
return true;
} else {
utils.logWarn('Invalid mediaType banner.');
logWarn('Invalid mediaType banner.');
}
return false;
}
Expand All @@ -35,7 +35,7 @@ function buildRequests(validBidRequests, bidderRequest) {

for (let i = 0; i < validBidRequests.length; i++) {
const bidRequest = validBidRequests[i];
const placementId = utils.getBidIdParameter('placementId', bidRequest.params);
const placementId = getBidIdParameter('placementId', bidRequest.params);
const bidDomain = bidRequest.params.domain || BIDDER_DOMAIN;
const bidUrl = `https://${bidDomain}/bid/v1/prebid/${placementId}`;
const uuid = getUuid();
Expand All @@ -44,12 +44,12 @@ function buildRequests(validBidRequests, bidderRequest) {
let height = 0;

if (hasVideoMediaType(bidRequest) && isVideoValid(bidRequest)) {
const playerSize = getValidSizes(utils.deepAccess(bidRequest, 'mediaTypes.video.playerSize'));
const playerSize = getValidSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize'));
width = playerSize[0][0];
height = playerSize[0][1];
mediaType = VIDEO;
} else if (hasBannerMediaType(bidRequest) && isBannerValid(bidRequest)) {
const sizes = getValidSizes(utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes'));
const sizes = getValidSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes'));
width = sizes[0][0];
height = sizes[0][1];
mediaType = BANNER;
Expand Down Expand Up @@ -136,7 +136,7 @@ function getUserSyncs(syncOptions, serverResponses) {
}
let syncUrl = `https://${BIDDER_DOMAIN}/tr/v1/prebid/sync.html`;
if (serverResponses.length > 0) {
syncUrl = utils.deepAccess(serverResponses, '0.body.syncUrl') || syncUrl;
syncUrl = deepAccess(serverResponses, '0.body.syncUrl') || syncUrl;
}
return [{
type: 'iframe',
Expand All @@ -145,34 +145,34 @@ function getUserSyncs(syncOptions, serverResponses) {
}

function onBidWon(bid) {
let query = utils.parseQueryStringParameters({
placement_id: utils.deepAccess(bid, 'params.0.placementId'),
creative_id: utils.deepAccess(bid, 'creativeId'),
price: utils.deepAccess(bid, 'cpm'),
auction_id: utils.deepAccess(bid, 'auctionId'),
bid_id: utils.deepAccess(bid, 'requestId'),
ad_id: utils.deepAccess(bid, 'adId'),
ad_unit_code: utils.deepAccess(bid, 'adUnitCode'),
let query = parseQueryStringParameters({
placement_id: deepAccess(bid, 'params.0.placementId'),
creative_id: deepAccess(bid, 'creativeId'),
price: deepAccess(bid, 'cpm'),
auction_id: deepAccess(bid, 'auctionId'),
bid_id: deepAccess(bid, 'requestId'),
ad_id: deepAccess(bid, 'adId'),
ad_unit_code: deepAccess(bid, 'adUnitCode'),
ref: window.location.href,
}).replace(/\&$/, '');
const bidDomain = utils.deepAccess(bid, 'params.0.domain') || BIDDER_DOMAIN;
const bidDomain = deepAccess(bid, 'params.0.domain') || BIDDER_DOMAIN;
const burl = `https://${bidDomain}/tr/v1/prebid/win.gif?${query}`;
utils.triggerPixel(burl);
triggerPixel(burl);
}

function onTimeout(data) {
let query = utils.parseQueryStringParameters({
placement_id: utils.deepAccess(data, '0.params.0.placementId'),
timeout: utils.deepAccess(data, '0.timeout'),
auction_id: utils.deepAccess(data, '0.auctionId'),
bid_id: utils.deepAccess(data, '0.bidId'),
ad_unit_code: utils.deepAccess(data, '0.adUnitCode'),
let query = parseQueryStringParameters({
placement_id: deepAccess(data, '0.params.0.placementId'),
timeout: deepAccess(data, '0.timeout'),
auction_id: deepAccess(data, '0.auctionId'),
bid_id: deepAccess(data, '0.bidId'),
ad_unit_code: deepAccess(data, '0.adUnitCode'),
version: ADAPTER_VERSION,
ref: window.location.href,
}).replace(/\&$/, '');
const bidDomain = utils.deepAccess(data, '0.params.0.domain') || BIDDER_DOMAIN;
const bidDomain = deepAccess(data, '0.params.0.domain') || BIDDER_DOMAIN;
const timeoutUrl = `https://${bidDomain}/tr/v1/prebid/timeout.gif?${query}`;
utils.triggerPixel(timeoutUrl);
triggerPixel(timeoutUrl);
}

function createPlayerTag(playerUrl) {
Expand All @@ -199,7 +199,7 @@ function newRenderer(bidId, playerUrl) {
try {
renderer.setRender(outstreamRender);
} catch (err) {
utils.logWarn('renderer.setRender Error', err);
logWarn('renderer.setRender Error', err);
}
return renderer;
}
Expand All @@ -220,17 +220,17 @@ function isBannerValid(bid) {
if (!isMobile()) {
return false;
}
const sizes = getValidSizes(utils.deepAccess(bid, 'mediaTypes.banner.sizes'));
const sizes = getValidSizes(deepAccess(bid, 'mediaTypes.banner.sizes'));
if (sizes.length > 0) {
return true;
}
return false;
}

function isVideoValid(bid) {
const playerSize = getValidSizes(utils.deepAccess(bid, 'mediaTypes.video.playerSize'));
const playerSize = getValidSizes(deepAccess(bid, 'mediaTypes.video.playerSize'));
if (playerSize.length > 0) {
const context = utils.deepAccess(bid, 'mediaTypes.video.context');
const context = deepAccess(bid, 'mediaTypes.video.context');
if (context && context === 'outstream') {
return true;
}
Expand All @@ -241,7 +241,7 @@ function isVideoValid(bid) {
function getUuid() {
const id = storage.getCookie(UUID_KEY)
if (id) return id;
const newId = utils.generateUUID();
const newId = generateUUID();
storage.setCookie(UUID_KEY, newId);
return newId;
}
Expand All @@ -255,18 +255,18 @@ export function isMobile() {
}

function hasBannerMediaType(bid) {
return !!utils.deepAccess(bid, 'mediaTypes.banner');
return !!deepAccess(bid, 'mediaTypes.banner');
}

function hasVideoMediaType(bid) {
return !!utils.deepAccess(bid, 'mediaTypes.video');
return !!deepAccess(bid, 'mediaTypes.video');
}

function getValidSizes(sizes) {
let result = [];
if (sizes && utils.isArray(sizes) && sizes.length > 0) {
if (sizes && isArray(sizes) && sizes.length > 0) {
for (let i = 0; i < sizes.length; i++) {
if (utils.isArray(sizes[i]) && sizes[i].length == 2) {
if (isArray(sizes[i]) && sizes[i].length == 2) {
const width = sizes[i][0];
const height = sizes[i][1];
if (width == 1 && height == 1) {
Expand Down
7 changes: 3 additions & 4 deletions modules/resetdigitalBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

import * as utils from '../src/utils.js';
import { timestamp, deepAccess, getOrigin } from '../src/utils.js';
import { config } from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {getOrigin} from '../src/utils.js';
const BIDDER_CODE = 'resetdigital';

export const spec = {
Expand All @@ -20,7 +19,7 @@ export const spec = {
? config.getConfig('userSync').syncsPerBidder : 5

const payload = {
start_time: utils.timestamp(),
start_time: timestamp(),
language: window.navigator.userLanguage || window.navigator.language,
site: {
domain: getOrigin(),
Expand Down Expand Up @@ -51,7 +50,7 @@ export const spec = {
imp_id: req.transactionId,
sizes: req.sizes,
force_bid: req.params.forceBid,
media_types: utils.deepAccess(req, 'mediaTypes')
media_types: deepAccess(req, 'mediaTypes')
});
}

Expand Down
18 changes: 9 additions & 9 deletions modules/revcontentBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import {registerBidder} from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE } from '../src/mediaTypes.js';
import * as utils from '../src/utils.js';
import { triggerPixel, isFn, deepAccess, getAdUnitSizes, parseGPTSingleSizeArrayToRtbSize, _map } from '../src/utils.js';

const BIDDER_CODE = 'revcontent';
const NATIVE_PARAMS = {
Expand Down Expand Up @@ -160,7 +160,7 @@ export const spec = {
},
onBidWon: function (bid) {
if (bid.nurl) {
utils.triggerPixel(bid.nurl);
triggerPixel(bid.nurl);
}
return true;
}
Expand Down Expand Up @@ -215,14 +215,14 @@ function extractHostname(url) {

function buildImp(bid, id) {
let bidfloor;
if (utils.isFn(bid.getFloor)) {
if (isFn(bid.getFloor)) {
bidfloor = bid.getFloor({
currency: 'USD',
mediaType: '*',
size: '*'
}).floor;
} else {
bidfloor = utils.deepAccess(bid, `params.bidfloor`) || 0.1;
bidfloor = deepAccess(bid, `params.bidfloor`) || 0.1;
}

let imp = {
Expand All @@ -236,17 +236,17 @@ function buildImp(bid, id) {
secure: '1'
};

let bannerReq = utils.deepAccess(bid, `mediaTypes.banner`);
let nativeReq = utils.deepAccess(bid, `mediaTypes.native`);
let bannerReq = deepAccess(bid, `mediaTypes.banner`);
let nativeReq = deepAccess(bid, `mediaTypes.native`);
if (bannerReq) {
let sizes = utils.getAdUnitSizes(bid);
let sizes = getAdUnitSizes(bid);
imp.banner = {
w: sizes[0][0],
h: sizes[0][1],
format: sizes.map(wh => utils.parseGPTSingleSizeArrayToRtbSize(wh)),
format: sizes.map(wh => parseGPTSingleSizeArrayToRtbSize(wh)),
}
} else if (nativeReq) {
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
Expand Down
Loading