Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
];
Expand Down
41 changes: 20 additions & 21 deletions src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function getPresetTargeting() {
})
};
});
})();
}());
}
}

Expand Down Expand Up @@ -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]] })
};
});
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 //
Expand Down Expand Up @@ -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('<IFRAME SRC="' + url + '" FRAMEBORDER="0" SCROLLING="no" MARGINHEIGHT="0" MARGINWIDTH="0" TOPMARGIN="0" LEFTMARGIN="0" ALLOWTRANSPARENCY="true" WIDTH="' + width + '" HEIGHT="' + height + '"></IFRAME>');
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);
}
Expand Down