diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 7dac4b8b182..01f45d30413 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -11,6 +11,8 @@ const VIDEO_TARGETING = ['id', 'mimes', 'minduration', 'maxduration', 'startdelay', 'skippable', 'playback_method', 'frameworks']; const USER_PARAMS = ['age', 'external_uid', 'segments', 'gender', 'dnt', 'language']; const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately +const AST_DEBUG_URL = ['ast_debug', 'ast_dongle', 'ast_debug_member', 'ast_debug_timeout'] +const AST_DEBUG_PARAMS = ['enabled', 'dongle', 'member_id', 'debug_timeout'] const NATIVE_MAPPING = { body: 'description', cta: 'ctatext', @@ -77,6 +79,38 @@ export const spec = { }; } + let debugObj = {}; + const debugObjParams = find(bidRequests, hasDebug); + if (debugObjParams && debugObjParams.debug) { + Object.keys(debugObjParams.debug) + .filter(param => includes(AST_DEBUG_PARAMS, param)) + .forEach(param => { + debugObj['debug'] = debugObj['debug'] || {}; + debugObj.debug[param] = debugObjParams.debug[param] + }); + } + + const debugUrlParams = getURLparams(); + if (debugUrlParams && debugUrlParams.params) { + Object.keys(debugUrlParams.params) + .filter(param => includes(AST_DEBUG_URL, param)) + .forEach(param => { + debugObj['debug'] = debugObj['debug'] || {}; + if (param == 'ast_debug') { + debugObj['debug']['enabled'] = (debugUrlParams.params[param] === 'true'); + } + if (param == 'ast_dongle') { + debugObj['debug']['dongle'] = debugUrlParams.params[param]; + } + if (param == 'ast_debug_member') { + debugObj['debug']['member_id'] = parseInt(debugUrlParams.params[param], 10); + } + if (param == 'ast_debug_timeout') { + debugObj['debug']['debug_timeout'] = parseInt(debugUrlParams.params[param], 10); + } + }); + } + const memberIdBid = find(bidRequests, hasMemberId); const member = memberIdBid ? parseInt(memberIdBid.params.member, 10) : 0; @@ -99,6 +133,10 @@ export const spec = { payload.app = appIdObj; } + if (debugObj && debugObj.debug) { + payload.debug = debugObj.debug + } + if (bidderRequest && bidderRequest.gdprConsent) { // note - objects for impbus use underscore instead of camelCase payload.gdpr_consent = { @@ -144,6 +182,21 @@ export const spec = { } }); } + + if (serverResponse.debug && serverResponse.debug.debug_info) { + let debugHeader = 'AppNexus Debug Auction for Prebid\n\n' + let debugText = debugHeader + serverResponse.debug.debug_info + debugText = debugText + .replace(/(