SDK 配置参考 enableSetData(小程序应用) 非必填项,值为布尔值,默认值为 false。若为 true,则会上报小程序 setData 方法相关的性能数据;反之亦然。 上报数据规整 parseResponse 用于解析并规整 API 响应数据。非必填项,值为函数,默认值为: javascript "parseResponse": function(responseData, statusCode, { method, api, domain }) { let msg '' if (responseData && typeof responseData 'object') { msg responseData.msg responseData.message responseData.subMsg responseData.errorMsg responseData.ret responseData.errorResponse '' if (typeof msg 'object') { msg msg.msg msg.message msg.info msg.ret JSON.stringify(msg) } } // 默认 > 200 && 400) { success false } return { msg, // String success, // Boolean code: statusCode, // Number } }, 该函数需要返回一个包含 msg、success、code 的对象。SDK 会使用该函数对 API 响应进行解析,提取出 msg、success 和 code 字段。 parseHash(Web 应用) 用于解析 SPA 应用的 page 字段,仅在 enableSPA 为 true 时才生效。非必填项,值为函数,默认值为: javascript "parseHash": function(hash) { const cutUrlSearch url > { if (!url typeof url ! 'string') return '' return url.replace( ?///, '' ).replace( /?.$/, '' ) } const page hash ? util.cutUrlSearch(hash.replace(/^/?/, '')) : '' return page '[index]' }, 此配置项一般不需要修改。如果需要在上报时使用自定义的页面名,或 URL 的 Hash 比较复杂,则需要修改此配置项。示例: javascript const PAGEMAP { '/overview': '总览页', '/log': '设置页', '/setting': '设置页', // ... } // ... 其他配置项 "parseHash": function(hash) { const key hash.replace(/?.$/, '') return PAGEMAP[key] key } // ... 其他配置项