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

remove try catch on get lastLocation and comment currency on prebidServer adapter #37

Merged
merged 2 commits into from
Oct 29, 2019
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
23 changes: 12 additions & 11 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,17 +669,18 @@ const OPEN_RTB_PROTOCOL = {
request.ext.prebid = Object.assign(request.ext.prebid, _s2sConfig.extPrebid);
}

/**
* @type {(string[]|string|undefined)} - OpenRTB property 'cur', currencies available for bids
*/
const adServerCur = config.getConfig('currency.adServerCurrency');
if (adServerCur && typeof adServerCur === 'string') {
// if the value is a string, wrap it with an array
request.cur = [adServerCur];
} else if (Array.isArray(adServerCur) && adServerCur.length) {
// if it's an array, get the first element
request.cur = [adServerCur[0]];
}
// TEMPORARY REMOVED
// /**
// * @type {(string[]|string|undefined)} - OpenRTB property 'cur', currencies available for bids
// */
// const adServerCur = config.getConfig('currency.adServerCurrency');
// if (adServerCur && typeof adServerCur === 'string') {
// // if the value is a string, wrap it with an array
// request.cur = [adServerCur];
// } else if (Array.isArray(adServerCur) && adServerCur.length) {
// // if it's an array, get the first element
// request.cur = [adServerCur[0]];
// }

_appendSiteAppDevice(request);

Expand Down
27 changes: 19 additions & 8 deletions src/marfeelTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,25 @@ var lastLocation;

export const getLastLocation = () => lastLocation;

const extractLastLocationFromArray = (adUnitArr) => (
adUnitArr &&
adUnitArr[0] &&
adUnitArr[0].bids &&
adUnitArr[0].bids[0] &&
adUnitArr[0].bids[0].params &&
adUnitArr[0].bids[0].params.referrer) ? adUnitArr[0].bids[0].params.referrer : '';

const extractLastLocationFromObject = (adUnitArr) => (
adUnitArr &&
adUnitArr.bids &&
adUnitArr.bids[0] &&
adUnitArr.bids[0].params &&
adUnitArr.bids[0].params.referrer) ? adUnitArr.bids[0].params.referrer : '';

export const setLastLocationFromLastAdUnit = (adUnitArr) => {
try {
if (utils.isArray(adUnitArr)) {
lastLocation = adUnitArr[0].bids[0].params.referrer;
} else {
lastLocation = adUnitArr.bids[0].params.referrer;
}
} catch (error) {
console.error('Error while extracting lastLocation from adUnit', error);
if (utils.isArray(adUnitArr)) {
lastLocation = extractLastLocationFromArray(adUnitArr);
} else {
lastLocation = extractLastLocationFromObject(adUnitArr);
}
}