diff --git a/karma.conf.js b/karma.conf.js index 0e637f57c10..95852360eb0 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -4,7 +4,7 @@ var webpackConfig = require('./webpack.conf'); webpackConfig.module.postLoaders = [ { test: /\.js$/, - exclude: /(node_modules)|(test)|(integrationExamples)|(build)|polyfill.js/, + exclude: /(node_modules)|(test)|(integrationExamples)|(build)|polyfill.js|(src\/adapters\/analytics\/ga.js)/, loader: 'istanbul-instrumenter' } ]; diff --git a/src/prebid.js b/src/prebid.js index 05d07d4d5cf..b0db25fc28a 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -150,7 +150,7 @@ function getPresetTargeting() { }) }; }); - })(); + }()); } } @@ -188,11 +188,7 @@ function getDealTargeting() { return $$PREBID_GLOBAL$$._bidsReceived.filter(bid => bid.dealId).map(bid => { const dealKey = `hb_deal_${bid.bidderCode}`; return { - [bid.adUnitCode]: CONSTANTS.TARGETING_KEYS.map(key => { - return { - [`${key}_${bid.bidderCode}`.substring(0, 20)]: [bid.adserverTargeting[key]] - }; - }) + [bid.adUnitCode]: getTargetingMap(bid, CONSTANTS.TARGETING_KEYS) .concat({ [dealKey.substring(0, 20)]: [bid.adserverTargeting[dealKey]] }) }; }); @@ -232,16 +228,20 @@ function getBidLandscapeTargeting() { return $$PREBID_GLOBAL$$._bidsReceived.map(bid => { if (bid.adserverTargeting) { return { - [bid.adUnitCode]: standardKeys.map(key => { - return { - [`${key}_${bid.bidderCode}`.substring(0, 20)]: [bid.adserverTargeting[key]] - }; - }) + [bid.adUnitCode]: getTargetingMap(bid, standardKeys) }; } }).filter(bid => bid); // removes empty elements in array } +function getTargetingMap(bid, keys) { + return keys.map(key => { + return { + [`${key}_${bid.bidderCode}`.substring(0, 20)]: [bid.adserverTargeting[key]] + }; + }); +} + function getAllTargeting() { // Get targeting for the winning bid. Add targeting for any bids that have // `alwaysUseBid=true`. If sending all bids is enabled, add targeting for losing bids. @@ -288,6 +288,13 @@ function removeComplete() { .forEach(bid => responses.splice(responses.indexOf(bid), 1)); } +function setRenderSize(doc, width, height) { + if (doc.defaultView && doc.defaultView.frameElement) { + doc.defaultView.frameElement.width = width; + doc.defaultView.frameElement.height = height; + } +} + ////////////////////////////////// // // // Start Public APIs // @@ -462,19 +469,11 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id) { } else if (ad) { doc.write(ad); doc.close(); - if (doc.defaultView && doc.defaultView.frameElement) { - doc.defaultView.frameElement.width = width; - doc.defaultView.frameElement.height = height; - } + setRenderSize(doc, width, height); } else if (url) { doc.write(''); doc.close(); - - if (doc.defaultView && doc.defaultView.frameElement) { - doc.defaultView.frameElement.width = width; - doc.defaultView.frameElement.height = height; - } - + setRenderSize(doc, width, height); } else { utils.logError('Error trying to write ad. No ad for bid response id: ' + id); }