aegis-mp-sdk 1.37.8 → 1.37.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/aegis.min.js +3 -3
- package/package.json +1 -1
package/lib/aegis.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ================================================================
|
|
3
|
-
* aegis-mp-sdk@1.37.
|
|
3
|
+
* aegis-mp-sdk@1.37.9 (c) 2023 TencentCloud Real User Monitoring.
|
|
4
4
|
* Author pumpkincai.
|
|
5
|
-
* Last Release Time
|
|
5
|
+
* Last Release Time Fri Sep 01 2023 09:31:00 GMT+0800 (中国标准时间).
|
|
6
6
|
* Released under the MIT License.
|
|
7
7
|
* Thanks for supporting RUM & Aegis!
|
|
8
8
|
* ================================================================
|
|
9
9
|
**/
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Aegis=t()}(this,function(){"use strict";var j=function(e,t){return(j=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}))(e,t)};function e(e,t){function n(){this.constructor=e}j(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var f=function(){return(f=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function I(o,r){var i,a,s,l={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(n){return function(e){var t=[n,e];if(i)throw new TypeError("Generator is already executing.");for(;l;)try{if(i=1,a&&(s=2&t[0]?a.return:t[0]?a.throw||((s=a.return)&&s.call(a),0):a.next)&&!(s=s.call(a,t[1])).done)return s;switch(a=0,(t=s?[2&t[0],s.value]:t)[0]){case 0:case 1:s=t;break;case 4:return l.label++,{value:t[1],done:!1};case 5:l.label++,a=t[1],t=[0];continue;case 7:t=l.ops.pop(),l.trys.pop();continue;default:if(!((s=0<(s=l.trys).length&&s[s.length-1])||6!==t[0]&&2!==t[0])){l=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3]))l.label=t[1];else if(6===t[0]&&l.label<s[1])l.label=s[1],s=t;else{if(!(s&&l.label<s[2])){s[2]&&l.ops.pop(),l.trys.pop();continue}l.label=s[2],l.ops.push(t)}}t=r.call(o,l)}catch(e){t=[6,e],a=0}finally{i=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}function a(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var o=Array(e),r=0,t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,r++)o[r]=i[a];return o}Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(null==e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),n=1;n<arguments.length;n++)if(null!=(o=arguments[n]))for(var o=Object(o),r=Object.keys(Object(o)),i=0,a=r.length;i<a;i++){var s=r[i],l=Object.getOwnPropertyDescriptor(o,s);null!=l&&l.enumerable&&(t[s]=o[s])}return t}});var H=/_?t(\d)?(imestamp)?=\d+&?/g,D=["aegis.qq.com","tamaegis.com","/aegis-sdk","rumt-","/flog.core.min.js","pingfore.qq.com","pingfore.tencent.com","zhiyan.tencent-cloud.net","h.trace.qq.com","btrace.qq.com","beacon.qq.com","dmplog.qq.com","qq.com/report","svibeacon.onezapp.com","cube.weixinbridge.com","doubleclick.net","pcmgrmonitor.3g.qq.com","tdm.qq.com","report.qqweb.qq.com","tpstelemetry.tencent.com","insight.cloud.tencent.com","facebook.com","facebook.net","google","yahoo.com","twitter.com","ga-audiences","report.idqqimg.com","arms-retcode.aliyuncs.com","px.effirst.com","sentry","baidu.com","hot-update.json","u.c.b.r.o.w.s.e.r","report.url.cn","sockjs-node","m3u8"],M=["ext1","ext2","ext3","level","trace","tag","seq","code"],F=(t.prototype.indexOf=function(e,t){for(var n=0;n<e.length;n++)if(e[n].callback===t)return n;return-1},t.prototype.on=function(e,t,n){var o;if(void 0===n&&(n=0),this)return(o=this.eventsList[e])||(this.eventsList[e]=[],o=this.eventsList[e]),-1===this.indexOf(o,t)&&o.push({name:e,type:n||0,callback:t}),this},t.prototype.one=function(e,t){this.on(e,t,1)},t.prototype.remove=function(e,t){if(this){var n=this.eventsList[e];if(n){if(t)return n.length&&(t=this.indexOf(n,t),n.splice(t,1)),this;try{delete this.eventsList[e]}catch(e){}}return null}},t.prototype.clear=function(){this.eventsList={}},t),B=function(e){if(!e||0===e.length)return"{}";e=Array.isArray(e)?e:[e];var t=Object.keys(e[0]),n={},o=(t.forEach(function(t){n[t]=e.map(function(e){return e[t]})}),n.count=e.length,n);if("string"==typeof o)return o;try{return JSON.stringify(o,ie())||"undefined"}catch(o){return"error happen when aegis stringify: \n "+o.message+" \n "+o.stack}};function t(){var a=this;this.emit=function(e,t){if(a){var n;if(null!=(o=a.eventsList[e])&&o.length)for(var o=o.slice(),r=0;r<o.length;r++){n=o[r];try{var i=n.callback.apply(a,[t]);if(1===n.type&&a.remove(e,n.callback),!1===i)break}catch(e){throw e}}return a}},this.eventsList={}}function p(e,t){return"string"==typeof e?e.split("?")[t?1:0]||"":e}function W(e){return"string"==typeof e&&/^\//.test(e)?"https:"===(null===location||void 0===location?void 0:location.protocol):/^https/.test(e)}function d(e,t,n){var o,r;try{if("function"==typeof(null==t?void 0:t.retCodeHandler))return{code:void 0===(i=(r=t.retCodeHandler(e,null==n?void 0:n.url,null==n?void 0:n.ctx,null==n?void 0:n.payload)||{}).code)?"unknown":i,isErr:r.isErr};if(!(e="string"==typeof e?JSON.parse(e):e))return{code:"unknown",isErr:!1};"function"==typeof(null==(o=null==t?void 0:t.ret)?void 0:o.join)&&(re=[].concat(t.ret.map(function(e){return e.toLowerCase()})));var i,a=Object.getOwnPropertyNames(e).filter(function(e){return-1!==re.indexOf(e.toLowerCase())});return a.length?{code:""+(i="未知"!==(i=e[a[0]])&&""!==i?i:"unknown"),isErr:0!==i&&"0"!==i&&"unknown"!==i}:{code:"unknown",isErr:!1}}catch(e){return{code:"unknown",isErr:!1}}}function h(e,t,n){try{var o="function"==typeof t?t(e,null==n?void 0:n.url)||"":e;return ae(o).slice(0,102400)}catch(e){return""}}function g(t,e){return"string"!=typeof t||!t||e&&-1<t.indexOf(e)||ce.test(t)||D.some(function(e){return-1<t.indexOf(e)})}function m(n,o){var r,i=[],a=n.config;return n.lifeCycle.on("destroy",function(){i.length=0}),function(e,t){Array.isArray(e)?i=i.concat(e):i.push(e),o&&i.length>=o||n.sendNow&&0<i.length?(i=ue(i),t(i.splice(0,i.length)),r&&clearTimeout(r)):(r&&clearTimeout(r),r=setTimeout(function(){r=null,0<(i=ue(i)).length&&t(i.splice(0,i.length))},a.delay))}}function V(e,t){return Array.isArray(e)?t(e.map(function(e){return t=f(f({},e),{msg:"string"==typeof e.msg?e.msg:[].concat(e.msg).map(E).join(" ")}),M.forEach(function(e){t[e]||delete t[e]}),t;var t})):t([f(f({},e),{msg:"string"==typeof e.msg?e.msg:E(e.msg)})])}function G(l,c){return function(e,t){var n,o,r,i=Array.isArray(e),a=i?e:[e],s=(l.lifeCycle.emit("beforeRequest",e),l.config.beforeRequest);(a="function"==typeof s?a.map(function(t){try{var e=s({logs:t,logType:c});return(null==e?void 0:e.logType)===c&&null!=e&&e.logs?e.logs:!1!==e&&t}catch(e){return t}}).filter(function(e){return!1!==e}):a).length&&(n=a,e=M,!Array.isArray(n)||n.length<=1||(o=[],r=[],!(r="string"==typeof e?[e]:e))||r.length<=0||(r.forEach(function(t){n.forEach(function(e){null!=e&&e[t]&&o.push(t)})}),0<o.length&&(n=n.map(function(e){var t={};return o.forEach(function(e){t[e]=""}),f(f({},t),e)}))),a=n,t(i?a:a[0]))}}function J(r){return function(e,t){r.lifeCycle.emit("modifyRequest",e);var n=r.config.modifyRequest;if("function"==typeof n)try{var o=n(e);"object"==typeof o&&"url"in o&&(e=o)}catch(e){console.error(e)}t(e)}}function K(o){return function(e,t){null!=(n=o.lifeCycle)&&n.emit("afterRequest",e);var n=(o.config||{}).afterRequest;"function"==typeof n&&!1===n(e)||t(e)}}function y(n){if(n&&n.reduce&&n.length)return 1===n.length?function(e,t){n[0](e,t||ge)}:n.reduce(function(n,o){return function(e,t){return void 0===t&&(t=ge),n(e,function(e){return null==o?void 0:o(e,t)})}});throw new TypeError("createPipeline need at least one function param")}function s(t,n){Object.getOwnPropertyNames(t).forEach(function(e){"function"==typeof t[e]&&"constructor"!==e&&(n?n[e]="sendPipeline"===e?function(){return function(){}}:function(){}:t[e]=function(){})})}function z(e){try{var t,n,o,r="";return r=e.pageUrl||(n=(t=getCurrentPages())[t.length-1]||{},i=n.options,o=Object.keys(i).length?"?"+Object.keys(i).map(function(e){return e+"="+i[e]}).join("&"):"",n.route?n.route+o:""),(r="function"==typeof e.urlHandler?e.urlHandler():r).slice(0,2048)}catch(e){return""}var i}function $(e,t){if("string"==typeof e&&"string"==typeof t){if(e===t)return 1;for(var n=e.split("."),o=t.split("."),r=Math.max(n.length,o.length),i=0;i<r;i++){var a=~~n[i],s=~~o[i];if(a<s)return;if(s<a)return 1}}}function Y(e,t){var n=this;this.taskQueue=[],this.count=1,this.maxCount=2,this.addTask=function(e){n.taskQueue.push(e)},this.fireTask=function(){var e=n.taskQueue.length;n.count>n.maxCount||0===e||(n.count=n.count+1,(e=n.taskQueue.shift())&&n.sendRequest(e.options,null==e?void 0:e.success,null==e?void 0:e.fail))},this.complete=function(){1<n.count&&(n.count=n.count-1),n.fireTask()},t&&(this.maxCount=t),this.sendRequest=e}function r(e){return me=me||i.getSystemInfoSync().SDKVersion,$(me,"1.1.1")&&i.canIUse?i.canIUse(e):!!i[e]}function Q(e){for(var t,n={unknown:/unknown|none/i,wifi:/wifi/i,net2g:/2g/i,net3g:/3g/i,net4g:/4g/i,net5g:/5g/i,net6g:/6g/i},o=c.unknown,r=0;r<Object.keys(n).length;r++){var i=Object.keys(n)[r];if(null!=(t=n[i])&&t.test(e)){o=c[i];break}}return o}function X(e){var t=e.apiName,n=k[t];n?n.hackCloudReq.addCallback(e):(n=P.cloud[t],k[t]={hackCloudReq:new Ee(e),originApi:n}),k[t]}function Z(e){var t=e.apiName,n=T[t];n?n.hackReq.addCallback(e):(n=wx[t],T[t]={hackReq:new Re(e),originApi:n}),T[t]}var v,l,c,b,u,ee,te,ne,oe,re=["ret","retcode","code","errcode"],ie=function(){var n=new WeakSet;return function(e,t){if(t instanceof Error)return"Error.message: "+t.message+" \n Error.stack: "+t.stack;if("object"==typeof t&&null!==t){if(n.has(t))return"[Circular "+(e||"root")+"]";n.add(t)}return t}},E=function(e){if("string"==typeof e)return e;try{return e instanceof Error?(JSON.stringify(e,ie(),4)||"undefined").replace(/"/gim,""):JSON.stringify(e,ie(),4)||"undefined"}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}},ae=function(n,o){void 0===o&&(o=3);var r,i,a,s="";return Array.isArray(n)?(s+="[",r=n.length,n.forEach(function(e,t){s=(s+="object"==typeof e&&1<o?ae(e,o-1):le(e))+(t===r-1?"":",")}),s+="]"):n instanceof Object?(s="{",i=Object.keys(n),a=i.length,i.forEach(function(e,t){"object"==typeof n[e]&&1<o?s+='"'+e+'":'+ae(n[e],o-1):s+=se(e,n[e]),s+=t===a-1||t<a-1&&void 0===n[i[t+1]]?"":","}),s+="}"):s+=n,s},se=function(e,t){var n=typeof t,o="";return"string"==n||"object"==n?o+='"'+e+'":"'+t+'"':"function"==typeof t?o+='"'+e+'":"function '+t.name+'"':"symbol"==typeof t?o+='"'+e+'":"symbol"':"number"!=typeof t&&"boolean"!=n||(o+='"'+e+'": '+t),o},le=function(e){var t=typeof e;return""+("undefined"==t||"symbol"==t||"function"==t?"null":"string"==t||"object"==t?'"'+e+'"':e)},ce=/data:(image|text|application|font)\/.*;base64/,ue=((n=v=v||{}).INFO_ALL="-1",n.API_RESPONSE="1",n.INFO="2",n.ERROR="4",n.PROMISE_ERROR="8",n.AJAX_ERROR="16",n.SCRIPT_ERROR="32",n.IMAGE_ERROR="64",n.CSS_ERROR="128",n.CONSOLE_ERROR="256",n.MEDIA_ERROR="512",n.RET_ERROR="1024",n.REPORT="2048",n.PV="4096",n.EVENT="8192",n.PAGE_NOT_FOUND_ERROR="16384",n.WEBSOCKET_ERROR="32768",n.BRIDGE_ERROR="65536",n.LAZY_LOAD_ERROR="131072",(n=l=l||{})[n.android=1]="android",n[n.ios=2]="ios",n[n.windows=3]="windows",n[n.macos=4]="macos",n[n.linux=5]="linux",n[n.devtools=6]="devtools",n[n.other=100]="other",(n=c=c||{})[n.unknown=100]="unknown",n[n.wifi=1]="wifi",n[n.net2g=2]="net2g",n[n.net3g=3]="net3g",n[n.net4g=4]="net4g",n[n.net5g=5]="net5g",n[n.net6g=6]="net6g",(n=b=b||{}).LOG="log",n.SPEED="speed",n.PERFORMANCE="performance",n.OFFLINE="offline",n.WHITE_LIST="whiteList",n.VITALS="vitals",n.PV="pv",n.CUSTOM_PV="customPV",n.EVENT="event",n.CUSTOM="custom",n.SDK_ERROR="sdkError",n.SET_DATA="setData",n.LOAD_PACKAGE="loadPackage",(n=u=u||{}).production="production",n.development="development",n.gray="gray",n.pre="pre",n.daily="daily",n.local="local",n.test="test",n.others="others",function(e){return e.filter(function(n,o){return"static"!==n.type||!e.find(function(e,t){return n.url===e.url&&200===n.status&&o<t})})}),fe=function(e){e.level===v.INFO_ALL&&(e.level=v.INFO)},O={},R={},pe=function(e){return O[e]||(O[e]=setTimeout(function(){R[e]={},O[e]=null},6e4)),O[e]},de=function(e){return(Array.isArray(e)?e:[e]).map(function(n){return Object.getOwnPropertyNames(n).reduce(function(e,t){return"ctx"!==t&&(e[t]=n[t]),e},{level:v.INFO,msg:""})})},he=function(o){return function(e){return o.sendPipeline([function(e,n){return n({url:o.config.url||"",data:B(de(e)),method:"post",contentType:"application/json",type:b.LOG,log:e,requestConfig:{timeout:5e3},success:function(){var t=o.config.onReport;"function"==typeof t&&e.forEach(function(e){t(e)}),"function"==typeof n&&n([])}})}],b.LOG)(e)}},ge=function(){},n=(Object.defineProperty(q.prototype,"__version__",{get:function(){return console.warn("__version__ has discard, please use version"),"1.37.8"},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"LogType",{get:function(){return console.warn("LogType has discard, please use logType"),v},enumerable:!1,configurable:!0}),q.prototype.init=function(e){this.setConfig(e);for(var t=0;t<q.installedPlugins.length;t++)try{q.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},q.prototype.setConfig=function(e){Object.assign(this.config,e);var e=this.config,t=e.id,n=e.uin,o=e.version,r=e.ext1,i=e.ext2,a=e.ext3,s=e.aid,l=e.env,c=void 0===l?"production":l,l=e.pageUrl,e=this.bean.id!==t||this.bean.uin!==n||this.bean.aid!==s;return this.bean.id=t||"",this.bean.uin=n||"",this.bean.version=o||"1.37.8",this.bean.aid=s||"",this.bean.env=function(){switch(c){case u.production:case u.development:case u.gray:case u.pre:case u.daily:case u.local:case u.test:case u.others:return 1;default:return}}()?c:u.others,l&&this.extendBean("from",encodeURIComponent(l.slice(0,2048))),r&&this.extendBean("ext1",encodeURIComponent(r)),i&&this.extendBean("ext2",encodeURIComponent(i)),a&&this.extendBean("ext3",encodeURIComponent(a)),e&&this.lifeCycle.emit("onConfigChange",this.config),this.config},q.use=function(e){-1===q.installedPlugins.indexOf(e)&&e.aegisPlugin&&q.installedPlugins.push(e)},q.unuse=function(e){e=q.installedPlugins.indexOf(e);-1!==e&&q.installedPlugins.splice(e,1)},q.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:v.INFO,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:v.INFO}),this.normalLogPipeline(n)},q.prototype.infoAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:v.INFO_ALL,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:v.INFO_ALL}),this.normalLogPipeline(n)},q.prototype.report=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:v.REPORT,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0])),this.normalLogPipeline(n)},q.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:v.ERROR,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:v.ERROR}),this.normalLogPipeline(n)},q.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},q.prototype.reportPv=function(n){var o,r=this;n&&(console.warn("reportPv is deprecated, please use reportEvent"),o=""+Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+r.bean[e]}).join("&"),this.sendPipeline([function(e,t){t({url:r.config.url+"/"+n+"?"+o,addBean:!1,type:b.CUSTOM_PV})}],b.CUSTOM_PV)(null))},q.prototype.reportEvent=function(e){e&&((e="string"==typeof e?{name:e,ext1:this.config.ext1||"",ext2:this.config.ext2||"",ext3:this.config.ext3||""}:e).name?("string"!=typeof e.name&&(console.warn("reportEvent params name must be string"),e.name=String(e.name)),this.eventPipeline(e)):console.warn("reportEvent params error"))},q.prototype.reportTime=function(e,t){if("object"==typeof e)return this.reportT(e);"string"==typeof e?"number"==typeof t?t<0||6e4<t?console.warn("reportTime: duration must between 0 and 60000"):this.submitCustomTime(e,t):console.warn("reportTime: second param must be number"):console.warn("reportTime: first param must be a string")},q.prototype.reportT=function(e){var t=e.name,n=e.duration,o=e.ext1,o=void 0===o?"":o,r=e.ext2,r=void 0===r?"":r,i=e.ext3,i=void 0===i?"":i,e=e.from;if("string"==typeof t&&"number"==typeof n&&"string"==typeof o&&"string"==typeof r&&"string"==typeof i){if(!(n<0||6e4<n))return this.submitCustomTime(t,n,o,r,i,void 0===e?"":e);console.warn("reportTime: duration must between 0 and 60000")}else console.warn("reportTime: params error")},q.prototype.time=function(e){"string"==typeof e?this.timeMap[e]?console.warn("Timer "+e+" already exists"):this.timeMap[e]=Date.now():console.warn("time: first param must be a string")},q.prototype.timeEnd=function(e){"string"==typeof e?this.timeMap[e]?(this.submitCustomTime(e,Date.now()-this.timeMap[e]),delete this.timeMap[e]):console.warn("Timer "+e+" does not exist"):console.warn("timeEnd: first param must be a string")},q.prototype.submitCustomTime=function(e,t,n,o,r,i){this.customTimePipeline({name:e,duration:t,ext1:n||this.config.ext1,ext2:o||this.config.ext2,ext3:r||this.config.ext3,from:i||void 0})},q.prototype.extendBean=function(e,t){this.bean[e]=t},q.prototype.sendPipeline=function(e,t){var n,i=this;return y(a([function(e,t){if("number"!=typeof n.config.random&&(console.warn("random must in [0, 1], default is 1."),n.config.random=1),!n.isHidden||!n.isGetSample)if(n.isGetSample)n.isHidden||t(e);else{if(n.isGetSample=!0,Math.random()<n.config.random)return n.isHidden=!1,t(e);n.isHidden=!0}},G(n=this,t)],e,[J(this),function(o,r){i.request(o,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=!1;-1<(""+e[i.failRequestCount=0]).indexOf("403 forbidden")&&(n=!0,i.destroy()),r({isErr:n,result:e,logType:null==o?void 0:o.type,logs:null==o?void 0:o.log}),null!=(n=null==o?void 0:o.success)&&n.call.apply(n,a([o],e))},function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];60<=++i.failRequestCount&&i.destroy(),-1<(""+t[0]).indexOf("403 forbidden")&&i.destroy(),r({isErr:!0,result:t,logType:null==o?void 0:o.type,logs:null==o?void 0:o.log}),null!=(e=null==o?void 0:o.fail)&&e.call.apply(e,a([o],t))})},K(this)]))},q.prototype.send=function(e,r,i){var t=this;return y([J(this),function(n,o){t.request(n,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o({isErr:!1,result:e,logType:n.type,logs:n.log}),null!=r&&r.apply(void 0,e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o({isErr:!0,result:e,logType:n.type,logs:n.log}),null!=i&&i.apply(void 0,e)})},K(this)])(e)},q.prototype.ready=function(e,t,n){throw new Error('You need to override "ready" method')},q.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},q.prototype.sendSDKError=function(e){var n=this;this.sendPipeline([function(e,t){t({url:n.config.url+"?id=1085&msg[0]="+encodeURIComponent(E(e))+"&level[0]=2&from="+n.config.id+"&count=1&version="+n.config.id+"(1.37.8)",addBean:!1,method:"get",type:b.SDK_ERROR,log:e})}],b.SDK_ERROR)(e)},q.prototype.destroy=function(e){void 0===e&&(e=!1);var t,n,o=q.instances.indexOf(this);-1!==o&&q.instances.splice(o,1);for(var r=q.installedPlugins.length-1;0<=r;r--)try{q.installedPlugins[r].unpatch(this)}catch(e){this.sendSDKError(e)}if(this.lifeCycle.emit("destroy"),this.lifeCycle.clear(),e)t=this,n=Object.getOwnPropertyDescriptors(t),Object.keys(n).forEach(function(e){n[e].writable&&(t[e]=null)}),Object.setPrototypeOf(this,null);else{for(var i=this;i.constructor!==Object&&s(i,this),i=Object.getPrototypeOf(i););0===q.instances.length&&(o=Object.getPrototypeOf(this).constructor,s(o),s(q))}},q.version="1.37.8",q.instances=[],q.logType=v,q.environment=u,q.installedPlugins=[],q),o=(L.prototype.patch=function(e){this.canUse(e)&&this.exist(e)&&(this.instances.push(e),this.triggerInit(e),this.triggerOnNewAegis(e))},L.prototype.unpatch=function(e){var t=this.instances.indexOf(e);-1!==t&&(this.instances.splice(t,1),0===this.instances.length)&&this.uninstall(e)},L.prototype.countInstance=function(){return this.instances.length},L.prototype.uninstall=function(e){var t;null!=(t=null==(t=this.option)?void 0:t.destroy)&&t.apply(this,[e])},L.prototype.walk=function(n){var o=this;this.instances.forEach(function(e){var t=o.canUse(e);t&&n(e,t)})},L.prototype.canUse=function(e){e=this.getConfig(e);return!(!e||"object"!=typeof e)||!!e},L.prototype.getConfig=function(e){return null==(e=e.config)?void 0:e[this.name]},L.prototype.exist=function(e){return-1===this.instances.indexOf(e)},L.prototype.triggerInit=function(e){var t;this.inited||(this.inited=!0,null==(t=null==(t=this.option)?void 0:t.init))||t.call(this.option,this.getConfig(e))},L.prototype.triggerOnNewAegis=function(e){var t;null!=(t=null==(t=this.option)?void 0:t.onNewAegis)&&t.call(this.option,e,this.getConfig(e))},L),i=wx||qq,me="",ye=new o({name:"device",onNewAegis:function(t){return e=this,l=function(){return I(this,function(e){return this.setSystemInfo(t),this.setNetworkType(t),this.setNetworkChange(t),[2]})},new(s=(s=a=void 0)||Promise)(function(n,t){function o(e){try{i(l.next(e))}catch(e){t(e)}}function r(e){try{i(l.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?n(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(o,r)}i((l=l.apply(e,a||[])).next())});var e,a,s,l},setSystemInfo:function(a){var s=this;try{r("getSystemInfo")&&i.getSystemInfo({success:function(e){var t=e.platform,n=e.model,o=e.windowHeight,r=e.windowWidth,i=e.screenWidth,i=void 0===i?0:i,e=e.screenHeight,e=void 0===e?0:e;a.extendBean("platform",s.getPlatFormType(t)),a.extendBean("model",n),a.extendBean("vp",Math.round(r)+" * "+Math.round(o)),a.extendBean("sr",Math.round(i)+" * "+Math.round(e))}})}catch(a){}},getPlatFormType:function(e){for(var t,n={android:/android/i,ios:/ios/i,windows:/windows/i,macos:/mac/i,devtools:/devtools/i},o=l.other,r=0;r<Object.keys(n).length;r++){var i=Object.keys(n)[r];if(null!=(t=n[i])&&t.test(e)){o=l[i];break}}return o},setNetworkChange:function(t){r("onNetworkStatusChange")&&i.onNetworkStatusChange(function(e){e=Q(e.networkType);t.extendBean("netType",e)})},setNetworkType:function(t){r("getNetworkType")&&i.getNetworkType({success:function(e){e=Q(e.networkType);t.extendBean("netType",e)}})}}),ve=i.request,n=(e(N,ne=n),Object.defineProperty(N.prototype,"getBean",{get:function(){var t=this;return this.bean?Object.getOwnPropertyNames(this.bean).map(function(e){return e+"="+t.bean[e]}).join("&")+"&from="+encodeURIComponent(z(this.config)):"from="+encodeURIComponent(z(this.config))},enumerable:!1,configurable:!0}),N.prototype.initRequestSchedule=function(){this.requestSchedule=new Y(this.sendRequest)},N.prototype.uploadLogs=function(e,t){this.lifeCycle.emit("uploadLogs",e=void 0===e?{}:e,t=void 0===t?{}:t)},N.prototype.reportPv=function(e){var t,n=this;e&&(t=Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+n.bean[e]}).join("&")+"&from="+encodeURIComponent(z(this.config)),this.send({url:this.config.url+"/"+e+"?"+t,addBean:!1,type:b.CUSTOM_PV,log:b.CUSTOM_PV},function(){},function(){}))},N.sessionID="session-"+Date.now(),N.asyncPluginIndex=0,N),be=new o({name:"aid",onNewAegis:function(t){this.initAid(function(e){t.bean.aid=e,t.config.aid=e})},initAid:function(t){i.getStorage({key:"AEGIS_ID",success:function(e){t(e.data)},fail:function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});i.setStorage({key:"AEGIS_ID",data:e,success:function(){t(e)}})}})}}),w=(C.prototype.addCallback=function(e){e&&this.callbacks.push(e)},C.prototype.prefixHandler=function(e){return f(f({},e),{aegisRequestStartTime:+new Date})},C.prototype.successHandler=function(n,o){var e;this.callbacks.forEach(function(e){var t;try{null!=(t=e.success)&&t.call(e,n,o)}catch(e){}}),null!=(e=o.success)&&e.call(o,n,o)},C.prototype.failHandler=function(n,o){var e;this.callbacks.forEach(function(e){var t;try{null!=(t=e.fail)&&t.call(e,n,o)}catch(e){}}),null!=(e=o.fail)&&e.call(o,n,o)},C.prototype.completeHandler=function(n,o){var e;this.callbacks.forEach(function(e){var t;try{null!=(t=e.complete)&&t.call(e,n,o)}catch(e){}}),null!=(e=o.complete)&&e.call(o,n,o)},C.prototype.override=function(){try{this.defineApiProperty()}catch(e){console.warn("cannot override `"+this.apiName+"`, error is: "+e)}finally{this.isOverride=!0}},C),P=wx||qq,k={},Ee=(e(x,te=w),x.prototype.defineApiProperty=function(){var e=this;P.cloud&&P.cloud[this.apiName]&&Object.defineProperty(P.cloud,this.apiName,{get:function(){return e.hackHandler.bind(e)}})},x.prototype.hackHandler=function(e){var o=this,r=this.prefixHandler(e);return new Promise(function(t,n){var e=null==(e=k[o.apiName])?void 0:e.originApi;null!=e&&e(f(f({},r),{success:function(e){o.successHandler(e,r),t(e)},fail:function(e){o.failHandler(e,r),n(e)},complete:function(e){o.completeHandler(e,r)}}))})},x),Oe=wx||qq,T={},Re=(e(S,ee=w),S.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(Oe,this.apiName,{get:function(){return e.hackHandler.bind(e)}})},S.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e),e=null==(e=T[this.apiName])?void 0:e.originApi;return null==e?void 0:e(f(f({},n),{success:function(e){t.successHandler(e,n)},fail:function(e){t.failHandler(e,n)},complete:function(e){t.completeHandler(e,n)}}))},S),we=wx||qq,Pe=we.request;function S(){return null!==ee&&ee.apply(this,arguments)||this}function x(){return null!==te&&te.apply(this,arguments)||this}function C(e){this.callbacks=[],this.isOverride=!1;var t=e.apiName;this.apiName=t,this.isOverride||this.override(),this.callbacks.push(e)}function N(e){var o,a,u=ne.call(this,e)||this;u.originRequest=ve,u.speedLogPipeline=y([(a=u.config,function(e,t){var n,o,r,i="number"==typeof a.repeat?a.repeat:60;!a.speedSample||i<=0?t(e):(n=(null==a?void 0:a.id)||"0",o=R[n]||{},Array.isArray(e)?(r=e.filter(function(e){var t=!o[e.url]||o[e.url]<i;return t?(o[e.url]=1+~~o[e.url],R[n]=o):O[n]||pe(n),t})).length&&t(r):!o[e.url]||o[e.url]<i?(o[e.url]=1+~~o[e.url],R[n]=o,t(e)):O[n]||pe(n))}),m(u),function(t,n){r("getNetworkType")?i.getNetworkType({success:function(e){e=Q(e.networkType);o.extendBean("netType",e),n(t)}}):n(t)},function(e,t){u.lifeCycle.emit("beforeReportSpeed",e);var n=u.config.beforeReportSpeed;if((e="function"==typeof n?e.filter(function(e){return!1!==n(e)}):e).length)return t(e)},G(o=u,b.SPEED),function(e,t){t(e.map(function(e){return void 0!==e.payload&&delete e.payload,e}))},function(e){var t,n,o,r;u.send({url:""+u.config.speedUrl,method:"post",data:(e=e,t=u.bean,o={fetch:[],static:[],bridge:[]},r={},Array.isArray(e)?e.forEach(function(e){var t;null!=(t=o[e.type])&&t.push(e)}):null!=(n=o[e.type])&&n.push(e),r.payload=JSON.stringify(f({duration:o},t)),r)})}]),u.request=function(e,t,n){e.url&&u.bean.id&&(!/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(String(u.bean.aid))||r("getNetworkType")&&void 0===u.bean.netType?u.requestSchedule.addTask({options:e,success:t,fail:n}):(u.requestSchedule.addTask({options:e,success:t,fail:n}),u.requestSchedule.fireTask()))},u.sendRequest=function(e,t,n){var o,r,i,a=e.url,s=(u.config.whiteListUrl===a&&(o=t,t=function(e){null!=o&&o(JSON.stringify(e.data))}),e.method),s=void 0===s?"get":s,l=(!1!==e.addBean&&(a=a+(-1===(null==a?void 0:a.indexOf("?"))?"?":"&")+u.getBean),e),c=u.config.onBeforeRequest;return(l=c?c(e,u):l)&&l.url?(c=u.config.enableHttp2||!1,"get"===s?(s=a,r=l.data,a="string"!=typeof s?"":"object"==typeof r&&r?(i=Object.getOwnPropertyNames(r).map(function(e){var t=r[e];return e+"="+("string"==typeof t?encodeURIComponent(t):encodeURIComponent(JSON.stringify(t)))}).join("&").replace(/eval/gi,"evaI"),s+(-1===s.indexOf("?")?"?":"&")+i):s,u.originRequest(f({url:a,enableHttp2:c,success:t,fail:n,complete:u.requestSchedule.complete},e.requestConfig))):("string"==typeof l.data&&(l.data=l.data.replace(/eval/gi,"evaI")),u.originRequest(f({url:a,enableHttp2:c,header:l.contentType?{"content-type":l.contentType}:void 0,method:"POST",data:l.data,success:t,fail:n,complete:u.requestSchedule.complete},e.requestConfig))),!0):(i="",l&&l.url||(i="Sending request blocked. Please handle the parameters reasonably, options.url is necessary",console.log(i)),null!=n&&n(i),u.requestSchedule.complete(),!1)};try{u.initRequestSchedule(),u.init(e),u.extendBean("sessionId",N.sessionID),u.extendBean("referer",(r("getLaunchOptionsSync")?i.getLaunchOptionsSync():{scene:""}).scene||"")}catch(e){console.warn(e),console.log("%cThe above error occurred in the process of initializing Aegis, which will affect your normal use of Aegis.\nIt is recommended that you contact us for feedback and thank you for your support.","color: red"),u.sendSDKError(e)}return u}function L(e){this.aegisPlugin=!0,this.name="",this.instances=[],this.inited=!1,e.$walk=this.walk.bind(this),e.$getConfig=this.getConfig.bind(this),this.option=e,this.name=e.name}function q(e){var n,t,o,r,a,i,s,l,c,u,f,p,d,h,g=this;this.isGetSample=!1,this.isHidden=!1,this.config={version:0,delay:1e3,onError:!0,repeat:60,random:1,aid:!0,device:!0,pagePerformance:!0,webVitals:!0,speedSample:!0,onClose:!0,reportLoadPackageSpeed:!0,hostUrl:"https://aegis.qq.com",env:"production",url:"",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",webVitalsUrl:"",eventUrl:"",setDataReportUrl:"",reportImmediately:!0},this.isWhiteList=!1,this.lifeCycle=new F,this.bean={},this.normalLogPipeline=y([m(this,5),V,function(e,t){var o=n.config;t(e=e.map(function(e){var t,n=o.maxLength||102400;try{if(!e.msg||e.msg.length<=n)return e;e.msg=null==(t=e.msg)?void 0:t.substring(0,n)}catch(t){e.msg=E(e.msg).substring(0,o.maxLength)}return e}))},(h=(n=this).config,function(e,t){var n="number"==typeof h.repeat?h.repeat:60;if(n<=0)return t(e);var o=(null==h?void 0:h.id)+"_error",r=R[o]||{};t(e.filter(function(e){if(e.level===v.ERROR||e.level===v.PROMISE_ERROR||e.level===v.AJAX_ERROR||e.level===v.SCRIPT_ERROR||e.level===v.IMAGE_ERROR||e.level===v.CSS_ERROR||e.level===v.MEDIA_ERROR||e.level===v.RET_ERROR||e.level===v.BRIDGE_ERROR||e.level===v.PAGE_NOT_FOUND_ERROR||e.level===v.WEBSOCKET_ERROR||e.level===v.LAZY_LOAD_ERROR){e=e.msg.slice(0,200);if(r[e]>n)return O[o]||pe(o),!1;r[e]=1+~~r[e],R[o]=r}return!0}))}),(p=this.lifeCycle.emit,d=this.config,function(e,t){var n,o=d.logCreated;return"function"==typeof o?(n=e.filter(function(e){return!1!==o(e)}),p("beforeWrite",n),t(n)):(p("beforeWrite",e),t(e))}),(f=this,setTimeout(function(){var e=f.config,t=e.pvUrl,n=void 0===t?"":t,t=e.spa,e=-1<["web-sdk","mp-sdk"].indexOf("mp-sdk");n&&(e&&!t||!e)&&f.sendPipeline([function(e,t){t({url:n,type:b.PV})}],b.PV)(null)},100),function(e,t){t(e)}),(c=l=s=!1,u=[],(a=this).lifeCycle.on("onConfigChange",function(){i&&clearTimeout(i),i=setTimeout(function(){var e,n;!c&&a.config&&(c=!0,e=a.config.whiteListUrl,(n=void 0===e?"":e)&&a.sendPipeline([function(e,t){t({url:n,type:b.WHITE_LIST,success:function(e){l=!0;try{var t=e.data||JSON.parse(e),n=t.retcode,o=t.result,r=void 0===o?{}:o,i=(0===n&&(s=r.is_in_white_list,a.isWhiteList=s,0<=r.rate)&&r.rate<=1&&(a.config.random=r.rate,a.isGetSample=!1),a.isWhiteList&&u.length?he(a)(u.splice(0),function(){}):!a.isWhiteList&&u.length&&(u.length=0),a.config.onWhitelist);"function"==typeof i&&i(s)}catch(e){}},fail:function(){l=!0}})}],b.WHITE_LIST)(null),c=!1)},a.config.uin?50:500)}),a.lifeCycle.on("destroy",function(){u.length=0}),function(e,t){var n;s||null!=(n=null==(n=a.config)?void 0:n.api)&&n.reportRequest?t(e.concat(u.splice(0)).map(function(e){return fe(e),e})):(n=e.filter(function(e){return e.level!==v.INFO&&e.level!==v.API_RESPONSE?(fe(e),!0):(l||(u.push(e),200<=u.length&&(u.length=200)),!1)})).length&&t(n)}),function(e,t){try{var n=JSON.parse(JSON.stringify(e)),o=(g.lifeCycle.emit("beforeReport",n),g.config.beforeReport);(e="function"==typeof o?e.filter(function(e){return!1!==o(e)}):e).length&&t(e)}catch(e){}},he(this)]),this.eventPipeline=y([m(this,10),(r=this,function(e){r.sendPipeline([function(e,t){var n=e.map(function(e){return{name:e.name,ext1:e.ext1||r.config.ext1||"",ext2:e.ext2||r.config.ext2||"",ext3:e.ext3||r.config.ext3||""}});t({url:r.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(n)),type:b.EVENT,log:e})}],b.EVENT)(e)})]),this.timeMap={},this.failRequestCount=0,this.customTimePipeline=y([m(this,10),(o=this,function(e){return o.sendPipeline([function(e,t){t({url:o.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:b.CUSTOM,log:e})}],b.CUSTOM)(e)})]),this.config=(t=this.config,void 0===(e=e.hostUrl)&&(e="https://aegis.qq.com"),t.url=t.url||e+"/collect",t.offlineUrl=t.offlineUrl||e+"/offline",t.whiteListUrl=t.whiteListUrl||e+"/collect/whitelist",t.pvUrl=t.pvUrl||e+"/collect/pv",t.eventUrl=t.eventUrl||e+"/collect/events",t.speedUrl=t.speedUrl||e+"/speed",t.customTimeUrl=t.customTimeUrl||e+"/speed/custom",t.performanceUrl=t.performanceUrl||e+"/speed/performance",t.webVitalsUrl=t.webVitalsUrl||e+"/speed/webvitals",t.setDataReportUrl=t.SetDataReportUrl||e+"/speed/miniProgramData",t),q.instances.push(this)}function ke(){return null!==oe&&oe.apply(this,arguments)||this}e(ke,oe=w),ke.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(we,"request",{get:function(){return e.hackHandler.bind(e)}})};function A(o,e,r){return null!=e&&e.length&&"object"==typeof o?e.reduce(function(e,t){var n=o[t];return n?e+(""===e?"\n":"\n\n")+r+" header "+t+": "+n:e},""):""}var _,Te,Se=new o({name:"reportApiSpeed",override:!(ke.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e);return Pe(f(f({},n),{success:function(e){t.successHandler(e,n)},fail:function(e){t.failHandler(e,n)},complete:function(e){t.completeHandler(e,n)}}))}),onNewAegis:function(e){this.override||(this.override=!0,this.hackRequest(e.config),this.overrideCallFunction(e.config),this.overrideCallContainer(e.config))},hackRequest:function(c){var u=this;Z({apiName:"request",success:function(e,t){var n,o,r,i,a,s,l;g(t.url,c.hostUrl)||(n={method:t.method||"get",url:p(t.url),duration:Date.now()-t.aegisRequestStartTime,status:e.statusCode||0,nextHopProtocol:"",isHttps:W(t.url),type:"fetch"},i=null==(i=c.api)?void 0:i.apiDetail,o=(r=d(e.data,c.api,{url:t.url,ctx:e,payload:t.data})||{}).code,r=r.isErr,l=i?h(t.data,null==(l=c.api)?void 0:l.reqParamHandler,{url:t.url}):"",i=i?h(e.data,null==(i=c.api)?void 0:i.resBodyHandler,{url:t.url}):"",a=(null==(a=c.api)?void 0:a.reqHeaders)||[],a=A(null==t?void 0:t.header,a,"req"),s=(null==(s=c.api)?void 0:s.resHeaders)||[],s=A(null==e?void 0:e.header,s,"res"),l="req url: "+n.url+" \n \nres status: "+(e.statusCode||0)+" \n \nres duration: "+n.duration+"ms \n \nreq method: "+n.method+" \n \nreq param: "+l+" \n \nres retcode: "+o+" \n \nres data: "+i+"\n "+a+"\n "+s,u.publishNormalLog({msg:l,level:v.API_RESPONSE,ctx:e}),n.ret=o,n.isErr=+r,n.payload=t.data,u.publishSpeedLog(n),r&&u.publishNormalLog({msg:l,level:v.RET_ERROR,ctx:e}))},fail:function(e,t){g(t.url,c.hostUrl)||(t={method:t.method||"get",url:p(t.url),duration:Date.now()-t.aegisRequestStartTime,status:0,nextHopProtocol:"",isHttps:W(t.url),type:"fetch"},u.publishSpeedLog(t))}})},overrideCallFunction:function(n){var o=this;X({apiName:"callFunction",success:function(e,t){o.cloudSuccessCallback(n,t,e,"callFunction")},fail:function(e,t){t={method:"call",url:"wx.cloud.callFunction."+t.name,duration:Date.now()-t.aegisRequestStartTime,status:0,nextHopProtocol:"",type:"fetch",errMsg:e.errMsg,isHttps:!0};o.publishSpeedLog(t)}})},overrideCallContainer:function(n){var o=this;X({apiName:"callContainer",success:function(e,t){o.cloudSuccessCallback(n,t,e,"callContainer")},fail:function(e,t){t={method:"call",url:"wx.cloud.callContainer."+t.path,duration:Date.now()-t.aegisRequestStartTime,status:0,nextHopProtocol:"",type:"fetch",errMsg:e.errMsg,isHttps:!0};o.publishSpeedLog(t)}})},cloudSuccessCallback:function(e,n,t,o){var r="callFunction"===o?n.name:n.path,i="callFunction"===o?t.result:t.data,r={method:"call",url:"wx.cloud."+o+"."+r,duration:Date.now()-n.aegisRequestStartTime,status:200,nextHopProtocol:"",type:"fetch",isHttps:!0},a=["apiName","aegisRequestStartTime","config","success","fail","complete"],s=Object.keys(n).reduce(function(e,t){return a.includes(t)||(e[t]=n[t]),e},{}),o="callFunction"===o?(null==(o=t.data)?void 0:o.code)||0:t.statusCode,l=d(i,e.api,{url:r.url,ctx:t,payload:s})||{},c=l.code,l=l.isErr,l=void 0!==l&&l,c=(r.ret=c,r.isErr=+l,r.payload=s,null==(c=e.api)?void 0:c.apiDetail),s=c?h(s,null==(s=e.api)?void 0:s.reqParamHandler,{url:r.url}):"",i=c?h(i,null==(c=e.api)?void 0:c.resBodyHandler,{url:r.url}):"",c=(null==(c=e.api)?void 0:c.reqHeaders)||[],c=A(null==n?void 0:n.header,c,"req"),e=(null==(e=e.api)?void 0:e.resHeaders)||[],e=A(null==t?void 0:t.header,e,"res"),o="req url: "+r.url+"\n \nres status: "+o+"\n \nres duration: "+r.duration+"ms \n \nreq type: "+r.type+"\n \nreq params: "+s+"\n \nres retcode: "+r.ret+"\n \nres data: "+i+"\n "+c+"\n "+e;this.publishNormalLog({msg:o,level:v.API_RESPONSE,ctx:t}),this.publishSpeedLog(r),l&&this.publishNormalLog({msg:o,level:v.RET_ERROR,ctx:t})},publishSpeedLog:function(t){this.$walk(function(e){e.speedLogPipeline(t)})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})}}),xe=wx||qq,Ce=xe.connectSocket,Ne=(Ue.prototype.addConfig=function(e){var t=e.send,e=e.onError;t&&this.sends.push(t),e&&this.onErrors.push(e)},Ue.prototype.toHack=function(t){var r=this,n=(this.onErrors.forEach(function(e){t.onError(e)}),t.send);return Object.defineProperty(t,"send",{get:function(){return function(o){return new Promise(function(e){n.call(t,f(f({},o),{fail:function(n){r.sends.forEach(function(e){var t;null!=(t=e.fail)&&t.call(e,n,o)}),e(n)}}))})}}}),t},Ue),Le=(e(U,Te=w),U.prototype.addTaskConf=function(e){this.taskHack.addConfig(e)},U.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(xe,"connectSocket",{get:function(){return e.hackHandler.bind(e)}})},U.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e),e=Ce(f(f({},n),{success:function(e){t.successHandler(e,n)},fail:function(e){t.failHandler(e,n)},complete:function(e){t.completeHandler(e,n)}}));return this.taskHack.toHack(e),e},U),w=new o({name:"onError",onNewAegis:function(e){var t=i.getSystemInfoSync().SDKVersion;this.listenError(),this.hackNetWork(e),this.hackCloud(e),e.config.websocketHack&&$(t,"1.7.0")&&this.hackWsConnect()},listenError:function(){var t=this;"function"==typeof i.onError&&i.onError(function(e){e&&t.publishErrorLog({msg:e,level:v.ERROR})}),r("onUnhandledRejection")&&i.onUnhandledRejection(function(e){e=e.reason;!e||-1<JSON.stringify(e).indexOf("request:fail")||t.publishErrorLog({msg:e,level:v.PROMISE_ERROR})}),r("onPageNotFound")&&i.onPageNotFound(function(e){e&&t.publishErrorLog({msg:e,level:v.PAGE_NOT_FOUND_ERROR})}),r("onLazyLoadError")&&i.onLazyLoadError(function(e){e&&t.publishErrorLog({msg:e,level:v.LAZY_LOAD_ERROR})})},publishErrorLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},hackNetWork:function(e){for(var n=this,o=e.config,t=0,r=[{apiName:"request",complete:function(e,t){return n.requestCompleteError(e,t,o)}},{apiName:"uploadFile",complete:function(e,t){return n.uploadFileCompleteError(e,t,o)}},{apiName:"downloadFile",complete:function(e,t){return n.downloadFileCompleteError(e,t,o)}}];t<r.length;t++){var i=r[t],a=i.apiName,i=i.complete;Z({apiName:a,complete:i})}},requestCompleteError:function(e,t,n){var o=e.errMsg,r=e.statusCode;g(t.url,n.hostUrl)||(o=this.getErrorType({errMsg:o,statusCode:r}))&&this.publishNetWorkError({apiName:"request",opts:t,res:e,config:n,type:o})},downloadFileCompleteError:function(e,t,n){var o=e.errMsg,r=e.statusCode,i=e.filePath,a=e.tempFilePath,o=this.getErrorType({errMsg:o,statusCode:r});o&&this.publishNetWorkError({apiName:"downloadFile",opts:t,res:e,config:n,type:o},{extraInfo:"\nres filePath: "+i+"\nres tempFilePath: "+a})},uploadFileCompleteError:function(e,t,n){var o=e.errMsg,r=e.statusCode,o=this.getErrorType({errMsg:o,statusCode:r});o&&this.publishNetWorkError({apiName:"uploadFile",opts:t,res:e,config:n,type:o})},hackCloud:function(e){for(var n=this,o=e.config,t=0,r=[{apiName:"callFunction",complete:function(e,t){return n.callFunctionCompleteError(e,t,o)}},{apiName:"callContainer",complete:function(e,t){return n.callContainerCompleteError(e,t,o)}}];t<r.length;t++){var i=r[t],a=i.apiName,i=i.complete;X({apiName:a,complete:i})}},callFunctionCompleteError:function(e,t,n){var o=e.errMsg,o=this.getErrorType({errMsg:o});o&&this.publishNetWorkError({apiName:"cloud.callFunction",opts:t,res:e,config:n,type:o})},callContainerCompleteError:function(e,t,n){var o=e.errMsg,r=e.statusCode,o=this.getErrorType({errMsg:o,statusCode:r});o&&this.publishNetWorkError({apiName:"cloud.callContainer",opts:t,res:e,config:n,type:o})},publishNetWorkError:function(e,t){var t=t.extraInfo,t=void 0===t?"":t,n=e.apiName,o=e.opts,r=e.res,i=e.config,e=e.type,a=r.errMsg,s=r.statusCode,l=r.data,c=o.url,u=d(l,i.api,{url:c,ctx:r,payload:o.data}).code,f=null==(f=i.api)?void 0:f.apiDetail,p=f?h(o.data,null==(p=i.api)?void 0:p.reqParamHandler,{url:c}):"",l=f?h(l,null==(f=i.api)?void 0:f.resBodyHandler,{url:c}):"",c=(null==(f=i.api)?void 0:f.reqHeaders)||[],f=A(null==o?void 0:o.header,c,"req"),i=(null==(c=i.api)?void 0:c.resHeaders)||[],c=A(null==r?void 0:r.header,i,"res");this.publishErrorLog({msg:"AJAX_ERROR: "+n+" "+e+"\n \nreq url: "+o.url+"\n \nres status: "+(s||0)+"\n \nres duration: "+(Date.now()-o.aegisRequestStartTime)+"ms\n \nreq method: "+(o.method||"get")+"\n \nreq param: "+p+"\n \nres retcode: "+u+"\n \nres data: "+l+"\n \nerrMsg: "+a.slice(0,1e3)+"\n "+t+"\n "+f+"\n "+c,level:v.AJAX_ERROR})},getErrorType:function(e){var t=e.errMsg,e=e.statusCode,n="",o=t;return["timeout","time out","ERR_CONNECTION_TIMED_OUT","ERR_TIMED_OUT","超时"].some(function(e){return String(o||"").includes(e)})?n="timeout":400<=e?n="error":(-1<t.indexOf("fail")||!e||e<0)&&(n="failed"),n},hackWsConnect:function(){var e,t,n=this;Z({apiName:"sendSocketMessage",fail:function(e){n.publishSocketError(e)}}),e=(t={connectCallback:{fail:function(e){n.publishSocketError(e)}},taskOpt:{onError:function(e){n.publishSocketError(e)},send:{fail:function(e){n.publishSocketError(e)}}}}).connectCallback,t=t.taskOpt,_?_.addCallback(e):_=new Le(e),t&&_.addTaskConf(t)},publishSocketError:function(e){e&&this.publishErrorLog({msg:e.errMsg,level:v.WEBSOCKET_ERROR})}}),qe=new o({name:"reportAssetSpeed",isStart:!1,onNewAegis:function(e){this.isStart||(this.isStart=!0,this.start(e))},start:function(t){var e,n=this;i.getPerformance&&"function"==typeof(e=i.getPerformance()).createObserver&&e.createObserver(function(e){e=e.getEntries();null!=e&&e.forEach(function(e){g(e.uri,t.config.hostUrl)||"number"!=typeof e.duration||e.duration<=0||n.publishAssetLog(e)})}).observe({entryTypes:["resource"]})},generateLog:function(e){var t,n,o=e.transferSize;return{url:(t=e.uri,void 0===n&&(n=2048),String(t).replace(H,"").slice(0,n)),method:"get",duration:Math.round(100*e.duration)/100,status:200,type:"static",isHttps:!0,urlQuery:p(e.uri,!0),nextHopProtocol:"",domainLookup:0,connectTime:0,transferSize:0<o?o:-1}},publishAssetLog:function(t){var n=this;this.$walk(function(e){e.speedLogPipeline(n.generateLog(t))})}}),Ae=["onLaunch","onHide","onError","onLoad","onReady","onShow","onUnload"],_e=new o({name:"pagePerformance",pageNavigationStartTime:{},onNewAegis:function(e){try{r("getPerformance")&&this.reportPerformance(e),this.setPagePV(e),this.reportSetDataTiming(e)}catch(e){}},reportPerformance:function(f){var p=this,e=i.getPerformance(),e=null==e?void 0:e.createObserver(function(e){var t={},n=null==(n=e.getEntriesByName("appLaunch"))?void 0:n[0],o=null==(o=e.getEntriesByName("firstRender"))?void 0:o[0],r=null==(r=e.getEntriesByName("evaluateScript"))?void 0:r[0],i=null==(i=e.getEntriesByName("route"))?void 0:i[0],a=null==(a=null==(a=e.getEntriesByName("firstPaint"))?void 0:a[0])?void 0:a.startTime,s=null==(s=null==(s=e.getEntriesByName("largestContentfulPaint"))?void 0:s[0])?void 0:s.startTime,l=null==(l=null==(l=e.getEntriesByName("firstContentfulPaint"))?void 0:l[0])?void 0:l.startTime,c=null==(c=(null==(c=e.getEntriesByName("firstPaint"))?void 0:c[0])||(null==(c=e.getEntriesByName("route"))?void 0:c[0])||(null==(c=e.getEntriesByName("appLaunch"))?void 0:c[0]))?void 0:c.pageId,u=null==(e=(null==(u=e.getEntriesByName("route"))?void 0:u[0])||(null==(u=e.getEntriesByName("appLaunch"))?void 0:u[0]))?void 0:e.startTime;c&&(p.pageNavigationStartTime[c]=null,u)&&(p.pageNavigationStartTime[c]=u),n&&(t.appLaunch=n.duration||-1),o&&(t.firstScreenTiming=o.duration||-1),r&&(t.scriptEvaluateTiming=r.duration||-1),i&&(t.pageRouteTiming=i.duration||-1),a&&u?t.firstPaintTiming=Math.max(a-u,-1):a&&p.pageNavigationStartTime[c]&&(t.firstPaintTiming=Math.max(a-p.pageNavigationStartTime[c],-1)),s&&u?t.LCP=Math.max(s-u,-1):s&&p.pageNavigationStartTime[c]&&(t.LCP=Math.max(s-p.pageNavigationStartTime[c],-1)),l&&u?t.FCP=Math.max(l-u,-1):l&&p.pageNavigationStartTime[c]&&(t.FCP=Math.max(l-p.pageNavigationStartTime[c],-1)),0<Object.keys(t).length&&p.publish(t,f)});null!=e&&e.observe({entryTypes:["navigation","render","script"]})},publish:function(t,n){var e,o,r,i=[],a=n.config,s=-1===(null==(e=n.config.performanceUrl)?void 0:e.indexOf("?"))?"?":"&";for(o in t)i.push(o+"="+t[o]);"function"==typeof a.urlHandler?(r=a.urlHandler()||window.location.href,this.$walk(function(e){e.send({url:n.config.performanceUrl+s+i.join("&")+"&from="+encodeURIComponent(r),beanFilter:["from"],type:b.PERFORMANCE,log:t})})):this.$walk(function(e){e.send({url:n.config.performanceUrl+s+i.join("&"),type:b.PERFORMANCE,log:t})})},setPagePV:function(t){var n=this;i.onAppRoute&&i.onAppRoute(function(e){"appLaunch"===e.openType&&!t.config.spa||(n.$walk(function(e){e.send({url:""+e.config.pvUrl,type:b.PV})}),n.reportPageLoaded(e))})},reportPageLoaded:function(e){e="infoType: behaviorBacktracking\ndataType: pageLoadAndRoute\npageLoadedPath: "+e.path+"\nopenType: "+e.openType;this.publishNormalLog({msg:e,level:v.INFO})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},reportSetDataTiming:function(t){var e,r,s,l,n,i,a,c,u=this,o=t.config.setDataReportConfig,o=void 0===o?{}:o;!0!==o.disabled&&(e=o.timeThreshold,r=!1!==o.withDataPaths,s=e&&0<+e?+e:30,l=y([m(t,10),function(e){e=e.map(function(e){return{type:b.SET_DATA,component:e.from,duration:e.duration,fields:e.dataPaths&&e.dataPaths.length?e.dataPaths.sort().join(";"):void 0,size:e.size}});t.send({url:t.config.setDataReportUrl+"?payload="+encodeURIComponent(JSON.stringify({miniProgramData:e})),type:b.SET_DATA,log:e})}]),n=Page,i=Component,a=function(e,t){var i,a,n=t.updateStartTimestamp,o=t.updateEndTimestamp,t=t.dataPaths,t=void 0===t?[]:t,o=o-n;isNaN(o)||o<s||(n={from:e.is,duration:o},r&&0<t.length&&Object.assign(n,{dataPaths:t.slice(0,30),size:(o=t,a=0,null!=(i=e)&&i.data?(o.forEach(function(e){for(var t=i.data[e[0]],n=1,o=e.length;n<o;n++)t[e[n]]&&(t=t[e[n]]);var r="";try{r=JSON.stringify(t)}catch(e){r=""}a+=2*(void 0===r?"":r).replace(/[\u4e00-\u9fa5]/g,"aa").length}),a=Math.min(a,10485760)):a)}),l(n))},c=function(o){var e="infoType: behaviorBacktracking\ndataType: tapEvent"+Object.keys(o[0]).reduce(function(e,t){var n="";try{n=t+": "+JSON.stringify(o[0][t])}catch(e){n=""}return e+"\n"+n},"");u.publishNormalLog({msg:e,level:v.INFO})},Page=function(t){var e=t.onReady;return t.onReady=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:r},function(e){a(t,e)}),null==e?void 0:e.call(this)},Object.keys(t).forEach(function(e){var n;"function"!=typeof t[e]||Ae.includes(e)||(n=t[e],t[e]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return null!=e&&e[0]&&"tap"===e[0].type&&c(e),null==n?void 0:n.apply(this,e)})}),n(t)},Component=function(e){e.lifetimes&&e.lifetimes.attached?(n=e.lifetimes.attached,e.lifetimes.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:r},function(e){a(t,e)}),null==n?void 0:n.call(this)}):(o=e.attached,e.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:r},function(e){a(t,e)}),null==o?void 0:o.call(this)});var n,o,t=e.methods;return t&&"[object Object]"===Object.prototype.toString.call(t)&&Object.keys(t).forEach(function(e){var n;"function"==typeof t[e]&&(n=t[e],t[e]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return null!=e&&e[0]&&"tap"===e[0].type&&c(e),null==n?void 0:n.apply(this,e)})}),i(e)})}}),o=new o({name:"reportLoadPackageSpeed",isLoaded:!1,onNewAegis:function(e){this.isLoaded||(this.isLoaded=!0,this.start(e))},start:function(){var t=this;i.getPerformance&&i.getPerformance().createObserver(function(e){e=e.getEntries();null!=e&&e.forEach(function(e){"number"!=typeof e.duration||e.duration<=0||t.publishPackageLog(e)})}).observe({entryTypes:["loadPackage"]})},generateLog:function(e){return[{type:b.LOAD_PACKAGE,packageName:e.packageName,size:Math.round(100*e.packageSize)/100,duration:Math.round(100*e.duration)/100}]},publishPackageLog:function(n){var o=this;this.$walk(function(e){var t=o.generateLog(n);e.send({url:e.config.setDataReportUrl+"?payload="+encodeURIComponent(JSON.stringify({miniProgramData:t})),type:b.LOAD_PACKAGE,log:t})})}});function U(e){e=Te.call(this,e)||this;return e.taskHack=new Ne,e}function Ue(){this.onErrors=[],this.sends=[]}return n.use(w),n.use(Se),n.use(be),n.use(qe),n.use(_e),n.use(o),n.use(ye),n});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Aegis=t()}(this,function(){"use strict";var j=function(e,t){return(j=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}))(e,t)};function e(e,t){function n(){this.constructor=e}j(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var f=function(){return(f=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function I(o,r){var i,a,s,l={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(n){return function(e){var t=[n,e];if(i)throw new TypeError("Generator is already executing.");for(;l;)try{if(i=1,a&&(s=2&t[0]?a.return:t[0]?a.throw||((s=a.return)&&s.call(a),0):a.next)&&!(s=s.call(a,t[1])).done)return s;switch(a=0,(t=s?[2&t[0],s.value]:t)[0]){case 0:case 1:s=t;break;case 4:return l.label++,{value:t[1],done:!1};case 5:l.label++,a=t[1],t=[0];continue;case 7:t=l.ops.pop(),l.trys.pop();continue;default:if(!((s=0<(s=l.trys).length&&s[s.length-1])||6!==t[0]&&2!==t[0])){l=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3]))l.label=t[1];else if(6===t[0]&&l.label<s[1])l.label=s[1],s=t;else{if(!(s&&l.label<s[2])){s[2]&&l.ops.pop(),l.trys.pop();continue}l.label=s[2],l.ops.push(t)}}t=r.call(o,l)}catch(e){t=[6,e],a=0}finally{i=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}function a(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var o=Array(e),r=0,t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,r++)o[r]=i[a];return o}Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(null==e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),n=1;n<arguments.length;n++)if(null!=(o=arguments[n]))for(var o=Object(o),r=Object.keys(Object(o)),i=0,a=r.length;i<a;i++){var s=r[i],l=Object.getOwnPropertyDescriptor(o,s);null!=l&&l.enumerable&&(t[s]=o[s])}return t}});var H=/_?t(\d)?(imestamp)?=\d+&?/g,D=["aegis.qq.com","tamaegis.com","/aegis-sdk","rumt-","/flog.core.min.js","pingfore.qq.com","pingfore.tencent.com","zhiyan.tencent-cloud.net","h.trace.qq.com","btrace.qq.com","beacon.qq.com","dmplog.qq.com","qq.com/report","svibeacon.onezapp.com","cube.weixinbridge.com","doubleclick.net","pcmgrmonitor.3g.qq.com","tdm.qq.com","report.qqweb.qq.com","tpstelemetry.tencent.com","insight.cloud.tencent.com","facebook.com","facebook.net","google","yahoo.com","twitter.com","ga-audiences","report.idqqimg.com","arms-retcode.aliyuncs.com","px.effirst.com","sentry","baidu.com","hot-update.json","u.c.b.r.o.w.s.e.r","report.url.cn","sockjs-node","m3u8"],M=["ext1","ext2","ext3","level","trace","tag","seq","code"],F=(t.prototype.indexOf=function(e,t){for(var n=0;n<e.length;n++)if(e[n].callback===t)return n;return-1},t.prototype.on=function(e,t,n){var o;if(void 0===n&&(n=0),this)return(o=this.eventsList[e])||(this.eventsList[e]=[],o=this.eventsList[e]),-1===this.indexOf(o,t)&&o.push({name:e,type:n||0,callback:t}),this},t.prototype.one=function(e,t){this.on(e,t,1)},t.prototype.remove=function(e,t){if(this){var n=this.eventsList[e];if(n){if(t)return n.length&&(t=this.indexOf(n,t),n.splice(t,1)),this;try{delete this.eventsList[e]}catch(e){}}return null}},t.prototype.clear=function(){this.eventsList={}},t),B=function(e){if(!e||0===e.length)return"{}";e=Array.isArray(e)?e:[e];var t=Object.keys(e[0]),n={},o=(t.forEach(function(t){n[t]=e.map(function(e){return e[t]})}),n.count=e.length,n);if("string"==typeof o)return o;try{return JSON.stringify(o,ie())||"undefined"}catch(o){return"error happen when aegis stringify: \n "+o.message+" \n "+o.stack}};function t(){var a=this;this.emit=function(e,t){if(a){var n;if(null!=(o=a.eventsList[e])&&o.length)for(var o=o.slice(),r=0;r<o.length;r++){n=o[r];try{var i=n.callback.apply(a,[t]);if(1===n.type&&a.remove(e,n.callback),!1===i)break}catch(e){throw e}}return a}},this.eventsList={}}function p(e,t){return"string"==typeof e?e.split("?")[t?1:0]||"":e}function W(e){return"string"==typeof e&&/^\//.test(e)?"https:"===(null===location||void 0===location?void 0:location.protocol):/^https/.test(e)}function d(e,t,n){var o,r;try{if("function"==typeof(null==t?void 0:t.retCodeHandler))return{code:void 0===(i=(r=t.retCodeHandler(e,null==n?void 0:n.url,null==n?void 0:n.ctx,null==n?void 0:n.payload)||{}).code)?"unknown":i,isErr:r.isErr};if(!(e="string"==typeof e?JSON.parse(e):e))return{code:"unknown",isErr:!1};"function"==typeof(null==(o=null==t?void 0:t.ret)?void 0:o.join)&&(re=[].concat(t.ret.map(function(e){return e.toLowerCase()})));var i,a=Object.getOwnPropertyNames(e).filter(function(e){return-1!==re.indexOf(e.toLowerCase())});return a.length?{code:""+(i="未知"!==(i=e[a[0]])&&""!==i?i:"unknown"),isErr:0!==i&&"0"!==i&&"unknown"!==i}:{code:"unknown",isErr:!1}}catch(e){return{code:"unknown",isErr:!1}}}function h(e,t,n){try{var o="function"==typeof t?t(e,null==n?void 0:n.url)||"":e;return ae(o).slice(0,102400)}catch(e){return""}}function g(t,e){return"string"!=typeof t||!t||e&&-1<t.indexOf(e)||ce.test(t)||D.some(function(e){return-1<t.indexOf(e)})}function m(n,o){var r,i=[],a=n.config;return n.lifeCycle.on("destroy",function(){i.length=0}),function(e,t){Array.isArray(e)?i=i.concat(e):i.push(e),o&&i.length>=o||n.sendNow&&0<i.length?(i=ue(i),t(i.splice(0,i.length)),r&&clearTimeout(r)):(r&&clearTimeout(r),r=setTimeout(function(){r=null,0<(i=ue(i)).length&&t(i.splice(0,i.length))},a.delay))}}function V(e,t){return Array.isArray(e)?t(e.map(function(e){return t=f(f({},e),{msg:"string"==typeof e.msg?e.msg:[].concat(e.msg).map(E).join(" ")}),M.forEach(function(e){t[e]||delete t[e]}),t;var t})):t([f(f({},e),{msg:"string"==typeof e.msg?e.msg:E(e.msg)})])}function G(l,c){return function(e,t){var n,o,r,i=Array.isArray(e),a=i?e:[e],s=(l.lifeCycle.emit("beforeRequest",e),l.config.beforeRequest);(a="function"==typeof s?a.map(function(t){try{var e=s({logs:t,logType:c});return(null==e?void 0:e.logType)===c&&null!=e&&e.logs?e.logs:!1!==e&&t}catch(e){return t}}).filter(function(e){return!1!==e}):a).length&&(n=a,e=M,!Array.isArray(n)||n.length<=1||(o=[],r=[],!(r="string"==typeof e?[e]:e))||r.length<=0||(r.forEach(function(t){n.forEach(function(e){null!=e&&e[t]&&o.push(t)})}),0<o.length&&(n=n.map(function(e){var t={};return o.forEach(function(e){t[e]=""}),f(f({},t),e)}))),a=n,t(i?a:a[0]))}}function J(r){return function(e,t){r.lifeCycle.emit("modifyRequest",e);var n=r.config.modifyRequest;if("function"==typeof n)try{var o=n(e);"object"==typeof o&&"url"in o&&(e=o)}catch(e){console.error(e)}t(e)}}function K(o){return function(e,t){null!=(n=o.lifeCycle)&&n.emit("afterRequest",e);var n=(o.config||{}).afterRequest;"function"==typeof n&&!1===n(e)||t(e)}}function y(n){if(n&&n.reduce&&n.length)return 1===n.length?function(e,t){n[0](e,t||ge)}:n.reduce(function(n,o){return function(e,t){return void 0===t&&(t=ge),n(e,function(e){return null==o?void 0:o(e,t)})}});throw new TypeError("createPipeline need at least one function param")}function s(t,n){Object.getOwnPropertyNames(t).forEach(function(e){"function"==typeof t[e]&&"constructor"!==e&&(n?n[e]="sendPipeline"===e?function(){return function(){}}:function(){}:t[e]=function(){})})}function z(e){try{var t,n,o,r="";return r=e.pageUrl||(n=(t=getCurrentPages())[t.length-1]||{},i=n.options,o=Object.keys(i).length?"?"+Object.keys(i).map(function(e){return e+"="+i[e]}).join("&"):"",n.route?n.route+o:""),(r="function"==typeof e.urlHandler?e.urlHandler():r).slice(0,2048)}catch(e){return""}var i}function $(e,t){if("string"==typeof e&&"string"==typeof t){if(e===t)return 1;for(var n=e.split("."),o=t.split("."),r=Math.max(n.length,o.length),i=0;i<r;i++){var a=~~n[i],s=~~o[i];if(a<s)return;if(s<a)return 1}}}function Y(e,t){var n=this;this.taskQueue=[],this.count=1,this.maxCount=2,this.addTask=function(e){n.taskQueue.push(e)},this.fireTask=function(){var e=n.taskQueue.length;n.count>n.maxCount||0===e||(n.count=n.count+1,(e=n.taskQueue.shift())&&n.sendRequest(e.options,null==e?void 0:e.success,null==e?void 0:e.fail))},this.complete=function(){1<n.count&&(n.count=n.count-1),n.fireTask()},t&&(this.maxCount=t),this.sendRequest=e}function r(e){return me=me||i.getSystemInfoSync().SDKVersion,$(me,"1.1.1")&&i.canIUse?i.canIUse(e):!!i[e]}function Q(e){for(var t,n={unknown:/unknown|none/i,wifi:/wifi/i,net2g:/2g/i,net3g:/3g/i,net4g:/4g/i,net5g:/5g/i,net6g:/6g/i},o=c.unknown,r=0;r<Object.keys(n).length;r++){var i=Object.keys(n)[r];if(null!=(t=n[i])&&t.test(e)){o=c[i];break}}return o}function X(e){var t=e.apiName,n=k[t];n?n.hackCloudReq.addCallback(e):(n=P.cloud[t],k[t]={hackCloudReq:new Ee(e),originApi:n}),k[t]}function Z(e){var t=e.apiName,n=T[t];n?n.hackReq.addCallback(e):(n=wx[t],T[t]={hackReq:new Re(e),originApi:n}),T[t]}var v,l,c,b,u,ee,te,ne,oe,re=["ret","retcode","code","errcode"],ie=function(){var n=new WeakSet;return function(e,t){if(t instanceof Error)return"Error.message: "+t.message+" \n Error.stack: "+t.stack;if("object"==typeof t&&null!==t){if(n.has(t))return"[Circular "+(e||"root")+"]";n.add(t)}return t}},E=function(e){if("string"==typeof e)return e;try{return e instanceof Error?(JSON.stringify(e,ie(),4)||"undefined").replace(/"/gim,""):JSON.stringify(e,ie(),4)||"undefined"}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}},ae=function(n,o){void 0===o&&(o=3);var r,i,a,s="";return Array.isArray(n)?(s+="[",r=n.length,n.forEach(function(e,t){s=(s+="object"==typeof e&&1<o?ae(e,o-1):le(e))+(t===r-1?"":",")}),s+="]"):n instanceof Object?(s="{",i=Object.keys(n),a=i.length,i.forEach(function(e,t){"object"==typeof n[e]&&1<o?s+='"'+e+'":'+ae(n[e],o-1):s+=se(e,n[e]),s+=t===a-1||t<a-1&&void 0===n[i[t+1]]?"":","}),s+="}"):s+=n,s},se=function(e,t){var n=typeof t,o="";return"string"==n||"object"==n?o+='"'+e+'":"'+t+'"':"function"==typeof t?o+='"'+e+'":"function '+t.name+'"':"symbol"==typeof t?o+='"'+e+'":"symbol"':"number"!=typeof t&&"boolean"!=n||(o+='"'+e+'": '+t),o},le=function(e){var t=typeof e;return""+("undefined"==t||"symbol"==t||"function"==t?"null":"string"==t||"object"==t?'"'+e+'"':e)},ce=/data:(image|text|application|font)\/.*;base64/,ue=((n=v=v||{}).INFO_ALL="-1",n.API_RESPONSE="1",n.INFO="2",n.ERROR="4",n.PROMISE_ERROR="8",n.AJAX_ERROR="16",n.SCRIPT_ERROR="32",n.IMAGE_ERROR="64",n.CSS_ERROR="128",n.CONSOLE_ERROR="256",n.MEDIA_ERROR="512",n.RET_ERROR="1024",n.REPORT="2048",n.PV="4096",n.EVENT="8192",n.PAGE_NOT_FOUND_ERROR="16384",n.WEBSOCKET_ERROR="32768",n.BRIDGE_ERROR="65536",n.LAZY_LOAD_ERROR="131072",(n=l=l||{})[n.android=1]="android",n[n.ios=2]="ios",n[n.windows=3]="windows",n[n.macos=4]="macos",n[n.linux=5]="linux",n[n.devtools=6]="devtools",n[n.other=100]="other",(n=c=c||{})[n.unknown=100]="unknown",n[n.wifi=1]="wifi",n[n.net2g=2]="net2g",n[n.net3g=3]="net3g",n[n.net4g=4]="net4g",n[n.net5g=5]="net5g",n[n.net6g=6]="net6g",(n=b=b||{}).LOG="log",n.SPEED="speed",n.PERFORMANCE="performance",n.OFFLINE="offline",n.WHITE_LIST="whiteList",n.VITALS="vitals",n.PV="pv",n.CUSTOM_PV="customPV",n.EVENT="event",n.CUSTOM="custom",n.SDK_ERROR="sdkError",n.SET_DATA="setData",n.LOAD_PACKAGE="loadPackage",(n=u=u||{}).production="production",n.development="development",n.gray="gray",n.pre="pre",n.daily="daily",n.local="local",n.test="test",n.others="others",function(e){return e.filter(function(n,o){return"static"!==n.type||!e.find(function(e,t){return n.url===e.url&&200===n.status&&o<t})})}),fe=function(e){e.level===v.INFO_ALL&&(e.level=v.INFO)},O={},R={},pe=function(e){return O[e]||(O[e]=setTimeout(function(){R[e]={},O[e]=null},6e4)),O[e]},de=function(e){return(Array.isArray(e)?e:[e]).map(function(n){return Object.getOwnPropertyNames(n).reduce(function(e,t){return"ctx"!==t&&(e[t]=n[t]),e},{level:v.INFO,msg:""})})},he=function(o){return function(e){return o.sendPipeline([function(e,n){return n({url:o.config.url||"",data:B(de(e)),method:"post",contentType:"application/json",type:b.LOG,log:e,requestConfig:{timeout:5e3},success:function(){var t=o.config.onReport;"function"==typeof t&&e.forEach(function(e){t(e)}),"function"==typeof n&&n([])}})}],b.LOG)(e)}},ge=function(){},n=(Object.defineProperty(q.prototype,"__version__",{get:function(){return console.warn("__version__ has discard, please use version"),"1.37.9"},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"LogType",{get:function(){return console.warn("LogType has discard, please use logType"),v},enumerable:!1,configurable:!0}),q.prototype.init=function(e){this.setConfig(e);for(var t=0;t<q.installedPlugins.length;t++)try{q.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},q.prototype.setConfig=function(e){Object.assign(this.config,e);var e=this.config,t=e.id,n=e.uin,o=e.version,r=e.ext1,i=e.ext2,a=e.ext3,s=e.aid,l=e.env,c=void 0===l?"production":l,l=e.pageUrl,e=this.bean.id!==t||this.bean.uin!==n||this.bean.aid!==s;return this.bean.id=t||"",this.bean.uin=n||"",this.bean.version=o||"1.37.9",this.bean.aid=s||"",this.bean.env=function(){switch(c){case u.production:case u.development:case u.gray:case u.pre:case u.daily:case u.local:case u.test:case u.others:return 1;default:return}}()?c:u.others,l&&this.extendBean("from",encodeURIComponent(l.slice(0,2048))),r&&this.extendBean("ext1",encodeURIComponent(r)),i&&this.extendBean("ext2",encodeURIComponent(i)),a&&this.extendBean("ext3",encodeURIComponent(a)),e&&this.lifeCycle.emit("onConfigChange",this.config),this.config},q.use=function(e){-1===q.installedPlugins.indexOf(e)&&e.aegisPlugin&&q.installedPlugins.push(e)},q.unuse=function(e){e=q.installedPlugins.indexOf(e);-1!==e&&q.installedPlugins.splice(e,1)},q.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:v.INFO,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:v.INFO}),this.normalLogPipeline(n)},q.prototype.infoAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:v.INFO_ALL,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:v.INFO_ALL}),this.normalLogPipeline(n)},q.prototype.report=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:v.REPORT,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0])),this.normalLogPipeline(n)},q.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:v.ERROR,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:v.ERROR}),this.normalLogPipeline(n)},q.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},q.prototype.reportPv=function(n){var o,r=this;n&&(console.warn("reportPv is deprecated, please use reportEvent"),o=""+Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+r.bean[e]}).join("&"),this.sendPipeline([function(e,t){t({url:r.config.url+"/"+n+"?"+o,addBean:!1,type:b.CUSTOM_PV})}],b.CUSTOM_PV)(null))},q.prototype.reportEvent=function(e){e&&((e="string"==typeof e?{name:e,ext1:this.config.ext1||"",ext2:this.config.ext2||"",ext3:this.config.ext3||""}:e).name?("string"!=typeof e.name&&(console.warn("reportEvent params name must be string"),e.name=String(e.name)),this.eventPipeline(e)):console.warn("reportEvent params error"))},q.prototype.reportTime=function(e,t){if("object"==typeof e)return this.reportT(e);"string"==typeof e?"number"==typeof t?t<0||6e4<t?console.warn("reportTime: duration must between 0 and 60000"):this.submitCustomTime(e,t):console.warn("reportTime: second param must be number"):console.warn("reportTime: first param must be a string")},q.prototype.reportT=function(e){var t=e.name,n=e.duration,o=e.ext1,o=void 0===o?"":o,r=e.ext2,r=void 0===r?"":r,i=e.ext3,i=void 0===i?"":i,e=e.from;if("string"==typeof t&&"number"==typeof n&&"string"==typeof o&&"string"==typeof r&&"string"==typeof i){if(!(n<0||6e4<n))return this.submitCustomTime(t,n,o,r,i,void 0===e?"":e);console.warn("reportTime: duration must between 0 and 60000")}else console.warn("reportTime: params error")},q.prototype.time=function(e){"string"==typeof e?this.timeMap[e]?console.warn("Timer "+e+" already exists"):this.timeMap[e]=Date.now():console.warn("time: first param must be a string")},q.prototype.timeEnd=function(e){"string"==typeof e?this.timeMap[e]?(this.submitCustomTime(e,Date.now()-this.timeMap[e]),delete this.timeMap[e]):console.warn("Timer "+e+" does not exist"):console.warn("timeEnd: first param must be a string")},q.prototype.submitCustomTime=function(e,t,n,o,r,i){this.customTimePipeline({name:e,duration:t,ext1:n||this.config.ext1,ext2:o||this.config.ext2,ext3:r||this.config.ext3,from:i||void 0})},q.prototype.extendBean=function(e,t){this.bean[e]=t},q.prototype.sendPipeline=function(e,t){var n,i=this;return y(a([function(e,t){if("number"!=typeof n.config.random&&(console.warn("random must in [0, 1], default is 1."),n.config.random=1),!n.isHidden||!n.isGetSample)if(n.isGetSample)n.isHidden||t(e);else{if(n.isGetSample=!0,Math.random()<n.config.random)return n.isHidden=!1,t(e);n.isHidden=!0}},G(n=this,t)],e,[J(this),function(o,r){i.request(o,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=!1;-1<(""+e[i.failRequestCount=0]).indexOf("403 forbidden")&&(n=!0,i.destroy()),r({isErr:n,result:e,logType:null==o?void 0:o.type,logs:null==o?void 0:o.log}),null!=(n=null==o?void 0:o.success)&&n.call.apply(n,a([o],e))},function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];60<=++i.failRequestCount&&i.destroy(),-1<(""+t[0]).indexOf("403 forbidden")&&i.destroy(),r({isErr:!0,result:t,logType:null==o?void 0:o.type,logs:null==o?void 0:o.log}),null!=(e=null==o?void 0:o.fail)&&e.call.apply(e,a([o],t))})},K(this)]))},q.prototype.send=function(e,r,i){var t=this;return y([J(this),function(n,o){t.request(n,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o({isErr:!1,result:e,logType:n.type,logs:n.log}),null!=r&&r.apply(void 0,e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o({isErr:!0,result:e,logType:n.type,logs:n.log}),null!=i&&i.apply(void 0,e)})},K(this)])(e)},q.prototype.ready=function(e,t,n){throw new Error('You need to override "ready" method')},q.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},q.prototype.sendSDKError=function(e){var n=this;this.sendPipeline([function(e,t){t({url:n.config.url+"?id=1085&msg[0]="+encodeURIComponent(E(e))+"&level[0]=2&from="+n.config.id+"&count=1&version="+n.config.id+"(1.37.9)",addBean:!1,method:"get",type:b.SDK_ERROR,log:e})}],b.SDK_ERROR)(e)},q.prototype.destroy=function(e){void 0===e&&(e=!1);var t,n,o=q.instances.indexOf(this);-1!==o&&q.instances.splice(o,1);for(var r=q.installedPlugins.length-1;0<=r;r--)try{q.installedPlugins[r].unpatch(this)}catch(e){this.sendSDKError(e)}if(this.lifeCycle.emit("destroy"),this.lifeCycle.clear(),e)t=this,n=Object.getOwnPropertyDescriptors(t),Object.keys(n).forEach(function(e){n[e].writable&&(t[e]=null)}),Object.setPrototypeOf(this,null);else{for(var i=this;i.constructor!==Object&&s(i,this),i=Object.getPrototypeOf(i););0===q.instances.length&&(o=Object.getPrototypeOf(this).constructor,s(o),s(q))}},q.version="1.37.9",q.instances=[],q.logType=v,q.environment=u,q.installedPlugins=[],q),o=(L.prototype.patch=function(e){this.canUse(e)&&this.exist(e)&&(this.instances.push(e),this.triggerInit(e),this.triggerOnNewAegis(e))},L.prototype.unpatch=function(e){var t=this.instances.indexOf(e);-1!==t&&(this.instances.splice(t,1),0===this.instances.length)&&this.uninstall(e)},L.prototype.countInstance=function(){return this.instances.length},L.prototype.uninstall=function(e){var t;null!=(t=null==(t=this.option)?void 0:t.destroy)&&t.apply(this,[e])},L.prototype.walk=function(n){var o=this;this.instances.forEach(function(e){var t=o.canUse(e);t&&n(e,t)})},L.prototype.canUse=function(e){e=this.getConfig(e);return!(!e||"object"!=typeof e)||!!e},L.prototype.getConfig=function(e){return null==(e=e.config)?void 0:e[this.name]},L.prototype.exist=function(e){return-1===this.instances.indexOf(e)},L.prototype.triggerInit=function(e){var t;this.inited||(this.inited=!0,null==(t=null==(t=this.option)?void 0:t.init))||t.call(this.option,this.getConfig(e))},L.prototype.triggerOnNewAegis=function(e){var t;null!=(t=null==(t=this.option)?void 0:t.onNewAegis)&&t.call(this.option,e,this.getConfig(e))},L),i=wx||qq,me="",ye=new o({name:"device",onNewAegis:function(t){return e=this,l=function(){return I(this,function(e){return this.setSystemInfo(t),this.setNetworkType(t),this.setNetworkChange(t),[2]})},new(s=(s=a=void 0)||Promise)(function(n,t){function o(e){try{i(l.next(e))}catch(e){t(e)}}function r(e){try{i(l.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?n(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(o,r)}i((l=l.apply(e,a||[])).next())});var e,a,s,l},setSystemInfo:function(a){var s=this;try{r("getSystemInfo")&&i.getSystemInfo({success:function(e){var t=e.platform,n=e.model,o=e.windowHeight,r=e.windowWidth,i=e.screenWidth,i=void 0===i?0:i,e=e.screenHeight,e=void 0===e?0:e;a.extendBean("platform",s.getPlatFormType(t)),a.extendBean("model",n),a.extendBean("vp",Math.round(r)+" * "+Math.round(o)),a.extendBean("sr",Math.round(i)+" * "+Math.round(e))}})}catch(a){}},getPlatFormType:function(e){for(var t,n={android:/android/i,ios:/ios/i,windows:/windows/i,macos:/mac/i,devtools:/devtools/i},o=l.other,r=0;r<Object.keys(n).length;r++){var i=Object.keys(n)[r];if(null!=(t=n[i])&&t.test(e)){o=l[i];break}}return o},setNetworkChange:function(t){r("onNetworkStatusChange")&&i.onNetworkStatusChange(function(e){e=Q(e.networkType);t.extendBean("netType",e)})},setNetworkType:function(t){r("getNetworkType")&&i.getNetworkType({success:function(e){e=Q(e.networkType);t.extendBean("netType",e)}})}}),ve=i.request,n=(e(N,ne=n),Object.defineProperty(N.prototype,"getBean",{get:function(){var t=this;return this.bean?Object.getOwnPropertyNames(this.bean).map(function(e){return e+"="+t.bean[e]}).join("&")+"&from="+encodeURIComponent(z(this.config)):"from="+encodeURIComponent(z(this.config))},enumerable:!1,configurable:!0}),N.prototype.initRequestSchedule=function(){this.requestSchedule=new Y(this.sendRequest)},N.prototype.uploadLogs=function(e,t){this.lifeCycle.emit("uploadLogs",e=void 0===e?{}:e,t=void 0===t?{}:t)},N.prototype.reportPv=function(e){var t,n=this;e&&(t=Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+n.bean[e]}).join("&")+"&from="+encodeURIComponent(z(this.config)),this.send({url:this.config.url+"/"+e+"?"+t,addBean:!1,type:b.CUSTOM_PV,log:b.CUSTOM_PV},function(){},function(){}))},N.sessionID="session-"+Date.now(),N.asyncPluginIndex=0,N),be=new o({name:"aid",onNewAegis:function(t){this.initAid(function(e){t.bean.aid=e,t.config.aid=e})},initAid:function(t){i.getStorage({key:"AEGIS_ID",success:function(e){t(e.data)},fail:function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});i.setStorage({key:"AEGIS_ID",data:e,success:function(){t(e)}})}})}}),w=(C.prototype.addCallback=function(e){e&&this.callbacks.push(e)},C.prototype.prefixHandler=function(e){return f(f({},e),{aegisRequestStartTime:+new Date})},C.prototype.successHandler=function(n,o){var e;this.callbacks.forEach(function(e){var t;try{null!=(t=e.success)&&t.call(e,n,o)}catch(e){}}),null!=(e=o.success)&&e.call(o,n,o)},C.prototype.failHandler=function(n,o){var e;this.callbacks.forEach(function(e){var t;try{null!=(t=e.fail)&&t.call(e,n,o)}catch(e){}}),null!=(e=o.fail)&&e.call(o,n,o)},C.prototype.completeHandler=function(n,o){var e;this.callbacks.forEach(function(e){var t;try{null!=(t=e.complete)&&t.call(e,n,o)}catch(e){}}),null!=(e=o.complete)&&e.call(o,n,o)},C.prototype.override=function(){try{this.defineApiProperty()}catch(e){console.warn("cannot override `"+this.apiName+"`, error is: "+e)}finally{this.isOverride=!0}},C),P=wx||qq,k={},Ee=(e(x,te=w),x.prototype.defineApiProperty=function(){var e=this;P.cloud&&P.cloud[this.apiName]&&Object.defineProperty(P.cloud,this.apiName,{get:function(){return e.hackHandler.bind(e)}})},x.prototype.hackHandler=function(e){var o=this,r=this.prefixHandler(e);return new Promise(function(t,n){var e=null==(e=k[o.apiName])?void 0:e.originApi;null!=e&&e(f(f({},r),{success:function(e){o.successHandler(e,r),t(e)},fail:function(e){o.failHandler(e,r),n(e)},complete:function(e){o.completeHandler(e,r)}}))})},x),Oe=wx||qq,T={},Re=(e(S,ee=w),S.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(Oe,this.apiName,{get:function(){return e.hackHandler.bind(e)}})},S.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e),e=null==(e=T[this.apiName])?void 0:e.originApi;return null==e?void 0:e(f(f({},n),{success:function(e){t.successHandler(e,n)},fail:function(e){t.failHandler(e,n)},complete:function(e){t.completeHandler(e,n)}}))},S),we=wx||qq,Pe=we.request;function S(){return null!==ee&&ee.apply(this,arguments)||this}function x(){return null!==te&&te.apply(this,arguments)||this}function C(e){this.callbacks=[],this.isOverride=!1;var t=e.apiName;this.apiName=t,this.isOverride||this.override(),this.callbacks.push(e)}function N(e){var o,a,u=ne.call(this,e)||this;u.originRequest=ve,u.speedLogPipeline=y([(a=u.config,function(e,t){var n,o,r,i="number"==typeof a.repeat?a.repeat:60;!a.speedSample||i<=0?t(e):(n=(null==a?void 0:a.id)||"0",o=R[n]||{},Array.isArray(e)?(r=e.filter(function(e){var t=!o[e.url]||o[e.url]<i;return t?(o[e.url]=1+~~o[e.url],R[n]=o):O[n]||pe(n),t})).length&&t(r):!o[e.url]||o[e.url]<i?(o[e.url]=1+~~o[e.url],R[n]=o,t(e)):O[n]||pe(n))}),m(u),function(t,n){r("getNetworkType")?i.getNetworkType({success:function(e){e=Q(e.networkType);o.extendBean("netType",e),n(t)}}):n(t)},function(e,t){u.lifeCycle.emit("beforeReportSpeed",e);var n=u.config.beforeReportSpeed;if((e="function"==typeof n?e.filter(function(e){return!1!==n(e)}):e).length)return t(e)},G(o=u,b.SPEED),function(e,t){t(e.map(function(e){return void 0!==e.payload&&delete e.payload,e}))},function(e){var t,n,o,r;u.send({url:""+u.config.speedUrl,method:"post",data:(e=e,t=u.bean,o={fetch:[],static:[],bridge:[]},r={},Array.isArray(e)?e.forEach(function(e){var t;null!=(t=o[e.type])&&t.push(e)}):null!=(n=o[e.type])&&n.push(e),r.payload=JSON.stringify(f({duration:o},t)),r)})}]),u.request=function(e,t,n){e.url&&u.bean.id&&(!/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(String(u.bean.aid))||r("getNetworkType")&&void 0===u.bean.netType?u.requestSchedule.addTask({options:e,success:t,fail:n}):(u.requestSchedule.addTask({options:e,success:t,fail:n}),u.requestSchedule.fireTask()))},u.sendRequest=function(e,t,n){var o,r,i,a=e.url,s=(u.config.whiteListUrl===a&&(o=t,t=function(e){null!=o&&o(JSON.stringify(e.data))}),e.method),s=void 0===s?"get":s,l=(!1!==e.addBean&&(a=a+(-1===(null==a?void 0:a.indexOf("?"))?"?":"&")+u.getBean),e),c=u.config.onBeforeRequest;return(l=c?c(e,u):l)&&l.url?(c=u.config.enableHttp2||!1,"get"===s?(s=a,r=l.data,a="string"!=typeof s?"":"object"==typeof r&&r?(i=Object.getOwnPropertyNames(r).map(function(e){var t=r[e];return e+"="+("string"==typeof t?encodeURIComponent(t):encodeURIComponent(JSON.stringify(t)))}).join("&").replace(/eval/gi,"evaI"),s+(-1===s.indexOf("?")?"?":"&")+i):s,u.originRequest(f({url:a,enableHttp2:c,success:t,fail:n,complete:u.requestSchedule.complete},e.requestConfig))):("string"==typeof l.data&&(l.data=l.data.replace(/eval/gi,"evaI")),u.originRequest(f({url:a,enableHttp2:c,header:l.contentType?{"content-type":l.contentType}:void 0,method:"POST",data:l.data,success:t,fail:n,complete:u.requestSchedule.complete},e.requestConfig))),!0):(i="",l&&l.url||(i="Sending request blocked. Please handle the parameters reasonably, options.url is necessary",console.log(i)),null!=n&&n(i),u.requestSchedule.complete(),!1)};try{u.initRequestSchedule(),u.init(e),u.extendBean("sessionId",N.sessionID),u.extendBean("referer",(r("getLaunchOptionsSync")?i.getLaunchOptionsSync():{scene:""}).scene||"")}catch(e){console.warn(e),console.log("%cThe above error occurred in the process of initializing Aegis, which will affect your normal use of Aegis.\nIt is recommended that you contact us for feedback and thank you for your support.","color: red"),u.sendSDKError(e)}return u}function L(e){this.aegisPlugin=!0,this.name="",this.instances=[],this.inited=!1,e.$walk=this.walk.bind(this),e.$getConfig=this.getConfig.bind(this),this.option=e,this.name=e.name}function q(e){var n,t,o,r,a,i,s,l,c,u,f,p,d,h,g=this;this.isGetSample=!1,this.isHidden=!1,this.config={version:0,delay:1e3,onError:!0,repeat:60,random:1,aid:!0,device:!0,pagePerformance:!0,webVitals:!0,speedSample:!0,onClose:!0,reportLoadPackageSpeed:!0,hostUrl:"https://aegis.qq.com",env:"production",url:"",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",webVitalsUrl:"",eventUrl:"",setDataReportUrl:"",reportImmediately:!0},this.isWhiteList=!1,this.lifeCycle=new F,this.bean={},this.normalLogPipeline=y([m(this,5),V,function(e,t){var o=n.config;t(e=e.map(function(e){var t,n=o.maxLength||102400;try{if(!e.msg||e.msg.length<=n)return e;e.msg=null==(t=e.msg)?void 0:t.substring(0,n)}catch(t){e.msg=E(e.msg).substring(0,o.maxLength)}return e}))},(h=(n=this).config,function(e,t){var n="number"==typeof h.repeat?h.repeat:60;if(n<=0)return t(e);var o=(null==h?void 0:h.id)+"_error",r=R[o]||{};t(e.filter(function(e){if(e.level===v.ERROR||e.level===v.PROMISE_ERROR||e.level===v.AJAX_ERROR||e.level===v.SCRIPT_ERROR||e.level===v.IMAGE_ERROR||e.level===v.CSS_ERROR||e.level===v.MEDIA_ERROR||e.level===v.RET_ERROR||e.level===v.BRIDGE_ERROR||e.level===v.PAGE_NOT_FOUND_ERROR||e.level===v.WEBSOCKET_ERROR||e.level===v.LAZY_LOAD_ERROR){e=e.msg.slice(0,200);if(r[e]>n)return O[o]||pe(o),!1;r[e]=1+~~r[e],R[o]=r}return!0}))}),(p=this.lifeCycle.emit,d=this.config,function(e,t){var n,o=d.logCreated;return"function"==typeof o?(n=e.filter(function(e){return!1!==o(e)}),p("beforeWrite",n),t(n)):(p("beforeWrite",e),t(e))}),(f=this,setTimeout(function(){var e=f.config,t=e.pvUrl,n=void 0===t?"":t,t=e.spa,e=-1<["web-sdk","mp-sdk"].indexOf("mp-sdk");n&&(e&&!t||!e)&&f.sendPipeline([function(e,t){t({url:n,type:b.PV})}],b.PV)(null)},100),function(e,t){t(e)}),(c=l=s=!1,u=[],(a=this).lifeCycle.on("onConfigChange",function(){i&&clearTimeout(i),i=setTimeout(function(){var e,n;!c&&a.config&&(c=!0,e=a.config.whiteListUrl,(n=void 0===e?"":e)&&a.sendPipeline([function(e,t){t({url:n,type:b.WHITE_LIST,success:function(e){l=!0;try{var t=e.data||JSON.parse(e),n=t.retcode,o=t.result,r=void 0===o?{}:o,i=(0===n&&(s=r.is_in_white_list,a.isWhiteList=s,0<=r.rate)&&r.rate<=1&&(a.config.random=r.rate,a.isGetSample=!1),a.isWhiteList&&u.length?he(a)(u.splice(0),function(){}):!a.isWhiteList&&u.length&&(u.length=0),a.config.onWhitelist);"function"==typeof i&&i(s)}catch(e){}},fail:function(){l=!0}})}],b.WHITE_LIST)(null),c=!1)},a.config.uin?50:500)}),a.lifeCycle.on("destroy",function(){u.length=0}),function(e,t){var n;s||null!=(n=null==(n=a.config)?void 0:n.api)&&n.reportRequest?t(e.concat(u.splice(0)).map(function(e){return fe(e),e})):(n=e.filter(function(e){return e.level!==v.INFO&&e.level!==v.API_RESPONSE?(fe(e),!0):(l||(u.push(e),200<=u.length&&(u.length=200)),!1)})).length&&t(n)}),function(e,t){try{var n=JSON.parse(JSON.stringify(e)),o=(g.lifeCycle.emit("beforeReport",n),g.config.beforeReport);(e="function"==typeof o?e.filter(function(e){return!1!==o(e)}):e).length&&t(e)}catch(e){}},he(this)]),this.eventPipeline=y([m(this,10),(r=this,function(e){r.sendPipeline([function(e,t){var n=e.map(function(e){return{name:e.name,ext1:e.ext1||r.config.ext1||"",ext2:e.ext2||r.config.ext2||"",ext3:e.ext3||r.config.ext3||""}});t({url:r.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(n)),type:b.EVENT,log:e})}],b.EVENT)(e)})]),this.timeMap={},this.failRequestCount=0,this.customTimePipeline=y([m(this,10),(o=this,function(e){return o.sendPipeline([function(e,t){t({url:o.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:b.CUSTOM,log:e})}],b.CUSTOM)(e)})]),this.config=(t=this.config,void 0===(e=e.hostUrl)&&(e="https://aegis.qq.com"),t.url=t.url||e+"/collect",t.offlineUrl=t.offlineUrl||e+"/offline",t.whiteListUrl=t.whiteListUrl||e+"/collect/whitelist",t.pvUrl=t.pvUrl||e+"/collect/pv",t.eventUrl=t.eventUrl||e+"/collect/events",t.speedUrl=t.speedUrl||e+"/speed",t.customTimeUrl=t.customTimeUrl||e+"/speed/custom",t.performanceUrl=t.performanceUrl||e+"/speed/performance",t.webVitalsUrl=t.webVitalsUrl||e+"/speed/webvitals",t.setDataReportUrl=t.SetDataReportUrl||e+"/speed/miniProgramData",t),q.instances.push(this)}function ke(){return null!==oe&&oe.apply(this,arguments)||this}e(ke,oe=w),ke.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(we,"request",{get:function(){return e.hackHandler.bind(e)}})};function A(o,e,r){return null!=e&&e.length&&"object"==typeof o?e.reduce(function(e,t){var n=o[t];return n?e+(""===e?"\n":"\n\n")+r+" header "+t+": "+n:e},""):""}var _,Te,Se=new o({name:"reportApiSpeed",override:!(ke.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e);return Pe(f(f({},n),{success:function(e){t.successHandler(e,n)},fail:function(e){t.failHandler(e,n)},complete:function(e){t.completeHandler(e,n)}}))}),onNewAegis:function(e){this.override||(this.override=!0,this.hackRequest(e.config),this.overrideCallFunction(e.config),this.overrideCallContainer(e.config))},hackRequest:function(c){var u=this;Z({apiName:"request",success:function(e,t){var n,o,r,i,a,s,l;g(t.url,c.hostUrl)||(n={method:t.method||"get",url:p(t.url),duration:Date.now()-t.aegisRequestStartTime,status:e.statusCode||0,nextHopProtocol:"",isHttps:W(t.url),type:"fetch"},i=null==(i=c.api)?void 0:i.apiDetail,o=(r=d(e.data,c.api,{url:t.url,ctx:e,payload:t.data})||{}).code,r=r.isErr,l=i?h(t.data,null==(l=c.api)?void 0:l.reqParamHandler,{url:t.url}):"",i=i?h(e.data,null==(i=c.api)?void 0:i.resBodyHandler,{url:t.url}):"",a=(null==(a=c.api)?void 0:a.reqHeaders)||[],a=A(null==t?void 0:t.header,a,"req"),s=(null==(s=c.api)?void 0:s.resHeaders)||[],s=A(null==e?void 0:e.header,s,"res"),l="req url: "+n.url+" \n \nres status: "+(e.statusCode||0)+" \n \nres duration: "+n.duration+"ms \n \nreq method: "+n.method+" \n \nreq param: "+l+" \n \nres retcode: "+o+" \n \nres data: "+i+"\n "+a+"\n "+s,u.publishNormalLog({msg:l,level:v.API_RESPONSE,ctx:e}),n.ret=o,n.isErr=+r,n.payload=t.data,u.publishSpeedLog(n),r&&u.publishNormalLog({msg:l,level:v.RET_ERROR,ctx:e}))},fail:function(e,t){g(t.url,c.hostUrl)||(t={method:t.method||"get",url:p(t.url),duration:Date.now()-t.aegisRequestStartTime,status:0,nextHopProtocol:"",isHttps:W(t.url),type:"fetch"},u.publishSpeedLog(t))}})},overrideCallFunction:function(n){var o=this;X({apiName:"callFunction",success:function(e,t){o.cloudSuccessCallback(n,t,e,"callFunction")},fail:function(e,t){t={method:"call",url:"wx.cloud.callFunction."+t.name,duration:Date.now()-t.aegisRequestStartTime,status:0,nextHopProtocol:"",type:"fetch",errMsg:e.errMsg,isHttps:!0};o.publishSpeedLog(t)}})},overrideCallContainer:function(n){var o=this;X({apiName:"callContainer",success:function(e,t){o.cloudSuccessCallback(n,t,e,"callContainer")},fail:function(e,t){t={method:"call",url:"wx.cloud.callContainer."+t.path,duration:Date.now()-t.aegisRequestStartTime,status:0,nextHopProtocol:"",type:"fetch",errMsg:e.errMsg,isHttps:!0};o.publishSpeedLog(t)}})},cloudSuccessCallback:function(e,n,t,o){var r="callFunction"===o?n.name:n.path,i="callFunction"===o?t.result:t.data,r={method:"call",url:"wx.cloud."+o+"."+r,duration:Date.now()-n.aegisRequestStartTime,status:200,nextHopProtocol:"",type:"fetch",isHttps:!0},a=["apiName","aegisRequestStartTime","config","success","fail","complete"],s=Object.keys(n).reduce(function(e,t){return a.includes(t)||(e[t]=n[t]),e},{}),o="callFunction"===o?(null==(o=t.data)?void 0:o.code)||0:t.statusCode,l=d(i,e.api,{url:r.url,ctx:t,payload:s})||{},c=l.code,l=l.isErr,l=void 0!==l&&l,c=(r.ret=c,r.isErr=+l,r.payload=s,null==(c=e.api)?void 0:c.apiDetail),s=c?h(s,null==(s=e.api)?void 0:s.reqParamHandler,{url:r.url}):"",i=c?h(i,null==(c=e.api)?void 0:c.resBodyHandler,{url:r.url}):"",c=(null==(c=e.api)?void 0:c.reqHeaders)||[],c=A(null==n?void 0:n.header,c,"req"),e=(null==(e=e.api)?void 0:e.resHeaders)||[],e=A(null==t?void 0:t.header,e,"res"),o="req url: "+r.url+"\n \nres status: "+o+"\n \nres duration: "+r.duration+"ms \n \nreq type: "+r.type+"\n \nreq params: "+s+"\n \nres retcode: "+r.ret+"\n \nres data: "+i+"\n "+c+"\n "+e;this.publishNormalLog({msg:o,level:v.API_RESPONSE,ctx:t}),this.publishSpeedLog(r),l&&this.publishNormalLog({msg:o,level:v.RET_ERROR,ctx:t})},publishSpeedLog:function(t){this.$walk(function(e){e.speedLogPipeline(t)})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})}}),xe=wx||qq,Ce=xe.connectSocket,Ne=(Ue.prototype.addConfig=function(e){var t=e.send,e=e.onError;t&&this.sends.push(t),e&&this.onErrors.push(e)},Ue.prototype.toHack=function(t){var r=this,n=(this.onErrors.forEach(function(e){t.onError(e)}),t.send);return Object.defineProperty(t,"send",{get:function(){return function(o){return new Promise(function(e){n.call(t,f(f({},o),{fail:function(n){r.sends.forEach(function(e){var t;null!=(t=e.fail)&&t.call(e,n,o)}),e(n)}}))})}}}),t},Ue),Le=(e(U,Te=w),U.prototype.addTaskConf=function(e){this.taskHack.addConfig(e)},U.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(xe,"connectSocket",{get:function(){return e.hackHandler.bind(e)}})},U.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e),e=Ce(f(f({},n),{success:function(e){t.successHandler(e,n)},fail:function(e){t.failHandler(e,n)},complete:function(e){t.completeHandler(e,n)}}));return this.taskHack.toHack(e),e},U),w=new o({name:"onError",onNewAegis:function(e){var t=i.getSystemInfoSync().SDKVersion;this.listenError(),this.hackNetWork(e),this.hackCloud(e),e.config.websocketHack&&$(t,"1.7.0")&&this.hackWsConnect()},listenError:function(){var t=this;"function"==typeof i.onError&&i.onError(function(e){e&&t.publishErrorLog({msg:e,level:v.ERROR})}),r("onUnhandledRejection")&&i.onUnhandledRejection(function(e){e=e.reason;!e||-1<JSON.stringify(e).indexOf("request:fail")||t.publishErrorLog({msg:e,level:v.PROMISE_ERROR})}),r("onPageNotFound")&&i.onPageNotFound(function(e){e&&t.publishErrorLog({msg:e,level:v.PAGE_NOT_FOUND_ERROR})}),r("onLazyLoadError")&&i.onLazyLoadError(function(e){e&&t.publishErrorLog({msg:e,level:v.LAZY_LOAD_ERROR})})},publishErrorLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},hackNetWork:function(e){for(var n=this,o=e.config,t=0,r=[{apiName:"request",complete:function(e,t){return n.requestCompleteError(e,t,o)}},{apiName:"uploadFile",complete:function(e,t){return n.uploadFileCompleteError(e,t,o)}},{apiName:"downloadFile",complete:function(e,t){return n.downloadFileCompleteError(e,t,o)}}];t<r.length;t++){var i=r[t],a=i.apiName,i=i.complete;Z({apiName:a,complete:i})}},requestCompleteError:function(e,t,n){var o=e.errMsg,r=e.statusCode;g(t.url,n.hostUrl)||(o=this.getErrorType({errMsg:o,statusCode:r}))&&this.publishNetWorkError({apiName:"request",opts:t,res:e,config:n,type:o})},downloadFileCompleteError:function(e,t,n){var o=e.errMsg,r=e.statusCode,i=e.filePath,a=e.tempFilePath,o=this.getErrorType({errMsg:o,statusCode:r});o&&this.publishNetWorkError({apiName:"downloadFile",opts:t,res:e,config:n,type:o},{extraInfo:"\nres filePath: "+i+"\nres tempFilePath: "+a})},uploadFileCompleteError:function(e,t,n){var o=e.errMsg,r=e.statusCode,o=this.getErrorType({errMsg:o,statusCode:r});o&&this.publishNetWorkError({apiName:"uploadFile",opts:t,res:e,config:n,type:o})},hackCloud:function(e){for(var n=this,o=e.config,t=0,r=[{apiName:"callFunction",complete:function(e,t){return n.callFunctionCompleteError(e,t,o)}},{apiName:"callContainer",complete:function(e,t){return n.callContainerCompleteError(e,t,o)}}];t<r.length;t++){var i=r[t],a=i.apiName,i=i.complete;X({apiName:a,complete:i})}},callFunctionCompleteError:function(e,t,n){var o=e.errMsg,o=this.getErrorType({errMsg:o});o&&this.publishNetWorkError({apiName:"cloud.callFunction",opts:t,res:e,config:n,type:o})},callContainerCompleteError:function(e,t,n){var o=e.errMsg,r=e.statusCode,o=this.getErrorType({errMsg:o,statusCode:r});o&&this.publishNetWorkError({apiName:"cloud.callContainer",opts:t,res:e,config:n,type:o})},publishNetWorkError:function(e,t){var t=t.extraInfo,t=void 0===t?"":t,n=e.apiName,o=e.opts,r=e.res,i=e.config,e=e.type,a=r.errMsg,s=r.statusCode,l=r.data,c=o.url,u=d(l,i.api,{url:c,ctx:r,payload:o.data}).code,f=null==(f=i.api)?void 0:f.apiDetail,p=f?h(o.data,null==(p=i.api)?void 0:p.reqParamHandler,{url:c}):"",l=f?h(l,null==(f=i.api)?void 0:f.resBodyHandler,{url:c}):"",c=(null==(f=i.api)?void 0:f.reqHeaders)||[],f=A(null==o?void 0:o.header,c,"req"),i=(null==(c=i.api)?void 0:c.resHeaders)||[],c=A(null==r?void 0:r.header,i,"res");this.publishErrorLog({msg:"AJAX_ERROR: "+n+" "+e+"\n \nreq url: "+o.url+"\n \nres status: "+(s||0)+"\n \nres duration: "+(Date.now()-o.aegisRequestStartTime)+"ms\n \nreq method: "+(o.method||"get")+"\n \nreq param: "+p+"\n \nres retcode: "+u+"\n \nres data: "+l+"\n \nerrMsg: "+a.slice(0,1e3)+"\n "+t+"\n "+f+"\n "+c,level:v.AJAX_ERROR})},getErrorType:function(e){var t=e.errMsg,e=e.statusCode,n="",o=t;return["timeout","time out","ERR_CONNECTION_TIMED_OUT","ERR_TIMED_OUT","超时"].some(function(e){return String(o||"").includes(e)})?n="timeout":400<=e?n="error":(-1<t.indexOf("fail")||!e||e<0)&&(n="failed"),n},hackWsConnect:function(){var e,t,n=this;Z({apiName:"sendSocketMessage",fail:function(e){n.publishSocketError(e)}}),e=(t={connectCallback:{fail:function(e){n.publishSocketError(e)}},taskOpt:{onError:function(e){n.publishSocketError(e)},send:{fail:function(e){n.publishSocketError(e)}}}}).connectCallback,t=t.taskOpt,_?_.addCallback(e):_=new Le(e),t&&_.addTaskConf(t)},publishSocketError:function(e){e&&this.publishErrorLog({msg:e.errMsg,level:v.WEBSOCKET_ERROR})}}),qe=new o({name:"reportAssetSpeed",isStart:!1,onNewAegis:function(e){this.isStart||(this.isStart=!0,this.start(e))},start:function(t){var e,n=this;i.getPerformance&&"function"==typeof(e=i.getPerformance()).createObserver&&e.createObserver(function(e){e=e.getEntries();null!=e&&e.forEach(function(e){g(e.uri,t.config.hostUrl)||"number"!=typeof e.duration||e.duration<=0||n.publishAssetLog(e)})}).observe({entryTypes:["resource"]})},generateLog:function(e){var t,n,o=e.transferSize;return{url:(t=e.uri,void 0===n&&(n=2048),String(t).replace(H,"").slice(0,n)),method:"get",duration:Math.round(100*e.duration)/100,status:200,type:"static",isHttps:!0,urlQuery:p(e.uri,!0),nextHopProtocol:"",domainLookup:0,connectTime:0,transferSize:0<o?o:-1}},publishAssetLog:function(t){var n=this;this.$walk(function(e){e.speedLogPipeline(n.generateLog(t))})}}),Ae=["onLaunch","onHide","onError","onLoad","onReady","onShow","onUnload"],_e=new o({name:"pagePerformance",pageNavigationStartTime:{},onNewAegis:function(e){try{r("getPerformance")&&this.reportPerformance(e),this.setPagePV(e),this.reportSetDataTiming(e)}catch(e){}},reportPerformance:function(f){var p=this,e=i.getPerformance();"function"==typeof e.createObserver&&null!=(e=null==e?void 0:e.createObserver(function(e){var t={},n=null==(n=e.getEntriesByName("appLaunch"))?void 0:n[0],o=null==(o=e.getEntriesByName("firstRender"))?void 0:o[0],r=null==(r=e.getEntriesByName("evaluateScript"))?void 0:r[0],i=null==(i=e.getEntriesByName("route"))?void 0:i[0],a=null==(a=null==(a=e.getEntriesByName("firstPaint"))?void 0:a[0])?void 0:a.startTime,s=null==(s=null==(s=e.getEntriesByName("largestContentfulPaint"))?void 0:s[0])?void 0:s.startTime,l=null==(l=null==(l=e.getEntriesByName("firstContentfulPaint"))?void 0:l[0])?void 0:l.startTime,c=null==(c=(null==(c=e.getEntriesByName("firstPaint"))?void 0:c[0])||(null==(c=e.getEntriesByName("route"))?void 0:c[0])||(null==(c=e.getEntriesByName("appLaunch"))?void 0:c[0]))?void 0:c.pageId,u=null==(e=(null==(u=e.getEntriesByName("route"))?void 0:u[0])||(null==(u=e.getEntriesByName("appLaunch"))?void 0:u[0]))?void 0:e.startTime;c&&(p.pageNavigationStartTime[c]=null,u)&&(p.pageNavigationStartTime[c]=u),n&&(t.appLaunch=n.duration||-1),o&&(t.firstScreenTiming=o.duration||-1),r&&(t.scriptEvaluateTiming=r.duration||-1),i&&(t.pageRouteTiming=i.duration||-1),a&&u?t.firstPaintTiming=Math.max(a-u,-1):a&&p.pageNavigationStartTime[c]&&(t.firstPaintTiming=Math.max(a-p.pageNavigationStartTime[c],-1)),s&&u?t.LCP=Math.max(s-u,-1):s&&p.pageNavigationStartTime[c]&&(t.LCP=Math.max(s-p.pageNavigationStartTime[c],-1)),l&&u?t.FCP=Math.max(l-u,-1):l&&p.pageNavigationStartTime[c]&&(t.FCP=Math.max(l-p.pageNavigationStartTime[c],-1)),0<Object.keys(t).length&&p.publish(t,f)}))&&e.observe({entryTypes:["navigation","render","script"]})},publish:function(t,n){var e,o,r,i=[],a=n.config,s=-1===(null==(e=n.config.performanceUrl)?void 0:e.indexOf("?"))?"?":"&";for(o in t)i.push(o+"="+t[o]);"function"==typeof a.urlHandler?(r=a.urlHandler()||window.location.href,this.$walk(function(e){e.send({url:n.config.performanceUrl+s+i.join("&")+"&from="+encodeURIComponent(r),beanFilter:["from"],type:b.PERFORMANCE,log:t})})):this.$walk(function(e){e.send({url:n.config.performanceUrl+s+i.join("&"),type:b.PERFORMANCE,log:t})})},setPagePV:function(t){var n=this;i.onAppRoute&&i.onAppRoute(function(e){"appLaunch"===e.openType&&!t.config.spa||(n.$walk(function(e){e.send({url:""+e.config.pvUrl,type:b.PV})}),n.reportPageLoaded(e))})},reportPageLoaded:function(e){e="infoType: behaviorBacktracking\ndataType: pageLoadAndRoute\npageLoadedPath: "+e.path+"\nopenType: "+e.openType;this.publishNormalLog({msg:e,level:v.INFO})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},reportSetDataTiming:function(t){var e,r,s,l,n,i,a,c,u=this,o=t.config.setDataReportConfig,o=void 0===o?{}:o;!0!==o.disabled&&(e=o.timeThreshold,r=!1!==o.withDataPaths,s=e&&0<+e?+e:30,l=y([m(t,10),function(e){e=e.map(function(e){return{type:b.SET_DATA,component:e.from,duration:e.duration,fields:e.dataPaths&&e.dataPaths.length?e.dataPaths.sort().join(";"):void 0,size:e.size}});t.send({url:t.config.setDataReportUrl+"?payload="+encodeURIComponent(JSON.stringify({miniProgramData:e})),type:b.SET_DATA,log:e})}]),n=Page,i=Component,a=function(e,t){var i,a,n=t.updateStartTimestamp,o=t.updateEndTimestamp,t=t.dataPaths,t=void 0===t?[]:t,o=o-n;isNaN(o)||o<s||(n={from:e.is,duration:o},r&&0<t.length&&Object.assign(n,{dataPaths:t.slice(0,30),size:(o=t,a=0,null!=(i=e)&&i.data?(o.forEach(function(e){for(var t=i.data[e[0]],n=1,o=e.length;n<o;n++)t[e[n]]&&(t=t[e[n]]);var r="";try{r=JSON.stringify(t)}catch(e){r=""}a+=2*(void 0===r?"":r).replace(/[\u4e00-\u9fa5]/g,"aa").length}),a=Math.min(a,10485760)):a)}),l(n))},c=function(o){var e="infoType: behaviorBacktracking\ndataType: tapEvent"+Object.keys(o[0]).reduce(function(e,t){var n="";try{n=t+": "+JSON.stringify(o[0][t])}catch(e){n=""}return e+"\n"+n},"");u.publishNormalLog({msg:e,level:v.INFO})},Page=function(t){var e=t.onReady;return t.onReady=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:r},function(e){a(t,e)}),null==e?void 0:e.call(this)},Object.keys(t).forEach(function(e){var n;"function"!=typeof t[e]||Ae.includes(e)||(n=t[e],t[e]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return null!=e&&e[0]&&"tap"===e[0].type&&c(e),null==n?void 0:n.apply(this,e)})}),n(t)},Component=function(e){e.lifetimes&&e.lifetimes.attached?(n=e.lifetimes.attached,e.lifetimes.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:r},function(e){a(t,e)}),null==n?void 0:n.call(this)}):(o=e.attached,e.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:r},function(e){a(t,e)}),null==o?void 0:o.call(this)});var n,o,t=e.methods;return t&&"[object Object]"===Object.prototype.toString.call(t)&&Object.keys(t).forEach(function(e){var n;"function"==typeof t[e]&&(n=t[e],t[e]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return null!=e&&e[0]&&"tap"===e[0].type&&c(e),null==n?void 0:n.apply(this,e)})}),i(e)})}}),o=new o({name:"reportLoadPackageSpeed",isLoaded:!1,onNewAegis:function(e){this.isLoaded||(this.isLoaded=!0,this.start(e))},start:function(){var e,t=this;i.getPerformance&&"function"==typeof(e=i.getPerformance()).createObserver&&e.createObserver(function(e){e=e.getEntries();null!=e&&e.forEach(function(e){"number"!=typeof e.duration||e.duration<=0||t.publishPackageLog(e)})}).observe({entryTypes:["loadPackage"]})},generateLog:function(e){return[{type:b.LOAD_PACKAGE,packageName:e.packageName,size:Math.round(100*e.packageSize)/100,duration:Math.round(100*e.duration)/100}]},publishPackageLog:function(n){var o=this;this.$walk(function(e){var t=o.generateLog(n);e.send({url:e.config.setDataReportUrl+"?payload="+encodeURIComponent(JSON.stringify({miniProgramData:t})),type:b.LOAD_PACKAGE,log:t})})}});function U(e){e=Te.call(this,e)||this;return e.taskHack=new Ne,e}function Ue(){this.onErrors=[],this.sends=[]}return n.use(w),n.use(Se),n.use(be),n.use(qe),n.use(_e),n.use(o),n.use(ye),n});
|