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 Adapters : import utils functions as needed, not whole module #7469

Merged
merged 79 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 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
ed83320
import utils as needed; dont import all
pm-harshad-mane Sep 23, 2021
9c7d944
import utils as needed; dont import all
pm-harshad-mane Sep 24, 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
43 changes: 23 additions & 20 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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(
{
Expand All @@ -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);
}

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

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -546,7 +549,7 @@ function contributeViewability(viewabilityAmount) {

function _isIframe() {
try {
return utils.getWindowSelf() !== utils.getWindowTop();
return getWindowSelf() !== getWindowTop();
} catch (e) {
return true;
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions modules/a4gBidAdapter.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions modules/ablidaBidAdapter.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -79,7 +79,7 @@ export const spec = {
},
onBidWon: function (bid) {
if (!bid['nurl']) { return; }
utils.triggerPixel(bid['nurl']);
triggerPixel(bid['nurl']);
}
};

Expand Down
8 changes: 4 additions & 4 deletions modules/adagioAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
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';
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) {
Expand All @@ -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 || [];
Expand Down
Loading