From d51c8980c96f682cfecf2014ccb157807296fe81 Mon Sep 17 00:00:00 2001 From: Andrew Bowman Date: Wed, 3 Oct 2018 13:51:54 -0400 Subject: [PATCH] removing nested object --- modules/appnexusBidAdapter.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 4c0cb0db2fa..5d7861eb34b 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -81,24 +81,26 @@ export const spec = { let debugObj = {}; let debugObjParams = {}; const debugCookieName = 'apn_prebid_debug'; - const debugCookie = getCookie(debugCookieName) || false; + const debugCookie = getCookie(debugCookieName) || null; if (debugCookie) { try { - debugObjParams['debug'] = JSON.parse(debugCookie); + debugObj = JSON.parse(debugCookie); } catch (e) { utils.logError('AppNexus Debug Auction Cookie Error:\n\n' + e); } } else { - debugObjParams = find(bidRequests, hasDebug); + const debugBidRequest = find(bidRequests, hasDebug); + if (debugBidRequest && debugBidRequest['debug']) { + debugObj = debugBidRequest['debug']; + } } - if (debugObjParams && debugObjParams.debug) { - Object.keys(debugObjParams.debug) + if (debugObj && debugObj['enabled']) { + Object.keys(debugObj) .filter(param => includes(DEBUG_PARAMS, param)) .forEach(param => { - debugObj['debug'] = debugObj['debug'] || {}; - debugObj.debug[param] = debugObjParams.debug[param] + debugObjParams[param] = debugObj[param]; }); } @@ -124,9 +126,9 @@ export const spec = { payload.app = appIdObj; } - if (debugObj && debugObj.debug) { - payload.debug = debugObj.debug; - utils.logInfo('AppNexus Debug Auction Settings:\n\n' + JSON.stringify(debugObj.debug, null, 4)); + if (debugObjParams && debugObjParams['enabled']) { + payload.debug = debugObjParams; + utils.logInfo('AppNexus Debug Auction Settings:\n\n' + JSON.stringify(debugObjParams, null, 4)); } if (bidderRequest && bidderRequest.gdprConsent) {