aegis-mp-sdk 1.24.57 → 1.36.1

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 CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * =================================================================
3
- * aegis-mp-sdk@1.24.57 (c) 2022 TencentCloud Real User Monitoring.
3
+ * aegis-mp-sdk@1.36.1 (c) 2022 TencentCloud Real User Monitoring.
4
4
  * Author pumpkincai.
5
- * Last Release Time Fri May 27 2022 15:26:25 GMT+0800 (GMT+08:00).
5
+ * Last Release Time Tue Aug 02 2022 20:32:21 GMT+0800 (GMT+08:00).
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 i=function(e,t){return(i=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}i(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,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function s(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var i=Array(e),o=0,t=0;t<n;t++)for(var r=arguments[t],s=0,a=r.length;s<a;s++,o++)i[o]=r[s];return i}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!=(i=arguments[n]))for(var i=Object(i),o=Object.keys(Object(i)),r=0,s=o.length;r<s;r++){var a=o[r],l=Object.getOwnPropertyDescriptor(i,a);null!=l&&l.enumerable&&(t[a]=i[a])}return t}});var r=(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){if(void 0===n&&(n=0),this){var i=this.eventsList[e];return(i||(this.eventsList[e]=[],i=this.eventsList[e]),-1!==this.indexOf(i,t))?this:(i.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)return null;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);function t(){var s=this;this.emit=function(e,t){if(s){var n;if(null!=(i=s.eventsList[e])&&i.length)for(var i=i.slice(),o=0;o<i.length;o++){n=i[o];try{var r=n.callback.apply(s,[t]);if(1===n.type&&s.remove(e,n.callback),!1===r)break}catch(e){throw e}}return s}},this.eventsList={}}(z={})[z.number=-1]="number",z.string="";function l(e,t){return"string"==typeof e?e.split("?")[t?1:0]||"":e}function u(e){return"string"==typeof e&&e.startsWith("//")?"undefined"!=typeof location&&"https:"===location.protocol:/^https/.test(e)}function c(e,t,n){var i;try{if("function"==typeof(null==t?void 0:t.retCodeHandler)){var o=t.retCodeHandler(e,null==n?void 0:n.url,null==n?void 0:n.ctx)||{};return{code:void 0===(r=o.code)?"unknown":r,isErr:o.isErr}}"string"==typeof e&&(e=JSON.parse(e)),"function"==typeof(null===(i=null==t?void 0:t.ret)||void 0===i?void 0:i.join)&&(m=[].concat(t.ret.map(function(e){return e.toLowerCase()})));var r,s=Object.getOwnPropertyNames(e).filter(function(e){return-1!==m.indexOf(e.toLowerCase())});return s.length?{code:""+(r=Number(e[s[0]])),isErr:0!==r}:{code:"unknown",isErr:!1}}catch(e){return{code:"unknown",isErr:!1}}}function n(){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}}var p,a,d,h,g,m=["ret","retcode","code","errcode"],v=function(e){if("string"==typeof e)return e;try{return e instanceof Error?(JSON.stringify(e,n(),4)||"undefined").replace(/"/gim,""):JSON.stringify(e,n(),4)||"undefined"}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}},o=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e,n())||"undefined"}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}},y=function(n,i){void 0===i&&(i=3);var o,r,s,a="";return Array.isArray(n)?(a+="[",o=n.length,n.forEach(function(e,t){a+="object"==typeof e&&1<i?y(e,i-1):O(e),a+=t===o-1?"":","}),a+="]"):n instanceof Object?(a="{",r=Object.keys(n),s=r.length,r.forEach(function(e,t){"object"==typeof n[e]&&1<i?a+='"'+e+'":'+y(n[e],i-1):a+=b(e,n[e]),a+=t===s-1||t<s-1&&void 0===n[r[t+1]]?"":","}),a+="}"):a+=n,a},b=function(e,t){var n=typeof t,i="";return"string"==n||"object"==n?i+='"'+e+'":"'+t+'"':"function"==typeof t?i+='"'+e+'":"function '+t.name+'"':"symbol"==typeof t?i+='"'+e+'":"symbol"':"number"!=typeof t&&"boolean"!=n||(i+='"'+e+'": '+t),i},O=function(e){var t=typeof e;return""+("undefined"==t||"symbol"==t||"function"==t?"null":"string"==t||"object"==t?'"'+e+'"':e)},w=function(e,t){var n,i={fetch:[],static:[]},o={};return Array.isArray(e)?e.forEach(function(e){var t;null===(t=i[e.type])||void 0===t||t.push(e)}):null===(n=i[e.type])||void 0===n||n.push(e),o.payload=JSON.stringify(f({duration:i},t)),o};(ne=p=p||{}).INFO_ALL="-1",ne.API_RESPONSE="1",ne.INFO="2",ne.ERROR="4",ne.PROMISE_ERROR="8",ne.AJAX_ERROR="16",ne.SCRIPT_ERROR="32",ne.IMAGE_ERROR="64",ne.CSS_ERROR="128",ne.CONSOLE_ERROR="256",ne.MEDIA_ERROR="512",ne.RET_ERROR="1024",ne.REPORT="2048",ne.PV="4096",ne.EVENT="8192",ne.PAGE_NOT_FOUND_ERROR="16384",ne.WEBSOCKET_ERROR="32768",(oe=a=a||{})[oe.android=1]="android",oe[oe.ios=2]="ios",oe[oe.windows=3]="windows",oe[oe.macos=4]="macos",oe[oe.linux=5]="linux",oe[oe.devtools=6]="devtools",oe[oe.other=100]="other",(re=d=d||{})[re.unknown=100]="unknown",re[re.wifi=1]="wifi",re[re.net2g=2]="net2g",re[re.net3g=3]="net3g",re[re.net4g=4]="net4g",re[re.net5g=5]="net5g",re[re.net6g=6]="net6g",(se=h=h||{}).LOG="log",se.SPEED="speed",se.PERFORMANCE="performance",se.OFFLINE="offline",se.WHITE_LIST="whiteList",se.VITALS="vitals",se.PV="pv",se.CUSTOM_PV="customPV",se.EVENT="event",se.CUSTOM="custom",se.SDK_ERROR="sdkError",se.SET_DATA="setData",(ve=g=g||{}).production="production",ve.gray="gray",ve.pre="pre",ve.daily="daily",ve.local="local",ve.test="test",ve.others="others";function E(e){return e.filter(function(n,i){return"static"!==n.type||!e.find(function(e,t){return n.url===e.url&&200===n.status&&i<t})})}function R(e){e.level===p.INFO_ALL&&(e.level=p.INFO)}function P(o){return function(e,t){o.lifeCycle.emit("modifyRequest",e);var n=o.config.modifyRequest;if("function"==typeof n)try{var i=n(e);"object"==typeof i&&"url"in i&&(e=i)}catch(e){console.error(e)}t(e)}}function S(i){return function(e,t){i.lifeCycle.emit("afterRequest",e);var n=i.config.afterRequest;"function"==typeof n&&!1===n(e)||t(e)}}function T(){}function x(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 k(){try{var e=getCurrentPages(),t=e[e.length-1]||{},n=(i=t.options,Object.keys(i).length?"?"+Object.keys(i).map(function(e){return e+"="+i[e]}).join("&"):"");return t.route?t.route+n:""}catch(e){return""}var i}function N(e,t){if("string"==typeof e&&"string"==typeof t){if(e===t)return 1;for(var n=e.split("."),i=t.split("."),o=Math.max(n.length,i.length),r=0;r<o;r++){var s=~~n[r],a=~~i[r];if(s<a)return;if(a<s)return 1}}}function L(e){var t=e.apiName,n=fe[t];return n?n.hackReq.addCallback(e):(n=wx[t],fe[t]={hackReq:new pe(e),originApi:n}),fe[t]}var C,A,U,j,q,I=function(i,o){return function(e,t){var n=o.logCreated;if("function"!=typeof n)return i("beforeWrite",e),t(e);e=e.filter(function(e){return!1!==n(e)});return i("beforeWrite",e),t(e)}},_=function(n,i){var o,r=[],s=n.config;return n.lifeCycle.on("destroy",function(){r.length=0}),function(e,t){if(Array.isArray(e)?r=r.concat(e):r.push(e),i&&r.length>=i||n.sendNow&&0<r.length)return r=E(r),t(r.splice(0,r.length)),void(o&&clearTimeout(o));o&&clearTimeout(o),o=setTimeout(function(){o=null,0<(r=E(r)).length&&t(r.splice(0,r.length))},s.delay)}},F=function(e,t){return Array.isArray(e)?t(e.map(function(e){return f(f({},e),{msg:"string"==typeof e.msg?e.msg:[].concat(e.msg).map(v).join(" ")})})):t([f(f({},e),{msg:"string"==typeof e.msg?e.msg:v(e.msg)})])},M=function(s){var e,a=!1,l=!1,t=!1,u=[];return s.lifeCycle.on("onConfigChange",function(){e&&clearTimeout(e),e=setTimeout(function(){var e,n;!t&&s.config&&(t=!0,e=s.config.whiteListUrl,(n=void 0===e?"":e)&&s.sendPipeline([function(e,t){t({url:n,type:h.WHITE_LIST,success:function(e){l=!0;try{var t=e.data||JSON.parse(e),n=t.retcode,i=t.result,o=void 0===i?{}:i;if(0===n){if(a=o.is_in_white_list,s.isWhiteList=a,o.shutdown)return void s.destroy();0<=o.rate&&o.rate<=1&&(s.config.random=o.rate,s.isGetSample=!1)}s.isWhiteList&&u.length?J(s)(u.splice(0),function(){}):!s.isWhiteList&&u.length&&(u.length=0);var r=s.config.onWhitelist;"function"==typeof r&&r(a)}catch(e){}},fail:function(e){"403 forbidden"===e&&s.destroy(),l=!0}})}],h.WHITE_LIST)(null),t=!1)},s.config.uin?50:500)}),s.lifeCycle.on("destroy",function(){u.length=0}),function(e,t){var n;a||null!==(n=null===(n=s.config)||void 0===n?void 0:n.api)&&void 0!==n&&n.reportRequest?t(e.concat(u.splice(0)).map(function(e){return R(e),e})):(e=e.filter(function(e){return e.level!==p.INFO&&e.level!==p.API_RESPONSE?(R(e),!0):(l||(u.push(e),200<=u.length&&(u.length=200)),!1)})).length&&t(e)}},H=function(i){return setTimeout(function(){var e=i.config.pvUrl,n=void 0===e?"":e;n&&i.sendPipeline([function(e,t){t({url:n,type:h.PV,fail:function(e){"403 forbidden"===e&&i.destroy()}})}],h.PV)(null)},100),function(e,t){t(e)}},D=function(o){var r={};return function(e,t){var n,i;o.speedSample?(i="object"==typeof o.repeat?o.repeat:{repeat:o.repeat},n=+i.speed||+i.repeat||5,Array.isArray(e)?(i=e.filter(function(e){var t=!r[e.url]||r[e.url]<n;return r[e.url]=1+~~r[e.url],t})).length&&t(i):(!r[e.url]||r[e.url]<n)&&(r[e.url]=1+~~r[e.url],t(e))):t(e)}},B=function(i){var o={};return function(e,t){var n="number"==typeof i.repeat?i.repeat:5;if(0===n)return t(e);t(e.filter(function(e){return e.level!==p.ERROR&&e.level!==p.PROMISE_ERROR&&e.level!==p.AJAX_ERROR&&e.level!==p.SCRIPT_ERROR&&e.level!==p.IMAGE_ERROR&&e.level!==p.CSS_ERROR&&e.level!==p.MEDIA_ERROR||(o[e.msg]=o[e.msg]||0,o[e.msg]+=1,!(o[e.msg]>n))}))}},J=function(i){return function(e){return i.sendPipeline([function(e,n){return n({url:i.config.url||"",data:function(e){if(!e||0===e.length)return"{}";e=Array.isArray(e)?e:[e];var t=Object.keys(e[0]),n={};return t.forEach(function(t){n[t]=e.map(function(e){return e[t]})}),n.count=e.length,o(n)}((t=e,(Array.isArray(t)?t:[t]).map(function(n){return Object.getOwnPropertyNames(n).reduce(function(e,t){return"ctx"!==t&&(e[t]=n[t]),e},{level:p.INFO,msg:""})}))),method:"post",contentType:"application/json",type:h.LOG,log:e,requestConfig:{timeout:5e3},success:function(){var t=i.config.onReport;"function"==typeof t&&e.forEach(function(e){t(e)}),"function"==typeof n&&n([])},fail:function(e){"403 forbidden"===e&&i.destroy()}});var t}],h.LOG)(e)}},V=function(i){return function(e){i.sendPipeline([function(e,t){var n=e.map(function(e){return{name:e.name,ext1:e.ext1||i.config.ext1||"",ext2:e.ext2||i.config.ext2||"",ext3:e.ext3||i.config.ext3||""}});t({url:i.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(n)),type:h.EVENT,log:e,fail:function(e){"403 forbidden"===e&&i.destroy()}})}],h.EVENT)(e)}},W=function(n){return function(e){return n.sendPipeline([function(e,t){t({url:n.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:h.CUSTOM,log:e,fail:function(e){"403 forbidden"===e&&n.destroy()}})}],h.CUSTOM)(e)}},G=function(r,s){return function(e,t){var n=Array.isArray(e),i=n?e:[e];r.lifeCycle.emit("beforeRequest",e);var o=r.config.beforeRequest;(i="function"==typeof o?i.map(function(t){try{var e=o({logs:t,logType:s});return(null==e?void 0:e.logType)===s&&null!=e&&e.logs?e.logs:!1!==e&&t}catch(e){return t}}).filter(function(e){return!1!==e}):i).length&&(i=function(e,t){if(!Array.isArray(e)||e.length<=1)return e;var n=[],i=[];return!(i="string"==typeof t?[t]:t)||i.length<=0||(i.forEach(function(t){e.forEach(function(e){null!=e&&e[t]&&n.push(t)})}),0<n.length&&(e=e.map(function(e){var t={};return n.forEach(function(e){t[e]=""}),f(f({},t),e)}))),e}(i,["ext1","ext2","ext3","level","trace","tag","seq"]),t(n?i:i[0]))}},K=function(n){if(!n||!n.reduce||!n.length)throw new TypeError("createPipeline need at least one function param");return 1===n.length?function(e,t){n[0](e,t||T)}:n.reduce(function(n,i){return function(e,t){return void 0===t&&(t=T),n(e,function(e){return null==i?void 0:i(e,t)})}})},$=(Object.defineProperty(xe.prototype,"__version__",{get:function(){return console.warn("__version__ has discard, please use version"),"1.24.57"},enumerable:!1,configurable:!0}),Object.defineProperty(xe.prototype,"LogType",{get:function(){return console.warn("LogType has discard, please use logType"),p},enumerable:!1,configurable:!0}),xe.prototype.init=function(e){this.setConfig(e);for(var t=0;t<xe.installedPlugins.length;t++)try{xe.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},xe.prototype.setConfig=function(e){Object.assign(this.config,e);var t=this.config,n=t.id,i=t.uin,o=t.version,r=t.ext1,s=t.ext2,a=t.ext3,l=t.aid,e=t.env,u=void 0===e?"production":e,e=t.pageUrl,t=this.bean.id!==n||this.bean.uin!==i||this.bean.aid!==l;return this.bean.id=n||"",this.bean.uin=i||"",this.bean.version=o||"1.24.57",this.bean.aid=l||"",this.bean.env=function(){switch(u){case g.production:case g.gray:case g.pre:case g.daily:case g.local:case g.test:case g.others:return 1;default:return}}()?u:g.others,e&&this.extendBean("from",encodeURIComponent(e)),r&&this.extendBean("ext1",encodeURIComponent(r)),s&&this.extendBean("ext2",encodeURIComponent(s)),a&&this.extendBean("ext3",encodeURIComponent(a)),t&&this.lifeCycle.emit("onConfigChange",this.config),this.config},xe.use=function(e){-1===xe.installedPlugins.indexOf(e)&&e.aegisPlugin&&xe.installedPlugins.push(e)},xe.unuse=function(e){e=xe.installedPlugins.indexOf(e);-1!==e&&xe.installedPlugins.splice(e,1)},xe.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:p.INFO,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:p.INFO}),this.normalLogPipeline(n)},xe.prototype.infoAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:p.INFO_ALL,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:p.INFO_ALL}),this.normalLogPipeline(n)},xe.prototype.report=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:p.REPORT,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0])),this.normalLogPipeline(n)},xe.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:p.ERROR,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:p.ERROR}),this.normalLogPipeline(n)},xe.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},xe.prototype.reportPv=function(n){var i,o=this;n&&(console.warn("reportPv is deprecated, please use reportEvent"),i=""+Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+o.bean[e]}).join("&"),this.sendPipeline([function(e,t){t({url:o.config.url+"/"+n+"?"+i,addBean:!1,type:h.CUSTOM_PV,fail:function(e){"403 forbidden"===e&&o.destroy()}})}],h.CUSTOM_PV)(null))},xe.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?this.eventPipeline(e):console.warn("reportEvent params error"))},xe.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")},xe.prototype.reportT=function(e){var t=e.name,n=e.duration,i=e.ext1,o=void 0===i?"":i,r=e.ext2,i=void 0===r?"":r,r=e.ext3,r=void 0===r?"":r,e=e.from;if("string"==typeof t&&"number"==typeof n&&"string"==typeof o&&"string"==typeof i&&"string"==typeof r){if(!(n<0||6e4<n))return this.submitCustomTime(t,n,o,i,r,void 0===e?"":e);console.warn("reportTime: duration must between 0 and 60000")}else console.warn("reportTime: params error")},xe.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")},xe.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")},xe.prototype.submitCustomTime=function(e,t,n,i,o,r){this.customTimePipeline({name:e,duration:t,ext1:n||this.config.ext1,ext2:i||this.config.ext2,ext3:o||this.config.ext3,from:r||void 0})},xe.prototype.extendBean=function(e,t){this.bean[e]=t},xe.prototype.sendPipeline=function(e,t){var n,r=this;return K(s([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,[P(this),function(i,o){r.request(i,function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];r.failRequestCount=0,o({isErr:!1,result:t,logType:null==i?void 0:i.type,logs:null==i?void 0:i.log}),null===(e=null==i?void 0:i.success)||void 0===e||e.call.apply(e,s([i],t))},function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];10<=++r.failRequestCount&&r.destroy(),o({isErr:!0,result:t,logType:null==i?void 0:i.type,logs:null==i?void 0:i.log}),null===(e=null==i?void 0:i.fail)||void 0===e||e.call.apply(e,s([i],t))})},S(this)]))},xe.prototype.send=function(e,o,r){var t=this;return K([P(this),function(n,i){t.request(n,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i({isErr:!1,result:e,logType:n.type,logs:n.log}),null==o||o.apply(void 0,e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i({isErr:!0,result:e,logType:n.type,logs:n.log}),null==r||r.apply(void 0,e)})},S(this)])(e)},xe.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},xe.prototype.sendSDKError=function(e){var n=this;this.sendPipeline([function(e,t){t({url:n.config.url+"?id=1085&msg[0]="+encodeURIComponent(v(e))+"&level[0]=2&from="+n.config.id+"&count=1&version="+n.config.id+"(1.24.57)",addBean:!1,method:"get",type:h.SDK_ERROR,log:e})}],h.SDK_ERROR)(e)},xe.prototype.destroy=function(e){void 0===e&&(e=!1);var t,n,i=xe.instances.indexOf(this);-1!==i&&xe.instances.splice(i,1);for(var o=xe.installedPlugins.length-1;0<=o;o--)try{xe.installedPlugins[o].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 r=this;r.constructor!==Object&&x(r,this),r=Object.getPrototypeOf(r););0===xe.instances.length&&(e=Object.getPrototypeOf(this).constructor,x(e),x(xe))}},xe.version="1.24.57",xe.instances=[],xe.logType=p,xe.environment=g,xe.installedPlugins=[],xe),z=(Te.prototype.patch=function(e){this.canUse(e)&&this.exist(e)&&(this.instances.push(e),this.triggerInit(e),this.triggerOnNewAegis(e))},Te.prototype.unpatch=function(e){e=this.instances.indexOf(e);-1!==e&&(this.instances.splice(e,1),0===this.instances.length&&this.uninstall())},Te.prototype.countInstance=function(){return this.instances.length},Te.prototype.uninstall=function(){var e;null===(e=null===(e=this.option)||void 0===e?void 0:e.destroy)||void 0===e||e.apply(this)},Te.prototype.walk=function(n){var i=this;this.instances.forEach(function(e){var t=i.canUse(e);t&&n(e,t)})},Te.prototype.canUse=function(e){e=this.getConfig(e);return!(!e||"object"!=typeof e)||!!e},Te.prototype.getConfig=function(e){return null===(e=e.config)||void 0===e?void 0:e[this.name]},Te.prototype.exist=function(e){return-1===this.instances.indexOf(e)},Te.prototype.triggerInit=function(e){var t;this.inited||(this.inited=!0,null===(t=null===(t=this.option)||void 0===t?void 0:t.init)||void 0===t||t.call(this.option,this.getConfig(e)))},Te.prototype.triggerOnNewAegis=function(e){var t;null===(t=null===(t=this.option)||void 0===t?void 0:t.onNewAegis)||void 0===t||t.call(this.option,e,this.getConfig(e))},Te),X=wx||qq,Q="",Y=function(e){return Q=Q||X.getSystemInfoSync().SDKVersion,N(Q,"1.1.1")&&X.canIUse?X.canIUse(e):!!X[e]},Z=new z({name:"offlineLog",onNewAegis:function(o){if(X.getFileSystemManager)try{var e=o.config,t=e.id,r=void 0===t?"":t,n=e.uin,s=void 0===n?0:n,i=e.offlineUrl,a=void 0===i?"":i,l=e.offlineLogLimit,u=new ee({limit:l});o.lifeCycle.on("beforeWrite",function(e){u.save2Offline(e=void 0===e?[]:e,o.config)}),u.ready(function(t){var e=(o.bean||{}).aid,i=void 0===e?"":e;!t&&r&&(s||i)&&o.send({url:a+"/offlineAuto",type:h.OFFLINE,log:h.OFFLINE},function(e){var n=(null==e?void 0:e.data).secretKey;n&&(t||u.getLogs({id:r,uin:s},function(e,t){e?console.error(e):o.send({url:a+"/offlineLog",data:{logs:t,secretKey:n,id:r,uin:s,aid:i},method:"post",type:h.OFFLINE,log:t},function(){u.clearLogs()})}))})})}catch(o){console.error(o)}else console.warn("[aegis-mp-sdk]unsupport getFileSystemManager offline log not work!")}}),ee=(Se.prototype.getLogs=function(e,t){var n=this.fileSystem,i=this.filePath;n.readFile({filePath:i,encoding:"utf8",fail:function(e){console.error(e)},success:function(e){e=e.data,e=(void 0===e?"":e).toString().split("\n").filter(function(e){return e}).map(function(e){return JSON.parse(e)});t(null,e)}})},Se.prototype.checkLimit=function(o,r){void 0===r&&(r=function(){});var s=this.fileSystem,a=this.filePath,l=this.limitSize;s.readFile({filePath:a,encoding:"utf8",success:function(e){e=e.data,e=void 0===e?"":e;if((e=e.toString()+o).length>l){for(var t=e.split("\n"),n="",i=t.length-1;0<=i&&!(t[i]&&(n=t[i]+"\n"+n).length>l);i--);s.writeFile({filePath:a,data:n,success:r})}else s.appendFile({data:o,filePath:a,encoding:"utf8",success:r,fail:function(e){console.error(e)}})}})},Se),te=function(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},i=d.unknown,o=0;o<Object.keys(n).length;o++){var r=Object.keys(n)[o];if(null!==(t=n[r])&&void 0!==t&&t.test(e)){i=d[r];break}}return i},ne=new z({name:"device",onNewAegis:function(l){return e=this,u=function(){return n=this,i=function(e){return this.setSystemInfo(l),this.refreshNetwork(l),this.setNetworkChange(l),[2]},a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,r&&(s=2&t[0]?r.return:t[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,t[1])).done)return s;switch(r=0,(t=s?[2&t[0],s.value]:t)[0]){case 0:case 1:s=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,r=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!((s=0<(s=a.trys).length&&s[s.length-1])||6!==t[0]&&2!==t[0])){a=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){a.label=t[1];break}if(6===t[0]&&a.label<s[1]){a.label=s[1],s=t;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(t);break}s[2]&&a.ops.pop(),a.trys.pop();continue}t=i.call(n,a)}catch(e){t=[6,e],r=0}finally{o=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}var n,i,o,r,s,a,t},new(a=(a=s=void 0)||Promise)(function(n,t){function i(e){try{r(u.next(e))}catch(e){t(e)}}function o(e){try{r(u.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?n(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(i,o)}r((u=u.apply(e,s||[])).next())});var e,s,a,u},setSystemInfo:function(s){var a=this;try{Y("getSystemInfo")&&X.getSystemInfo({success:function(e){var t=e.platform,n=e.model,i=e.windowHeight,o=e.windowWidth,r=e.screenWidth,r=void 0===r?0:r,e=e.screenHeight,e=void 0===e?0:e;s.extendBean("platform",a.getPlatFormType(t)),s.extendBean("model",n),s.extendBean("vp",Math.round(o)+" * "+Math.round(i)),s.extendBean("sr",Math.round(r)+" * "+Math.round(e))}})}catch(s){}},getPlatFormType:function(e){for(var t,n={android:/android/i,ios:/ios/i,windows:/windows/i,macos:/mac/i,devtools:/devtools/i},i=a.other,o=0;o<Object.keys(n).length;o++){var r=Object.keys(n)[o];if(null!==(t=n[r])&&void 0!==t&&t.test(e)){i=a[r];break}}return i},setNetworkChange:function(t){Y("onNetworkStatusChange")&&X.onNetworkStatusChange(function(e){e=te(e.networkType);t.extendBean("netType",e)})},setNetworkType:function(t){Y("getNetworkType")&&X.getNetworkType({success:function(e){e=te(e.networkType);t.extendBean("netType",e)}})},refreshNetwork:function(e){var t=this;this.timer&&clearTimeout(this.timer),this.setNetworkType(e),this.timer=setTimeout(function(){t.refreshNetwork(e)},1e4)}}),ie=X.request,oe=(e(Pe,q=$),Object.defineProperty(Pe.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(k()):"from="+encodeURIComponent(k())},enumerable:!1,configurable:!0}),Pe.prototype.initOfflineLog=function(){Pe.use(Z)},Pe.prototype.uploadLogs=function(e,t){this.lifeCycle.emit("uploadLogs",e=void 0===e?{}:e,t=void 0===t?{}:t)},Pe.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(k()),this.send({url:this.config.url+"/"+e+"?"+t,addBean:!1,type:h.CUSTOM_PV,log:h.CUSTOM_PV},function(){},function(){}))},Pe.sessionID="session-"+Date.now(),Pe.asyncPluginIndex=0,Pe),re=new z({name:"aid",onNewAegis:function(t){this.initAid(function(e){t.bean.aid=e,t.config.aid=e})},initAid:function(t){X.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)});X.setStorage({key:"AEGIS_ID",data:e,success:function(){t(e)}})}})}}),se=(Re.prototype.addCallback=function(e){e&&this.callbacks.push(e)},Re.prototype.prefixHandler=function(e){return f(f({},e),{aegisRequestStartTime:+new Date})},Re.prototype.successHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null===(t=e.success)||void 0===t||t.call(e,n,i)}catch(e){}}),null===(e=i.success)||void 0===e||e.call(i,n,i)},Re.prototype.failHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null===(t=e.fail)||void 0===t||t.call(e,n,i)}catch(e){}}),null===(e=i.fail)||void 0===e||e.call(i,n,i)},Re.prototype.completeHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null===(t=e.complete)||void 0===t||t.call(e,n,i)}catch(e){}}),null===(e=i.complete)||void 0===e||e.call(i,n,i)},Re.prototype.override=function(){try{this.defineApiProperty()}catch(e){console.warn("cannot override `"+this.apiName+"`, error is: "+e)}finally{this.isOverride=!0}},Re),ae=wx||qq,le=null===(ve=ae.cloud)||void 0===ve?void 0:ve.callFunction,ue=(e(Ee,j=se),Ee.prototype.defineApiProperty=function(){var e=this;ae.cloud&&ae.cloud.callFunction&&Object.defineProperty(ae.cloud,"callFunction",{get:function(){return e.hackHandler.bind(e)}})},Ee.prototype.hackHandler=function(e){var i=this,o=this.prefixHandler(e);return new Promise(function(t,n){le(f(f({},o),{success:function(e){i.successHandler(e,o),t(e)},fail:function(e){i.failHandler(e,o),n(e)},complete:function(e){i.completeHandler(e,o)}}))})},Ee),ce=wx||qq,fe={},pe=(e(we,U=se),we.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(ce,this.apiName,{get:function(){return e.hackHandler.bind(e)}})},we.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e),e=null===(e=fe[this.apiName])||void 0===e?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)}}))},we),$=new z({name:"reportApiSpeed",override:!1,onNewAegis:function(e){this.override||(this.override=!0,this.hackRequest(e.config),this.overrideCallFunction(e.config))},hackRequest:function(s){var a=this;L({apiName:"request",success:function(e,t){var n,i,o,r;s.hostUrl&&-1<t.url.indexOf(s.hostUrl)||(n={method:t.method||"get",url:l(t.url),duration:Date.now()-t.aegisRequestStartTime,status:e.statusCode||0,isHttps:u(t.url),type:"fetch"},r=null===(i=s.api)||void 0===i?void 0:i.apiDetail,i=(o=c(e.data,s.api,{url:t.url,ctx:e})||{}).code,o=o.isErr,r="req url: "+n.url+" \n \nreq method: "+n.method+" \n \nreq param: "+(r?v(t.data):"")+" \n \nres duration: "+n.duration+"ms \n \nres status: "+(e.statusCode||0)+" \n \nres retcode: "+i+" \n \nres data: "+(r?y(e.data):""),a.publishNormalLog({msg:r,level:p.API_RESPONSE,ctx:e}),n.ret=i,n.isErr=+o,a.publishSpeedLog(n),o&&a.publishNormalLog({msg:r,level:p.RET_ERROR,ctx:e}))},fail:function(e,t){s.hostUrl&&-1<t.url.indexOf(s.hostUrl)||(t={method:t.method||"get",url:l(t.url),duration:Date.now()-t.aegisRequestStartTime,status:0,isHttps:u(t.url),type:"fetch"},a.publishSpeedLog(t))}})},overrideCallFunction:function(l){var u=this;new ue({apiName:"callFunction",success:function(e,t){var n={method:"call",url:"wx.cloud.callFunction."+t.name,duration:Date.now()-t.aegisRequestStartTime,status:200,type:"fetch",errMsg:e.errMsg,isHttps:!0},i=null===(a=l.api)||void 0===a?void 0:a.apiDetail,o="req url: "+n.url+"\n \nreq type: "+n.type+"\n \nres duration: "+n.duration+"ms \n \nres errMsg: "+n.errMsg+"\n \nres data: "+(i?y(e.result):"")+"\n ";u.publishNormalLog({msg:o,level:p.API_RESPONSE,ctx:e});var r,s,a=!1,a=(s="function"==typeof(null===(i=l.api)||void 0===i?void 0:i.retCodeCloudFunctionHandler)?(r=(t=l.api.retCodeCloudFunctionHandler(e.result,t.name,t,e)||{}).code,void 0!==(t=t.isErr)&&t):(r=(s=c(e.result,l.api,{url:n.url,ctx:e})||{}).code,s.isErr),n.ret=r,s);n.isErr=+a,u.publishSpeedLog(n),a&&u.publishNormalLog({msg:o,level:p.RET_ERROR,ctx:e})},fail:function(e,t){e={method:"call",url:"wx.cloud.callFunction."+t.name,duration:Date.now()-t.aegisRequestStartTime,status:0,type:"fetch",errMsg:e.errMsg,isHttps:!0};u.publishSpeedLog(e)}})},publishSpeedLog:function(t){this.$walk(function(e){e.speedLogPipeline(t)})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})}}),de=wx||qq,he=de.connectSocket,ge=(Oe.prototype.addConfig=function(e){var t=e.send,e=e.onError;t&&this.sends.push(t),e&&this.onErrors.push(e)},Oe.prototype.toHack=function(t){var o=this;this.onErrors.forEach(function(e){t.onError(e)});var n=t.send;return Object.defineProperty(t,"send",{get:function(){return function(i){return new Promise(function(e){n(f(f({},i),{fail:function(n){o.sends.forEach(function(e){var t;null===(t=e.fail)||void 0===t||t.call(e,n,i)}),e(n)}}))})}}}),t},Oe),me=(e(be,A=se),be.prototype.addTaskConf=function(e){this.taskHack.addConfig(e)},be.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(de,"connectSocket",{get:function(){return e.hackHandler.bind(e)}})},be.prototype.hackHandler=function(e){var i,o=this,r=this.prefixHandler(e);return new Promise(function(t,n){i=he(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)}})),o.taskHack.toHack(i)}),i},be),ve=new z({name:"onError",onNewAegis:function(e){var t=X.getSystemInfoSync().SDKVersion;this.listenError(),this.hackNetWork(e),e.config.websocketHack&&N(t,"1.7.0")&&this.hackWsConnect()},listenError:function(){var t=this;"function"==typeof X.onError&&X.onError(function(e){e&&t.publishErrorLog({msg:e,level:p.ERROR})}),Y("onUnhandledRejection")&&X.onUnhandledRejection(function(e){e=e.reason;e&&(-1<JSON.stringify(e).indexOf("request:fail")||t.publishErrorLog({msg:e,level:p.PROMISE_ERROR}))}),Y("onPageNotFound")&&X.onPageNotFound(function(e){e&&t.publishErrorLog({msg:e,level:p.PAGE_NOT_FOUND_ERROR})})},publishErrorLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},hackNetWork:function(e){for(var n=this,i=e.config,t=0,o=[{apiName:"request",complete:function(e,t){return n.requestCompleteError(e,t,i)}},{apiName:"uploadFile",complete:function(e,t){return n.uploadFileCompleteError(e,t,i)}},{apiName:"downloadFile",complete:function(e,t){return n.downloadFileCompleteError(e,t,i)}}];t<o.length;t++){var r=o[t],s=r.apiName,r=r.complete;L({apiName:s,complete:r})}},requestCompleteError:function(e,t,n){var i,o=e.errMsg,r=e.statusCode;n.hostUrl&&-1<(null===(i=t.url)||void 0===i?void 0:i.indexOf(n.hostUrl))||(r=this.getErrorType({errMsg:o,statusCode:r}))&&this.publishNetWorkError({apiName:"request",opts:t,res:e,config:n,type:r})},downloadFileCompleteError:function(e,t,n){var i=e.errMsg,o=e.statusCode,r=e.filePath,s=e.tempFilePath,e=this.getErrorType({errMsg:i,statusCode:o});e&&(n=null===(n=n.api)||void 0===n?void 0:n.apiDetail,this.publishErrorLog({msg:"AJAX_ERROR: downloadFile "+e+"\n \nres status: "+(o||0)+"\n \nres duration: "+(Date.now()-t.aegisRequestStartTime)+"ms\n \nres filePath: "+r+"\n \nres tempFilePath: "+s+"\n \nreq url: "+t.url+"\n \nreq method: "+(t.method||"get")+"\n \nreq param: "+(n?v(t.data):"")+"\n \nerrMsg: "+i.slice(0,1e3),level:p.AJAX_ERROR}))},uploadFileCompleteError:function(e,t,n){var i=e.errMsg,o=e.statusCode,o=this.getErrorType({errMsg:i,statusCode:o});o&&this.publishNetWorkError({apiName:"uploadFile",opts:t,res:e,config:n,type:o})},publishNetWorkError:function(e){var t=e.apiName,n=e.opts,i=e.res,o=e.config,r=e.type,s=i.errMsg,a=i.statusCode,l=i.data,e=null===(u=o.api)||void 0===u?void 0:u.apiDetail,u="wx.cloud.callFunction."+n.url,i=c(l,o.api,{url:u,ctx:i}).code;this.publishErrorLog({msg:"AJAX_ERROR: "+t+" "+r+"\n \nres status: "+(a||0)+"\n \nres retcode: "+i+"\n \nres duration: "+(Date.now()-n.aegisRequestStartTime)+"ms\n \nres data: "+(e?v(l):"")+"\n \nreq url: "+n.url+"\n \nreq method: "+(n.method||"get")+"\n \nreq param: "+(e?v(n.data):"")+"\n \nerrMsg: "+s.slice(0,1e3),level:p.AJAX_ERROR})},getErrorType:function(e){var t=e.errMsg,n=e.statusCode,e="";return-1<t.indexOf("timeout")||-1<t.indexOf("超时")?e="timeout":400<=n?e="error":(-1<t.indexOf("fail")||!n||n<0)&&(e="failed"),e},hackWsConnect:function(){var e,t,n=this;L({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,C?C.addCallback(e):C=new me(e),t&&C.addTaskConf(t)},publishSocketError:function(e){e&&this.publishErrorLog({msg:e.errMsg,level:p.WEBSOCKET_ERROR})}}),se=new z({name:"reportAssetSpeed",isStart:!1,onNewAegis:function(e){this.isStart||(this.isStart=!0,this.start(e))},start:function(){var t=this;X.getPerformance&&X.getPerformance().createObserver(function(e){e=e.getEntries();null==e||e.forEach(function(e){"number"!=typeof e.duration||e.duration<=0||t.publishAssetLog(e)})}).observe({entryTypes:["resource"]})},generateLog:function(e){return{url:""+l(e.uri),method:"get",duration:Math.round(100*e.duration)/100,status:200,type:"static",isHttps:!0,urlQuery:"",domainLookup:0,connectTime:0}},publishAssetLog:function(t){var n=this;this.$walk(function(e){e.speedLogPipeline(n.generateLog(t))})}}),ye=["onLaunch","onHide","onError","onLoad","onReady","onShow","onUnload"],z=new z({name:"pagePerformance",pageNavigationStartTime:{},onNewAegis:function(e){try{Y("getPerformance")&&this.reportPerformance(e),this.setPagePV(e),this.reportSetDataTiming(e)}catch(e){}},reportPerformance:function(f){var p=this,e=X.getPerformance(),e=null==e?void 0:e.createObserver(function(e){var t,n,i={},o=null===(t=e.getEntriesByName("appLaunch"))||void 0===t?void 0:t[0],r=null===(a=e.getEntriesByName("firstRender"))||void 0===a?void 0:a[0],s=null===(l=e.getEntriesByName("evaluateScript"))||void 0===l?void 0:l[0],a=null===(t=e.getEntriesByName("route"))||void 0===t?void 0:t[0],l=null===(t=null===(l=e.getEntriesByName("firstPaint"))||void 0===l?void 0:l[0])||void 0===t?void 0:t.startTime,u=null===(n=(null===(t=e.getEntriesByName("firstPaint"))||void 0===t?void 0:t[0])||(null===(n=e.getEntriesByName("route"))||void 0===n?void 0:n[0])||(null===(u=e.getEntriesByName("appLaunch"))||void 0===u?void 0:u[0]))||void 0===n?void 0:n.pageId,c=null===(c=(null===(n=e.getEntriesByName("route"))||void 0===n?void 0:n[0])||(null===(c=e.getEntriesByName("appLaunch"))||void 0===c?void 0:c[0]))||void 0===c?void 0:c.startTime;u&&(p.pageNavigationStartTime[u]=null,c&&(p.pageNavigationStartTime[u]=c)),o&&(i.appLaunch=o.duration),r&&(i.firstScreenTiming=r.duration),s&&(i.scriptEvaluateTiming=s.duration),a&&(i.pageRouteTiming=a.duration),l&&c?i.firstPaintTiming=Math.max(l-c,0):l&&p.pageNavigationStartTime[u]&&(i.firstPaintTiming=Math.max(l-p.pageNavigationStartTime[u],0)),p.publish(i,f)});null==e||e.observe({entryTypes:["navigation","render","script"]})},publish:function(t,n){var e,i,o=[],r=n.config,s=-1===(null===(e=n.config.performanceUrl)||void 0===e?void 0:e.indexOf("?"))?"?":"&";for(i in t)o.push(i+"="+t[i]);"function"==typeof r.urlHandler?this.$walk(function(e){e.send({url:n.config.performanceUrl+s+o.join("&")+"&from="+(encodeURIComponent(r.urlHandler())||window.location.href),beanFilter:["from"],type:h.PERFORMANCE,log:t})}):this.$walk(function(e){e.send({url:n.config.performanceUrl+s+o.join("&"),type:h.PERFORMANCE,log:t})})},setPagePV:function(e){var t=this;X.onAppRoute&&X.onAppRoute(function(e){"appLaunch"!==e.openType&&(t.$walk(function(e){e.send({url:""+e.config.pvUrl,type:h.PV})}),t.reportPageLoaded(e))})},reportPageLoaded:function(e){e="infoType: behaviorBacktracking\ndataType: pageLoadAndRoute\npageLoadedPath: "+e.path+"\nopenType: "+e.openType;this.publishNormalLog({msg:e,level:p.INFO})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},reportSetDataTiming:function(t){var e,o,a,l,n,r,s,u,c=this,i=t.config,i=i.setDataReportConfig||(null===(e=i.pagePerformance)||void 0===e?void 0:e.setDataReportConfig)||{};!0!==i.disabled&&(e=i.timeThreshold,o=!1!==i.withDataPaths,a=e&&0<+e?+e:30,l=K([_(t,10),function(e){e=e.map(function(e){return{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:h.SET_DATA,log:e})}]),n=Page,r=Component,s=function(e,t){var r,s,n=t.updateStartTimestamp,i=t.updateEndTimestamp,t=t.dataPaths,t=void 0===t?[]:t,n=i-n;isNaN(n)||n<a||(n={from:e.is,duration:n},o&&0<t.length&&Object.assign(n,{dataPaths:t.slice(0,30),size:(t=t,s=0,null!=(r=e)&&r.data?(t.forEach(function(e){for(var t=r.data[e[0]],n=1,i=e.length;n<i;n++)t[e[n]]&&(t=t[e[n]]);var o="";try{o=JSON.stringify(t)}catch(e){o=""}s+=2*(void 0===o?"":o).replace(/[\u4e00-\u9fa5]/g,"aa").length}),s=Math.min(s,10485760)):s)}),l(n))},u=function(i){var e="infoType: behaviorBacktracking\ndataType: tapEvent"+Object.keys(i[0]).reduce(function(e,t){var n="";try{n=t+": "+JSON.stringify(i[0][t])}catch(e){n=""}return e+"\n"+n},"");c.publishNormalLog({msg:e,level:p.INFO})},Page=function(t){var e=t.onReady;return t.onReady=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:o},function(e){s(t,e)}),null==e?void 0:e.call(this)},Object.keys(t).forEach(function(e){var n;"function"!=typeof t[e]||ye.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&&u(e),null==n?void 0:n.apply(this,e)})}),n(t)},Component=function(e){var n,i;e.lifetimes&&e.lifetimes.attached?(n=e.lifetimes.attached,e.lifetimes.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:o},function(e){s(t,e)}),null==n?void 0:n.call(this)}):(i=e.attached,e.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:o},function(e){s(t,e)}),null==i?void 0:i.call(this)});var 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&&u(e),null==n?void 0:n.apply(this,e)})}),r(e)})}});function be(e){e=A.call(this,e)||this;return e.taskHack=new ge,e}function Oe(){this.onErrors=[],this.sends=[]}function we(){return null!==U&&U.apply(this,arguments)||this}function Ee(){return null!==j&&j.apply(this,arguments)||this}function Re(e){this.callbacks=[],this.isOverride=!1;var t=e.apiName;this.apiName=t,this.isOverride||this.override(),this.callbacks.push(e)}function Pe(e){var i,c=q.call(this,e)||this;c.originRequest=ie,c.speedLogPipeline=K([D(c.config),_(c),function(t,n){Y("getNetworkType")?X.getNetworkType({success:function(e){e=te(e.networkType);i.extendBean("netType",e),n(t)}}):n(t)},function(e,t){c.lifeCycle.emit("beforeReportSpeed",e);var n=c.config.beforeReportSpeed;if((e="function"==typeof n?e.filter(function(e){return!1!==n(e)}):e).length)return t(e)},G(i=c,h.SPEED),function(e){c.send({url:""+c.config.speedUrl,method:"post",data:w(e,c.bean)})}]),c.requestQueue=[],c.requesting=!1,c.request=function(e,t,n){if(e.url&&c.bean.id)if(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(String(c.bean.aid))){if(!(c.requesting||Y("getNetworkType")&&void 0===c.bean.netType)){c.requesting=!0;var i,o=e.url;c.config.whiteListUrl===o&&(i=t,t=function(e){null==i||i(JSON.stringify(e.data))}),!1!==e.addBean&&(o=o+(-1===o.indexOf("?")?"?":"&")+c.getBean);var r=e.method||"get",s=function(){c.requesting=!1;var e=c.requestQueue.shift();e&&c.request(e.options,e.success,e.fail)},a=e,l=c.config.onBeforeRequest;if(!(a=l?l(e,c):a)||!a.url){var u="";return a&&a.url||(u="Sending request blocked. Please handle the parameters reasonably, options.url is necessary",console.log(u)),null==n||n(u),s(),!1}u=c.config.enableHttp2||!1;return"get"===r?(o=function(e,n){if("string"!=typeof e)return"";if("object"==typeof n&&n){var t=Object.getOwnPropertyNames(n).map(function(e){var t=n[e];return e+"="+("string"==typeof t?encodeURIComponent(t):encodeURIComponent(JSON.stringify(t)))}).join("&").replace(/eval/gi,"evaI");return e+(-1===e.indexOf("?")?"?":"&")+t}return e}(o,a.data),c.originRequest(f({url:o,enableHttp2:u,success:t,fail:n,complete:s},e.requestConfig))):("string"==typeof a.data&&(a.data=a.data.replace(/eval/gi,"evaI")),c.originRequest(f({url:o,enableHttp2:u,header:a.contentType?{"content-type":a.contentType}:void 0,method:"POST",data:a.data,success:t,fail:n,complete:s},e.requestConfig))),!0}c.requestQueue.push({options:e,success:t,fail:n})}else c.requestQueue.push({options:e,success:t,fail:n})};try{e.offlineLog&&c.initOfflineLog(),c.init(e),c.extendBean("sessionId",Pe.sessionID),c.extendBean("referer",(Y("getLaunchOptionsSync")?X.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"),c.sendSDKError(e)}return c}function Se(e){var o,r,s=this,t=void 0===e?{}:e,e=t.path,e=void 0===e?"/.aegis.offline.log":e,t=t.limit,t=void 0===t?2e4:t;this.offlineBuffer=[],this.insertLog=(o=null,r=[],function(e){r=r.concat(e),o=o||setTimeout(function(){o=null;var e,t=s.fileSystem,n=s.filePath,i=r.map(function(e){return JSON.stringify(e)}).join("\n")+"\n";i&&(e=function(e){e?s.checkLimit(i,function(){r=[]}):t.writeFile({data:i,filePath:n,encoding:"utf8",fail:function(e){console.error(e)},success:function(){r=[]}})},t.access({path:n,success:function(){e(!0)},fail:function(){e()}}))},2e3)}),this.ready=function(e){s.fileSystem?setTimeout(function(){e(null)},0):(e(new Error("getFileSystemManager file")),s.offlineLog=!1)},this.clearLogs=function(){var e=s.fileSystem,t=s.filePath;e.writeFile({filePath:t,data:"",fail:function(){e.unlinkSync(t)}})},this.save2Offline=function(e,t){e=(e=!Array.isArray(e)?[e]:e).map(function(e){return"string"==typeof e&&(e={msg:e}),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e[0]),i=1;i<e.length;i++){var o=e[i];if(null!==o)for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n[r]=o[r])}return n}({id:t.id,uin:t.uin,time:+Date.now(),version:t.version,from:k()},e)});s.fileSystem?s.insertLog(e):(s.fileSystem||s.offlineBuffer.length||s.ready(function(e){e?console.error(e):s.offlineBuffer.length&&(s.addLogs(s.offlineBuffer),s.offlineBuffer=[])}),s.offlineBuffer=s.offlineBuffer.concat(e))},this.addLogs=function(e){s.fileSystem&&s.insertLog(e)},this.filePath=X.env.USER_DATA_PATH+e,this.fileSystem=X.getFileSystemManager(),this.limitSize=t}function Te(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 xe(e){var n,t,o=this;this.isGetSample=!1,this.isHidden=!1,this.config={version:0,delay:1e3,onError:!0,repeat:5,random:1,aid:!0,device:!0,pagePerformance:!0,webVitals:!0,speedSample:!0,onClose:!0,hostUrl:"https://aegis.qq.com",websocketHack:!1,env:"production",url:"",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",webVitalsUrl:"",eventUrl:"",setDataReportUrl:""},this.isWhiteList=!1,this.lifeCycle=new r,this.bean={},this.normalLogPipeline=K([_(this,5),F,function(e,t){var i=n.config;t(e=e.map(function(e){var t,n=i.maxLength||204800;try{if(!e.msg||e.msg.length<=n)return e;e.msg=null===(t=e.msg)||void 0===t?void 0:t.substring(0,n)}catch(t){e.msg=v(e.msg).substring(0,i.maxLength)}return e}))},B((n=this).config),I(this.lifeCycle.emit,this.config),H(this),M(this),function(e,t){try{var n=JSON.parse(JSON.stringify(e));o.lifeCycle.emit("beforeReport",n);var i=o.config.beforeReport;(e="function"==typeof i?e.filter(function(e){return!1!==i(e)}):e).length&&t(e)}catch(e){}},J(this)]),this.eventPipeline=K([_(this,5),V(this)]),this.timeMap={},this.failRequestCount=0,this.customTimePipeline=K([_(this,5),W(this)]),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),xe.instances.push(this)}return oe.use(ve),oe.use($),oe.use(re),oe.use(se),oe.use(z),oe.use(ne),oe});
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 I=function(e,t){return(I=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}I(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var p=function(){return(p=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function q(i,o){var r,s,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[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(r)throw new TypeError("Generator is already executing.");for(;l;)try{if(r=1,s&&(a=2&t[0]?s.return:t[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,t[1])).done)return a;switch(s=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return l.label++,{value:t[1],done:!1};case 5:l.label++,s=t[1],t=[0];continue;case 7:t=l.ops.pop(),l.trys.pop();continue;default:if(!((a=0<(a=l.trys).length&&a[a.length-1])||6!==t[0]&&2!==t[0])){l=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){l.label=t[1];break}if(6===t[0]&&l.label<a[1]){l.label=a[1],a=t;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(t);break}a[2]&&l.ops.pop(),l.trys.pop();continue}t=o.call(i,l)}catch(e){t=[6,e],s=0}finally{r=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}function s(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var i=Array(e),o=0,t=0;t<n;t++)for(var r=arguments[t],s=0,a=r.length;s<a;s++,o++)i[o]=r[s];return i}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!=(i=arguments[n]))for(var i=Object(i),o=Object.keys(Object(i)),r=0,s=o.length;r<s;r++){var a=o[r],l=Object.getOwnPropertyDescriptor(i,a);null!=l&&l.enumerable&&(t[a]=i[a])}return t}});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 i;if(void 0===n&&(n=0),this)return(i=this.eventsList[e])||(this.eventsList[e]=[],i=this.eventsList[e]),-1===this.indexOf(i,t)&&i.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={}};var F=t,D=function(e){if(!e||0===e.length)return"{}";e=Array.isArray(e)?e:[e];var t=Object.keys(e[0]),n={},i=(t.forEach(function(t){n[t]=e.map(function(e){return e[t]})}),n.count=e.length,n);if("string"==typeof i)return i;try{return JSON.stringify(i,o())||"undefined"}catch(i){return"error happen when aegis stringify: \n "+i.message+" \n "+i.stack}};function t(){var s=this;this.emit=function(e,t){if(s){var n;if(null!=(i=s.eventsList[e])&&i.length)for(var i=i.slice(),o=0;o<i.length;o++){n=i[o];try{var r=n.callback.apply(s,[t]);if(1===n.type&&s.remove(e,n.callback),!1===r)break}catch(e){throw e}}return s}},this.eventsList={}}function l(e,t){return"string"==typeof e?e.split("?")[t?1:0]||"":e}function H(e){return"string"==typeof e&&e.startsWith("//")?"undefined"!=typeof location&&"https:"===location.protocol:/^https/.test(e)}function c(e,t,n){var i,o;try{if("function"==typeof(null==t?void 0:t.retCodeHandler))return{code:void 0===(r=(o=t.retCodeHandler(e,null==n?void 0:n.url,null==n?void 0:n.ctx)||{}).code)?"unknown":r,isErr:o.isErr};"string"==typeof e&&(e=JSON.parse(e)),"function"==typeof(null==(i=null==t?void 0:t.ret)?void 0:i.join)&&(M=[].concat(t.ret.map(function(e){return e.toLowerCase()})));var r,s=Object.getOwnPropertyNames(e).filter(function(e){return-1!==M.indexOf(e.toLowerCase())});return s.length?{code:""+(r=Number(e[s[0]])),isErr:0!==r}:{code:"unknown",isErr:!1}}catch(e){return{code:"unknown",isErr:!1}}}function f(r,s){void 0===s&&(s=3);var o,a,l,u="";return Array.isArray(r)?(u+="[",o=r.length,r.forEach(function(e,t){var n,i;u=(u+="object"==typeof e&&1<s?f(e,s-1):(i="",i+="undefined"==(n=typeof(e=e))||"symbol"==n||"function"==n?"null":"string"==n||"object"==n?'"'+e+'"':e))+(t===o-1?"":",")}),u+="]"):r instanceof Object?(u="{",a=Object.keys(r),l=a.length,a.forEach(function(e,t){var n,i,o;"object"==typeof r[e]&&1<s?u+='"'+e+'":'+f(r[e],s-1):u+=(n=r[e=e],o="","string"==(i=typeof n)||"object"==i?o+='"'+e+'":"'+n+'"':"function"==typeof n?o+='"'+e+'":"function '+n.name+'"':"symbol"==typeof n?o+='"'+e+'":"symbol"':"number"!=typeof n&&"boolean"!=i||(o+='"'+e+'": '+n),o),u+=t===l-1||t<l-1&&void 0===r[a[t+1]]?"":","}),u+="}"):u+=r,u}var y,a,u,v,d,M=["ret","retcode","code","errcode"],o=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}},b=function(e){if("string"==typeof e)return e;try{return e instanceof Error?(JSON.stringify(e,o(),4)||"undefined").replace(/"/gim,""):JSON.stringify(e,o(),4)||"undefined"}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}};(P=y=y||{}).INFO_ALL="-1",P.API_RESPONSE="1",P.INFO="2",P.ERROR="4",P.PROMISE_ERROR="8",P.AJAX_ERROR="16",P.SCRIPT_ERROR="32",P.IMAGE_ERROR="64",P.CSS_ERROR="128",P.CONSOLE_ERROR="256",P.MEDIA_ERROR="512",P.RET_ERROR="1024",P.REPORT="2048",P.PV="4096",P.EVENT="8192",P.PAGE_NOT_FOUND_ERROR="16384",P.WEBSOCKET_ERROR="32768",(P=a=a||{})[P.android=1]="android",P[P.ios=2]="ios",P[P.windows=3]="windows",P[P.macos=4]="macos",P[P.linux=5]="linux",P[P.devtools=6]="devtools",P[P.other=100]="other",(P=u=u||{})[P.unknown=100]="unknown",P[P.wifi=1]="wifi",P[P.net2g=2]="net2g",P[P.net3g=3]="net3g",P[P.net4g=4]="net4g",P[P.net5g=5]="net5g",P[P.net6g=6]="net6g",(P=v=v||{}).LOG="log",P.SPEED="speed",P.PERFORMANCE="performance",P.OFFLINE="offline",P.WHITE_LIST="whiteList",P.VITALS="vitals",P.PV="pv",P.CUSTOM_PV="customPV",P.EVENT="event",P.CUSTOM="custom",P.SDK_ERROR="sdkError",P.SET_DATA="setData",P.LOAD_PACKAGE="loadPackage",(P=d=d||{}).production="production",P.development="development",P.gray="gray",P.pre="pre",P.daily="daily",P.local="local",P.test="test",P.others="others";function O(n,i){var o,r=[],s=n.config;return n.lifeCycle.on("destroy",function(){r.length=0}),function(e,t){if(Array.isArray(e)?r=r.concat(e):r.push(e),i&&r.length>=i||n.sendNow&&0<r.length)return r=X(r),t(r.splice(0,r.length)),void(o&&clearTimeout(o));o&&clearTimeout(o),o=setTimeout(function(){o=null,0<(r=X(r)).length&&t(r.splice(0,r.length))},s.delay)}}function B(e,t){return Array.isArray(e)?t(e.map(function(e){return p(p({},e),{msg:"string"==typeof e.msg?e.msg:[].concat(e.msg).map(b).join(" ")})})):t([p(p({},e),{msg:"string"==typeof e.msg?e.msg:b(e.msg)})])}function J(r,s){return function(e,t){var n=Array.isArray(e),i=n?e:[e],o=(r.lifeCycle.emit("beforeRequest",e),r.config.beforeRequest);(i="function"==typeof o?i.map(function(t){try{var e=o({logs:t,logType:s});return(null==e?void 0:e.logType)===s&&null!=e&&e.logs?e.logs:!1!==e&&t}catch(e){return t}}).filter(function(e){return!1!==e}):i).length&&(i=function(e,t){if(!Array.isArray(e)||e.length<=1)return e;var n=[],i=[];return!(i="string"==typeof t?[t]:t)||i.length<=0||(i.forEach(function(t){e.forEach(function(e){null!=e&&e[t]&&n.push(t)})}),0<n.length&&(e=e.map(function(e){var t={};return n.forEach(function(e){t[e]=""}),p(p({},t),e)}))),e}(i,["ext1","ext2","ext3","level","trace","tag","seq"]),t(n?i:i[0]))}}function V(o){return function(e,t){o.lifeCycle.emit("modifyRequest",e);var n=o.config.modifyRequest;if("function"==typeof n)try{var i=n(e);"object"==typeof i&&"url"in i&&(e=i)}catch(e){console.error(e)}t(e)}}function W(i){return function(e,t){i.lifeCycle.emit("afterRequest",e);var n=i.config.afterRequest;"function"==typeof n&&!1===n(e)||t(e)}}function E(n){if(n&&n.reduce&&n.length)return 1===n.length?function(e,t){n[0](e,t||ee)}:n.reduce(function(n,i){return function(e,t){return void 0===t&&(t=ee),n(e,function(e){return null==i?void 0:i(e,t)})}});throw new TypeError("createPipeline need at least one function param")}function h(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 i(){try{var e=getCurrentPages(),t=e[e.length-1]||{},n=(i=t.options,Object.keys(i).length?"?"+Object.keys(i).map(function(e){return e+"="+i[e]}).join("&"):"");return t.route?t.route+n:""}catch(e){return""}var i}function G(e,t){if("string"==typeof e&&"string"==typeof t){if(e===t)return 1;for(var n=e.split("."),i=t.split("."),o=Math.max(n.length,i.length),r=0;r<o;r++){var s=~~n[r],a=~~i[r];if(s<a)return;if(a<s)return 1}}}function g(e){return te=te||S.getSystemInfoSync().SDKVersion,G(te,"1.1.1")&&S.canIUse?S.canIUse(e):!!S[e]}function m(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},i=u.unknown,o=0;o<Object.keys(n).length;o++){var r=Object.keys(n)[o];if(null!=(t=n[r])&&t.test(e)){i=u[r];break}}return i}function w(e){var t=e.apiName,n=x[t];n?n.hackReq.addCallback(e):(n=wx[t],x[t]={hackReq:new ce(e),originApi:n}),x[t]}var r,K,n,$,z,X=function(e){return e.filter(function(n,i){return"static"!==n.type||!e.find(function(e,t){return n.url===e.url&&200===n.status&&i<t})})},Q=function(e){e.level===y.INFO_ALL&&(e.level=y.INFO)},Y=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:y.INFO,msg:""})})},Z=function(i){return function(e){return i.sendPipeline([function(e,n){return n({url:i.config.url||"",data:D(Y(e)),method:"post",contentType:"application/json",type:v.LOG,log:e,requestConfig:{timeout:5e3},success:function(){var t=i.config.onReport;"function"==typeof t&&e.forEach(function(e){t(e)}),"function"==typeof n&&n([])},fail:function(e){"403 forbidden"===e&&i.destroy()}})}],v.LOG)(e)}},ee=function(){},P=(Object.defineProperty(_.prototype,"__version__",{get:function(){return console.warn("__version__ has discard, please use version"),"1.36.1"},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"LogType",{get:function(){return console.warn("LogType has discard, please use logType"),y},enumerable:!1,configurable:!0}),_.prototype.init=function(e){this.setConfig(e);for(var t=0;t<_.installedPlugins.length;t++)try{_.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},_.prototype.setConfig=function(e){Object.assign(this.config,e);var e=this.config,t=e.id,n=e.uin,i=e.version,o=e.ext1,r=e.ext2,s=e.ext3,a=e.aid,l=e.env,u=void 0===l?"production":l,l=e.pageUrl,e=this.bean.id!==t||this.bean.uin!==n||this.bean.aid!==a;return this.bean.id=t||"",this.bean.uin=n||"",this.bean.version=i||"1.36.1",this.bean.aid=a||"",this.bean.env=function(){switch(u){case d.production:case d.development:case d.gray:case d.pre:case d.daily:case d.local:case d.test:case d.others:return 1;default:return}}()?u:d.others,l&&this.extendBean("from",encodeURIComponent(l)),o&&this.extendBean("ext1",encodeURIComponent(o)),r&&this.extendBean("ext2",encodeURIComponent(r)),s&&this.extendBean("ext3",encodeURIComponent(s)),e&&this.lifeCycle.emit("onConfigChange",this.config),this.config},_.use=function(e){-1===_.installedPlugins.indexOf(e)&&e.aegisPlugin&&_.installedPlugins.push(e)},_.unuse=function(e){e=_.installedPlugins.indexOf(e);-1!==e&&_.installedPlugins.splice(e,1)},_.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:y.INFO,msg:e};1===e.length&&e[0].msg&&Object.assign(n,p({},e[0]),{level:y.INFO}),this.normalLogPipeline(n)},_.prototype.infoAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:y.INFO_ALL,msg:e};1===e.length&&e[0].msg&&Object.assign(n,p({},e[0]),{level:y.INFO_ALL}),this.normalLogPipeline(n)},_.prototype.report=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:y.REPORT,msg:e};1===e.length&&e[0].msg&&Object.assign(n,p({},e[0])),this.normalLogPipeline(n)},_.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:y.ERROR,msg:e};1===e.length&&e[0].msg&&Object.assign(n,p({},e[0]),{level:y.ERROR}),this.normalLogPipeline(n)},_.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},_.prototype.reportPv=function(n){var i,o=this;n&&(console.warn("reportPv is deprecated, please use reportEvent"),i=""+Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+o.bean[e]}).join("&"),this.sendPipeline([function(e,t){t({url:o.config.url+"/"+n+"?"+i,addBean:!1,type:v.CUSTOM_PV,fail:function(e){"403 forbidden"===e&&o.destroy()}})}],v.CUSTOM_PV)(null))},_.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?this.eventPipeline(e):console.warn("reportEvent params error"))},_.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")},_.prototype.reportT=function(e){var t=e.name,n=e.duration,i=e.ext1,i=void 0===i?"":i,o=e.ext2,o=void 0===o?"":o,r=e.ext3,r=void 0===r?"":r,e=e.from;if("string"==typeof t&&"number"==typeof n&&"string"==typeof i&&"string"==typeof o&&"string"==typeof r){if(!(n<0||6e4<n))return this.submitCustomTime(t,n,i,o,r,void 0===e?"":e);console.warn("reportTime: duration must between 0 and 60000")}else console.warn("reportTime: params error")},_.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")},_.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")},_.prototype.submitCustomTime=function(e,t,n,i,o,r){this.customTimePipeline({name:e,duration:t,ext1:n||this.config.ext1,ext2:i||this.config.ext2,ext3:o||this.config.ext3,from:r||void 0})},_.prototype.extendBean=function(e,t){this.bean[e]=t},_.prototype.sendPipeline=function(e,t){var n,r=this;return E(s([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}},J(n=this,t)],e,[V(this),function(i,o){r.request(i,function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];r.failRequestCount=0,o({isErr:!1,result:t,logType:null==i?void 0:i.type,logs:null==i?void 0:i.log}),null!=(e=null==i?void 0:i.success)&&e.call.apply(e,s([i],t))},function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];10<=++r.failRequestCount&&r.destroy(),o({isErr:!0,result:t,logType:null==i?void 0:i.type,logs:null==i?void 0:i.log}),null!=(e=null==i?void 0:i.fail)&&e.call.apply(e,s([i],t))})},W(this)]))},_.prototype.send=function(e,o,r){var t=this;return E([V(this),function(n,i){t.request(n,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i({isErr:!1,result:e,logType:n.type,logs:n.log}),null!=o&&o.apply(void 0,e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i({isErr:!0,result:e,logType:n.type,logs:n.log}),null!=r&&r.apply(void 0,e)})},W(this)])(e)},_.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},_.prototype.sendSDKError=function(e){var n=this;this.sendPipeline([function(e,t){t({url:n.config.url+"?id=1085&msg[0]="+encodeURIComponent(b(e))+"&level[0]=2&from="+n.config.id+"&count=1&version="+n.config.id+"(1.36.1)",addBean:!1,method:"get",type:v.SDK_ERROR,log:e})}],v.SDK_ERROR)(e)},_.prototype.destroy=function(e){void 0===e&&(e=!1);var t,n,i=_.instances.indexOf(this);-1!==i&&_.instances.splice(i,1);for(var o=_.installedPlugins.length-1;0<=o;o--)try{_.installedPlugins[o].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 r=this;r.constructor!==Object&&h(r,this),r=Object.getPrototypeOf(r););0===_.instances.length&&(i=Object.getPrototypeOf(this).constructor,h(i),h(_))}},_.version="1.36.1",_.instances=[],_.logType=y,_.environment=d,_.installedPlugins=[],_),R=(j.prototype.patch=function(e){this.canUse(e)&&this.exist(e)&&(this.instances.push(e),this.triggerInit(e),this.triggerOnNewAegis(e))},j.prototype.unpatch=function(e){e=this.instances.indexOf(e);-1!==e&&(this.instances.splice(e,1),0===this.instances.length&&this.uninstall())},j.prototype.countInstance=function(){return this.instances.length},j.prototype.uninstall=function(){var e;null!=(e=null==(e=this.option)?void 0:e.destroy)&&e.apply(this)},j.prototype.walk=function(n){var i=this;this.instances.forEach(function(e){var t=i.canUse(e);t&&n(e,t)})},j.prototype.canUse=function(e){e=this.getConfig(e);return!(!e||"object"!=typeof e)||!!e},j.prototype.getConfig=function(e){return null==(e=e.config)?void 0:e[this.name]},j.prototype.exist=function(e){return-1===this.instances.indexOf(e)},j.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)))},j.prototype.triggerOnNewAegis=function(e){var t;null!=(t=null==(t=this.option)?void 0:t.onNewAegis)&&t.call(this.option,e,this.getConfig(e))},j),S=wx||qq,te="",ne=new R({name:"offlineLog",onNewAegis:function(o){if(S.getFileSystemManager)try{var e=o.config,t=e.id,r=void 0===t?"":t,n=e.uin,s=void 0===n?0:n,i=e.offlineUrl,a=void 0===i?"":i,l=e.offlineLogLimit,u=new ie({limit:l});o.lifeCycle.on("beforeWrite",function(e){u.save2Offline(e=void 0===e?[]:e,o.config)}),u.ready(function(t){var e=(o.bean||{}).aid,i=void 0===e?"":e;!t&&r&&(s||i)&&o.send({url:a+"/offlineAuto",type:v.OFFLINE,log:v.OFFLINE},function(e){var n=(null==e?void 0:e.data).secretKey;n&&!t&&u.getLogs({id:r,uin:s},function(e,t){e?console.error(e):o.send({url:a+"/offlineLog",data:{logs:t,secretKey:n,id:r,uin:s,aid:i},method:"post",type:v.OFFLINE,log:t},function(){u.clearLogs()})})})})}catch(o){console.error(o)}else console.warn("[aegis-mp-sdk]unsupport getFileSystemManager offline log not work!")}}),ie=(Oe.prototype.getLogs=function(e,t){var n=this.fileSystem,i=this.filePath;n.readFile({filePath:i,encoding:"utf8",fail:function(e){console.error(e)},success:function(e){e=e.data,e=(void 0===e?"":e).toString().split("\n").filter(function(e){return e}).map(function(e){return JSON.parse(e)});t(null,e)}})},Oe.prototype.checkLimit=function(o,r){void 0===r&&(r=function(){});var s=this.fileSystem,a=this.filePath,l=this.limitSize;s.readFile({filePath:a,encoding:"utf8",success:function(e){e=e.data,e=void 0===e?"":e;if((e=e.toString()+o).length>l){for(var t=e.split("\n"),n="",i=t.length-1;0<=i&&!(t[i]&&(n=t[i]+"\n"+n).length>l);i--);s.writeFile({filePath:a,data:n,success:r})}else s.appendFile({data:o,filePath:a,encoding:"utf8",success:r,fail:function(e){console.error(e)}})}})},Oe),oe=new R({name:"device",onNewAegis:function(t){return e=this,l=function(){return q(this,function(e){return this.setSystemInfo(t),this.refreshNetwork(t),this.setNetworkChange(t),[2]})},new(a=(a=s=void 0)||Promise)(function(n,t){function i(e){try{r(l.next(e))}catch(e){t(e)}}function o(e){try{r(l.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?n(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(i,o)}r((l=l.apply(e,s||[])).next())});var e,s,a,l},setSystemInfo:function(s){var a=this;try{g("getSystemInfo")&&S.getSystemInfo({success:function(e){var t=e.platform,n=e.model,i=e.windowHeight,o=e.windowWidth,r=e.screenWidth,r=void 0===r?0:r,e=e.screenHeight,e=void 0===e?0:e;s.extendBean("platform",a.getPlatFormType(t)),s.extendBean("model",n),s.extendBean("vp",Math.round(o)+" * "+Math.round(i)),s.extendBean("sr",Math.round(r)+" * "+Math.round(e))}})}catch(s){}},getPlatFormType:function(e){for(var t,n={android:/android/i,ios:/ios/i,windows:/windows/i,macos:/mac/i,devtools:/devtools/i},i=a.other,o=0;o<Object.keys(n).length;o++){var r=Object.keys(n)[o];if(null!=(t=n[r])&&t.test(e)){i=a[r];break}}return i},setNetworkChange:function(t){g("onNetworkStatusChange")&&S.onNetworkStatusChange(function(e){e=m(e.networkType);t.extendBean("netType",e)})},setNetworkType:function(t){g("getNetworkType")&&S.getNetworkType({success:function(e){e=m(e.networkType);t.extendBean("netType",e)}})},refreshNetwork:function(e){var t=this;this.timer&&clearTimeout(this.timer),this.setNetworkType(e),this.timer=setTimeout(function(){t.refreshNetwork(e)},1e4)}}),re=S.request,P=(e(U,z=P),Object.defineProperty(U.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(i()):"from="+encodeURIComponent(i())},enumerable:!1,configurable:!0}),U.prototype.initOfflineLog=function(){U.use(ne)},U.prototype.uploadLogs=function(e,t){this.lifeCycle.emit("uploadLogs",e=void 0===e?{}:e,t=void 0===t?{}:t)},U.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(i()),this.send({url:this.config.url+"/"+e+"?"+t,addBean:!1,type:v.CUSTOM_PV,log:v.CUSTOM_PV},function(){},function(){}))},U.sessionID="session-"+Date.now(),U.asyncPluginIndex=0,U),se=new R({name:"aid",onNewAegis:function(t){this.initAid(function(e){t.bean.aid=e,t.config.aid=e})},initAid:function(t){S.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)});S.setStorage({key:"AEGIS_ID",data:e,success:function(){t(e)}})}})}}),T=(A.prototype.addCallback=function(e){e&&this.callbacks.push(e)},A.prototype.prefixHandler=function(e){return p(p({},e),{aegisRequestStartTime:+new Date})},A.prototype.successHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null!=(t=e.success)&&t.call(e,n,i)}catch(e){}}),null!=(e=i.success)&&e.call(i,n,i)},A.prototype.failHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null!=(t=e.fail)&&t.call(e,n,i)}catch(e){}}),null!=(e=i.fail)&&e.call(i,n,i)},A.prototype.completeHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null!=(t=e.complete)&&t.call(e,n,i)}catch(e){}}),null!=(e=i.complete)&&e.call(i,n,i)},A.prototype.override=function(){try{this.defineApiProperty()}catch(e){console.warn("cannot override `"+this.apiName+"`, error is: "+e)}finally{this.isOverride=!0}},A),k=wx||qq,ae=null==(fe=k.cloud)?void 0:fe.callFunction,le=(e(C,$=T),C.prototype.defineApiProperty=function(){var e=this;k.cloud&&k.cloud.callFunction&&Object.defineProperty(k.cloud,"callFunction",{get:function(){return e.hackHandler.bind(e)}})},C.prototype.hackHandler=function(e){var i=this,o=this.prefixHandler(e);return new Promise(function(t,n){ae(p(p({},o),{success:function(e){i.successHandler(e,o),t(e)},fail:function(e){i.failHandler(e,o),n(e)},complete:function(e){i.completeHandler(e,o)}}))})},C),ue=wx||qq,x={},ce=(e(L,n=T),L.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(ue,this.apiName,{get:function(){return e.hackHandler.bind(e)}})},L.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e),e=null==(e=x[this.apiName])?void 0:e.originApi;return null==e?void 0:e(p(p({},n),{success:function(e){t.successHandler(e,n)},fail:function(e){t.failHandler(e,n)},complete:function(e){t.completeHandler(e,n)}}))},L),fe=new R({name:"reportApiSpeed",override:!1,onNewAegis:function(e){this.override||(this.override=!0,this.hackRequest(e.config),this.overrideCallFunction(e.config))},hackRequest:function(s){var a=this;w({apiName:"request",success:function(e,t){var n,i,o,r;s.hostUrl&&-1<t.url.indexOf(s.hostUrl)||(n={method:t.method||"get",url:l(t.url),duration:Date.now()-t.aegisRequestStartTime,status:e.statusCode||0,nextHopProtocol:"",isHttps:H(t.url),type:"fetch"},i=null==(i=s.api)?void 0:i.apiDetail,o=(r=c(e.data,s.api,{url:t.url,ctx:e})||{}).code,r=r.isErr,t="req url: "+n.url+" \n \nreq method: "+n.method+" \n \nreq param: "+(i?b(t.data):"")+" \n \nres duration: "+n.duration+"ms \n \nres status: "+(e.statusCode||0)+" \n \nres retcode: "+o+" \n \nres data: "+(i?f(e.data):""),a.publishNormalLog({msg:t,level:y.API_RESPONSE,ctx:e}),n.ret=o,n.isErr=+r,a.publishSpeedLog(n),r&&a.publishNormalLog({msg:t,level:y.RET_ERROR,ctx:e}))},fail:function(e,t){s.hostUrl&&-1<t.url.indexOf(s.hostUrl)||(t={method:t.method||"get",url:l(t.url),duration:Date.now()-t.aegisRequestStartTime,status:0,nextHopProtocol:"",isHttps:H(t.url),type:"fetch"},a.publishSpeedLog(t))}})},overrideCallFunction:function(a){var l=this;new le({apiName:"callFunction",success:function(e,t){var n,i,o={method:"call",url:"wx.cloud.callFunction."+t.name,duration:Date.now()-t.aegisRequestStartTime,status:200,nextHopProtocol:"",type:"fetch",errMsg:e.errMsg,isHttps:!0},r=null==(r=a.api)?void 0:r.apiDetail,r="req url: "+o.url+"\n \nreq type: "+o.type+"\n \nres duration: "+o.duration+"ms \n \nres errMsg: "+o.errMsg+"\n \nres data: "+(r?f(e.result):"")+"\n ",s=(l.publishNormalLog({msg:r,level:y.API_RESPONSE,ctx:e}),!1),s=(t="function"==typeof(null==(n=a.api)?void 0:n.retCodeCloudFunctionHandler)?(i=(n=a.api.retCodeCloudFunctionHandler(e.result,t.name,t,e)||{}).code,void 0!==(t=n.isErr)&&t):(i=(n=c(e.result,a.api,{url:o.url,ctx:e})||{}).code,n.isErr),o.ret=i,t);o.isErr=+s,l.publishSpeedLog(o),s&&l.publishNormalLog({msg:r,level:y.RET_ERROR,ctx:e})},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};l.publishSpeedLog(t)}})},publishSpeedLog:function(t){this.$walk(function(e){e.speedLogPipeline(t)})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})}}),pe=wx||qq,de=pe.connectSocket,he=(be.prototype.addConfig=function(e){var t=e.send,e=e.onError;t&&this.sends.push(t),e&&this.onErrors.push(e)},be.prototype.toHack=function(t){var o=this,n=(this.onErrors.forEach(function(e){t.onError(e)}),t.send);return Object.defineProperty(t,"send",{get:function(){return function(i){return new Promise(function(e){n.call(t,p(p({},i),{fail:function(n){o.sends.forEach(function(e){var t;null!=(t=e.fail)&&t.call(e,n,i)}),e(n)}}))})}}}),t},be),ge=(e(N,K=T),N.prototype.addTaskConf=function(e){this.taskHack.addConfig(e)},N.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(pe,"connectSocket",{get:function(){return e.hackHandler.bind(e)}})},N.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e),e=de(p(p({},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},N),T=new R({name:"onError",onNewAegis:function(e){var t=S.getSystemInfoSync().SDKVersion;this.listenError(),this.hackNetWork(e),e.config.websocketHack&&G(t,"1.7.0")&&this.hackWsConnect()},listenError:function(){var t=this;"function"==typeof S.onError&&S.onError(function(e){e&&t.publishErrorLog({msg:e,level:y.ERROR})}),g("onUnhandledRejection")&&S.onUnhandledRejection(function(e){e=e.reason;!e||-1<JSON.stringify(e).indexOf("request:fail")||t.publishErrorLog({msg:e,level:y.PROMISE_ERROR})}),g("onPageNotFound")&&S.onPageNotFound(function(e){e&&t.publishErrorLog({msg:e,level:y.PAGE_NOT_FOUND_ERROR})})},publishErrorLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},hackNetWork:function(e){for(var n=this,i=e.config,t=0,o=[{apiName:"request",complete:function(e,t){return n.requestCompleteError(e,t,i)}},{apiName:"uploadFile",complete:function(e,t){return n.uploadFileCompleteError(e,t,i)}},{apiName:"downloadFile",complete:function(e,t){return n.downloadFileCompleteError(e,t,i)}}];t<o.length;t++){var r=o[t],s=r.apiName,r=r.complete;w({apiName:s,complete:r})}},requestCompleteError:function(e,t,n){var i,o=e.errMsg,r=e.statusCode;n.hostUrl&&-1<(null==(i=t.url)?void 0:i.indexOf(n.hostUrl))||(i=this.getErrorType({errMsg:o,statusCode:r}))&&this.publishNetWorkError({apiName:"request",opts:t,res:e,config:n,type:i})},downloadFileCompleteError:function(e,t,n){var i=e.errMsg,o=e.statusCode,r=e.filePath,e=e.tempFilePath,s=this.getErrorType({errMsg:i,statusCode:o});s&&(n=null==(n=n.api)?void 0:n.apiDetail,this.publishErrorLog({msg:"AJAX_ERROR: downloadFile "+s+"\n \nres status: "+(o||0)+"\n \nres duration: "+(Date.now()-t.aegisRequestStartTime)+"ms\n \nres filePath: "+r+"\n \nres tempFilePath: "+e+"\n \nreq url: "+t.url+"\n \nreq method: "+(t.method||"get")+"\n \nreq param: "+(n?b(t.data):"")+"\n \nerrMsg: "+i.slice(0,1e3),level:y.AJAX_ERROR}))},uploadFileCompleteError:function(e,t,n){var i=e.errMsg,o=e.statusCode,i=this.getErrorType({errMsg:i,statusCode:o});i&&this.publishNetWorkError({apiName:"uploadFile",opts:t,res:e,config:n,type:i})},publishNetWorkError:function(e){var t=e.apiName,n=e.opts,i=e.res,o=e.config,e=e.type,r=i.errMsg,s=i.statusCode,a=i.data,l=null==(l=o.api)?void 0:l.apiDetail,u="wx.cloud.callFunction."+n.url,o=c(a,o.api,{url:u,ctx:i}).code;this.publishErrorLog({msg:"AJAX_ERROR: "+t+" "+e+"\n \nres status: "+(s||0)+"\n \nres retcode: "+o+"\n \nres duration: "+(Date.now()-n.aegisRequestStartTime)+"ms\n \nres data: "+(l?b(a):"")+"\n \nreq url: "+n.url+"\n \nreq method: "+(n.method||"get")+"\n \nreq param: "+(l?b(n.data):"")+"\n \nerrMsg: "+r.slice(0,1e3),level:y.AJAX_ERROR})},getErrorType:function(e){var t=e.errMsg,e=e.statusCode,n="";return-1<t.indexOf("timeout")||-1<t.indexOf("超时")?n="timeout":400<=e?n="error":(-1<t.indexOf("fail")||!e||e<0)&&(n="failed"),n},hackWsConnect:function(){var e,t,n=this;w({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,r?r.addCallback(e):r=new ge(e),t&&r.addTaskConf(t)},publishSocketError:function(e){e&&this.publishErrorLog({msg:e.errMsg,level:y.WEBSOCKET_ERROR})}}),me=new R({name:"reportAssetSpeed",isStart:!1,onNewAegis:function(e){this.isStart||(this.isStart=!0,this.start(e))},start:function(){var t=this;S.getPerformance&&S.getPerformance().createObserver(function(e){e=e.getEntries();null!=e&&e.forEach(function(e){"number"!=typeof e.duration||e.duration<=0||t.publishAssetLog(e)})}).observe({entryTypes:["resource"]})},generateLog:function(e){return{url:""+l(e.uri),method:"get",duration:Math.round(100*e.duration)/100,status:200,type:"static",isHttps:!0,urlQuery:"",nextHopProtocol:"",domainLookup:0,connectTime:0}},publishAssetLog:function(t){var n=this;this.$walk(function(e){e.speedLogPipeline(n.generateLog(t))})}}),ye=["onLaunch","onHide","onError","onLoad","onReady","onShow","onUnload"],ve=new R({name:"pagePerformance",pageNavigationStartTime:{},onNewAegis:function(e){try{g("getPerformance")&&this.reportPerformance(e),this.setPagePV(e),this.reportSetDataTiming(e)}catch(e){}},reportPerformance:function(u){var c=this,e=S.getPerformance(),e=null==e?void 0:e.createObserver(function(e){var t={},n=null==(n=e.getEntriesByName("appLaunch"))?void 0:n[0],i=null==(i=e.getEntriesByName("firstRender"))?void 0:i[0],o=null==(o=e.getEntriesByName("evaluateScript"))?void 0:o[0],r=null==(r=e.getEntriesByName("route"))?void 0:r[0],s=null==(s=null==(s=e.getEntriesByName("firstPaint"))?void 0:s[0])?void 0:s.startTime,a=null==(a=(null==(a=e.getEntriesByName("firstPaint"))?void 0:a[0])||(null==(a=e.getEntriesByName("route"))?void 0:a[0])||(null==(a=e.getEntriesByName("appLaunch"))?void 0:a[0]))?void 0:a.pageId,l=null==(e=(null==(l=e.getEntriesByName("route"))?void 0:l[0])||(null==(l=e.getEntriesByName("appLaunch"))?void 0:l[0]))?void 0:e.startTime;a&&(c.pageNavigationStartTime[a]=null,l&&(c.pageNavigationStartTime[a]=l)),n&&(t.appLaunch=n.duration),i&&(t.firstScreenTiming=i.duration),o&&(t.scriptEvaluateTiming=o.duration),r&&(t.pageRouteTiming=r.duration),s&&l?t.firstPaintTiming=Math.max(s-l,0):s&&c.pageNavigationStartTime[a]&&(t.firstPaintTiming=Math.max(s-c.pageNavigationStartTime[a],0)),c.publish(t,u)});null!=e&&e.observe({entryTypes:["navigation","render","script"]})},publish:function(t,n){var e,i,o=[],r=n.config,s=-1===(null==(e=n.config.performanceUrl)?void 0:e.indexOf("?"))?"?":"&";for(i in t)o.push(i+"="+t[i]);"function"==typeof r.urlHandler?this.$walk(function(e){e.send({url:n.config.performanceUrl+s+o.join("&")+"&from="+(encodeURIComponent(r.urlHandler())||window.location.href),beanFilter:["from"],type:v.PERFORMANCE,log:t})}):this.$walk(function(e){e.send({url:n.config.performanceUrl+s+o.join("&"),type:v.PERFORMANCE,log:t})})},setPagePV:function(e){var t=this;S.onAppRoute&&S.onAppRoute(function(e){"appLaunch"!==e.openType&&(t.$walk(function(e){e.send({url:""+e.config.pvUrl,type:v.PV})}),t.reportPageLoaded(e))})},reportPageLoaded:function(e){e="infoType: behaviorBacktracking\ndataType: pageLoadAndRoute\npageLoadedPath: "+e.path+"\nopenType: "+e.openType;this.publishNormalLog({msg:e,level:y.INFO})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},reportSetDataTiming:function(t){var e,o,r,s,n,a,l,u,c,f=this,i=t.config,i=i.setDataReportConfig||(null==(i=i.pagePerformance)?void 0:i.setDataReportConfig)||{};!0!==i.disabled&&(e=i.timeThreshold,o=!1!==i.withDataPaths,r=e&&0<+e?+e:30,s=E([O(t,10),function(e){e=e.map(function(e){return{type:v.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:v.SET_DATA,log:e})}]),n=Page,a=Component,l=function(r,e){var s=0;return null!=r&&r.data?(e.forEach(function(e){for(var t=r.data[e[0]],n=1,i=e.length;n<i;n++)t[e[n]]&&(t=t[e[n]]);var o="";try{o=JSON.stringify(t)}catch(e){o=""}s+=2*(void 0===o?"":o).replace(/[\u4e00-\u9fa5]/g,"aa").length}),s=Math.min(s,10485760)):s},u=function(e,t){var n=t.updateStartTimestamp,i=t.updateEndTimestamp,t=t.dataPaths,t=void 0===t?[]:t,i=i-n;isNaN(i)||i<r||(n={from:e.is,duration:i},o&&0<t.length&&Object.assign(n,{dataPaths:t.slice(0,30),size:l(e,t)}),s(n))},c=function(i){var e="infoType: behaviorBacktracking\ndataType: tapEvent"+Object.keys(i[0]).reduce(function(e,t){var n="";try{n=t+": "+JSON.stringify(i[0][t])}catch(e){n=""}return e+"\n"+n},"");f.publishNormalLog({msg:e,level:y.INFO})},Page=function(t){var e=t.onReady;return t.onReady=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:o},function(e){u(t,e)}),null==e?void 0:e.call(this)},Object.keys(t).forEach(function(e){var n;"function"!=typeof t[e]||ye.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:o},function(e){u(t,e)}),null==n?void 0:n.call(this)}):(i=e.attached,e.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:o},function(e){u(t,e)}),null==i?void 0:i.call(this)});var n,i,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)})}),a(e)})}}),R=new R({name:"reportLoadPackageSpeed",isLoaded:!1,onNewAegis:function(e){this.isLoaded||(this.isLoaded=!0,this.start(e))},start:function(){var t=this;S.getPerformance&&S.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:v.LOAD_PACKAGE,packageName:e.packageName,size:Math.round(100*e.packageSize)/100,duration:Math.round(100*e.duration)/100}]},publishPackageLog:function(n){var i=this;this.$walk(function(e){var t=i.generateLog(n);e.send({url:e.config.setDataReportUrl+"?payload="+encodeURIComponent(JSON.stringify({miniProgramData:t})),type:v.LOAD_PACKAGE,log:t})})}});function N(e){e=K.call(this,e)||this;return e.taskHack=new he,e}function be(){this.onErrors=[],this.sends=[]}function L(){return null!==n&&n.apply(this,arguments)||this}function C(){return null!==$&&$.apply(this,arguments)||this}function A(e){this.callbacks=[],this.isOverride=!1;var t=e.apiName;this.apiName=t,this.isOverride||this.override(),this.callbacks.push(e)}function U(e){var i,o,r,f=z.call(this,e)||this;f.originRequest=re,f.speedLogPipeline=E([(o=f.config,r={},function(e,t){var n,i;o.speedSample?(i="object"==typeof o.repeat?o.repeat:{repeat:o.repeat},n=+i.speed||+i.repeat||5,Array.isArray(e)?(i=e.filter(function(e){var t=!r[e.url]||r[e.url]<n;return r[e.url]=1+~~r[e.url],t})).length&&t(i):(!r[e.url]||r[e.url]<n)&&(r[e.url]=1+~~r[e.url],t(e))):t(e)}),O(f),function(t,n){g("getNetworkType")?S.getNetworkType({success:function(e){e=m(e.networkType);i.extendBean("netType",e),n(t)}}):n(t)},function(e,t){f.lifeCycle.emit("beforeReportSpeed",e);var n=f.config.beforeReportSpeed;if((e="function"==typeof n?e.filter(function(e){return!1!==n(e)}):e).length)return t(e)},J(i=f,v.SPEED),function(e){var t,n,i,o;f.send({url:""+f.config.speedUrl,method:"post",data:(e=e,t=f.bean,i={fetch:[],static:[]},o={},Array.isArray(e)?e.forEach(function(e){var t;null!=(t=i[e.type])&&t.push(e)}):null!=(n=i[e.type])&&n.push(e),o.payload=JSON.stringify(p({duration:i},t)),o)})}]),f.requestQueue=[],f.requesting=!1,f.request=function(e,t,n){if(e.url&&f.bean.id)if(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(String(f.bean.aid))){if(!(f.requesting||g("getNetworkType")&&void 0===f.bean.netType)){f.requesting=!0;var i,o=e.url,r=(f.config.whiteListUrl===o&&(i=t,t=function(e){null!=i&&i(JSON.stringify(e.data))}),!1!==e.addBean&&(o=o+(-1===o.indexOf("?")?"?":"&")+f.getBean),e.method||"get"),s=function(){f.requesting=!1;var e=f.requestQueue.shift();e&&f.request(e.options,e.success,e.fail)},a=e,l=f.config.onBeforeRequest;if(!(a=l?l(e,f):a)||!a.url)return l="",a&&a.url||(l="Sending request blocked. Please handle the parameters reasonably, options.url is necessary",console.log(l)),null!=n&&n(l),s(),!1;l=f.config.enableHttp2||!1;return"get"===r?(r=o,u=a.data,o="string"!=typeof r?"":"object"==typeof u&&u?(c=Object.getOwnPropertyNames(u).map(function(e){var t=u[e];return e+"="+("string"==typeof t?encodeURIComponent(t):encodeURIComponent(JSON.stringify(t)))}).join("&").replace(/eval/gi,"evaI"),r+(-1===r.indexOf("?")?"?":"&")+c):r,f.originRequest(p({url:o,enableHttp2:l,success:t,fail:n,complete:s},e.requestConfig))):("string"==typeof a.data&&(a.data=a.data.replace(/eval/gi,"evaI")),f.originRequest(p({url:o,enableHttp2:l,header:a.contentType?{"content-type":a.contentType}:void 0,method:"POST",data:a.data,success:t,fail:n,complete:s},e.requestConfig))),!0}f.requestQueue.push({options:e,success:t,fail:n})}else f.requestQueue.push({options:e,success:t,fail:n});var u,c};try{e.offlineLog&&f.initOfflineLog(),f.init(e),f.extendBean("sessionId",U.sessionID),f.extendBean("referer",(g("getLaunchOptionsSync")?S.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"),f.sendSDKError(e)}return f}function Oe(e){var o,r,s=this,e=void 0===e?{}:e,t=e.path,t=void 0===t?"/.aegis.offline.log":t,e=e.limit,e=void 0===e?2e4:e;this.offlineBuffer=[],this.insertLog=(o=null,r=[],function(e){r=r.concat(e),o=o||setTimeout(function(){o=null;var e,t=s.fileSystem,n=s.filePath,i=r.map(function(e){return JSON.stringify(e)}).join("\n")+"\n";i&&(e=function(e){e?s.checkLimit(i,function(){r=[]}):t.writeFile({data:i,filePath:n,encoding:"utf8",fail:function(e){console.error(e)},success:function(){r=[]}})},t.access({path:n,success:function(){e(!0)},fail:function(){e()}}))},2e3)}),this.ready=function(e){s.fileSystem?setTimeout(function(){e(null)},0):(e(new Error("getFileSystemManager file")),s.offlineLog=!1)},this.clearLogs=function(){var e=s.fileSystem,t=s.filePath;e.writeFile({filePath:t,data:"",fail:function(){e.unlinkSync(t)}})},this.save2Offline=function(e,t){e=(e=Array.isArray(e)?e:[e]).map(function(e){return"string"==typeof e&&(e={msg:e}),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e[0]),i=1;i<e.length;i++){var o=e[i];if(null!==o)for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n[r]=o[r])}return n}({id:t.id,uin:t.uin,time:+Date.now(),version:t.version,from:i()},e)});s.fileSystem?s.insertLog(e):(s.fileSystem||s.offlineBuffer.length||s.ready(function(e){e?console.error(e):s.offlineBuffer.length&&(s.addLogs(s.offlineBuffer),s.offlineBuffer=[])}),s.offlineBuffer=s.offlineBuffer.concat(e))},this.addLogs=function(e){s.fileSystem&&s.insertLog(e)},this.filePath=S.env.USER_DATA_PATH+t,this.fileSystem=S.getFileSystemManager(),this.limitSize=e}function j(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 _(e){var n,t,i,o,s,r,a,l,u,c,f,p,d,h,g,m=this;this.isGetSample=!1,this.isHidden=!1,this.config={version:0,delay:1e3,onError:!0,repeat:5,random:1,aid:!0,device:!0,pagePerformance:!0,webVitals:!0,speedSample:!0,onClose:!0,hostUrl:"https://aegis.qq.com",websocketHack:!1,env:"production",url:"",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",webVitalsUrl:"",eventUrl:"",setDataReportUrl:""},this.isWhiteList=!1,this.lifeCycle=new F,this.bean={},this.normalLogPipeline=E([O(this,5),B,function(e,t){var i=n.config;t(e=e.map(function(e){var t,n=i.maxLength||204800;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=b(e.msg).substring(0,i.maxLength)}return e}))},(h=(n=this).config,g={},function(e,t){var n="number"==typeof h.repeat?h.repeat:5;if(0===n)return t(e);t(e.filter(function(e){return e.level!==y.ERROR&&e.level!==y.PROMISE_ERROR&&e.level!==y.AJAX_ERROR&&e.level!==y.SCRIPT_ERROR&&e.level!==y.IMAGE_ERROR&&e.level!==y.CSS_ERROR&&e.level!==y.MEDIA_ERROR||(g[e.msg]=g[e.msg]||0,g[e.msg]+=1,!(g[e.msg]>n))}))}),(p=this.lifeCycle.emit,d=this.config,function(e,t){var n,i=d.logCreated;return"function"==typeof i?(n=e.filter(function(e){return!1!==i(e)}),p("beforeWrite",n),t(n)):(p("beforeWrite",e),t(e))}),(f=this,setTimeout(function(){var e=f.config.pvUrl,n=void 0===e?"":e;n&&f.sendPipeline([function(e,t){t({url:n,type:v.PV,fail:function(e){"403 forbidden"===e&&f.destroy()}})}],v.PV)(null)},100),function(e,t){t(e)}),(u=l=a=!1,c=[],(s=this).lifeCycle.on("onConfigChange",function(){r&&clearTimeout(r),r=setTimeout(function(){var e,n;!u&&s.config&&(u=!0,e=s.config.whiteListUrl,(n=void 0===e?"":e)&&s.sendPipeline([function(e,t){t({url:n,type:v.WHITE_LIST,success:function(e){l=!0;try{var t=e.data||JSON.parse(e),n=t.retcode,i=t.result,o=void 0===i?{}:i;if(0===n){if(a=o.is_in_white_list,s.isWhiteList=a,o.shutdown)return void s.destroy();0<=o.rate&&o.rate<=1&&(s.config.random=o.rate,s.isGetSample=!1)}s.isWhiteList&&c.length?Z(s)(c.splice(0),function(){}):!s.isWhiteList&&c.length&&(c.length=0);var r=s.config.onWhitelist;"function"==typeof r&&r(a)}catch(e){}},fail:function(e){"403 forbidden"===e&&s.destroy(),l=!0}})}],v.WHITE_LIST)(null),u=!1)},s.config.uin?50:500)}),s.lifeCycle.on("destroy",function(){c.length=0}),function(e,t){var n;a||null!=(n=null==(n=s.config)?void 0:n.api)&&n.reportRequest?t(e.concat(c.splice(0)).map(function(e){return Q(e),e})):(n=e.filter(function(e){return e.level!==y.INFO&&e.level!==y.API_RESPONSE?(Q(e),!0):(l||(c.push(e),200<=c.length&&(c.length=200)),!1)})).length&&t(n)}),function(e,t){try{var n=JSON.parse(JSON.stringify(e)),i=(m.lifeCycle.emit("beforeReport",n),m.config.beforeReport);(e="function"==typeof i?e.filter(function(e){return!1!==i(e)}):e).length&&t(e)}catch(e){}},Z(this)]),this.eventPipeline=E([O(this,5),(o=this,function(e){o.sendPipeline([function(e,t){var n=e.map(function(e){return{name:e.name,ext1:e.ext1||o.config.ext1||"",ext2:e.ext2||o.config.ext2||"",ext3:e.ext3||o.config.ext3||""}});t({url:o.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(n)),type:v.EVENT,log:e,fail:function(e){"403 forbidden"===e&&o.destroy()}})}],v.EVENT)(e)})]),this.timeMap={},this.failRequestCount=0,this.customTimePipeline=E([O(this,5),(i=this,function(e){return i.sendPipeline([function(e,t){t({url:i.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:v.CUSTOM,log:e,fail:function(e){"403 forbidden"===e&&i.destroy()}})}],v.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),_.instances.push(this)}return P.use(T),P.use(fe),P.use(se),P.use(me),P.use(ve),P.use(R),P.use(oe),P});
@@ -34,6 +34,7 @@ export interface Config {
34
34
  api?: Record<string, any>;
35
35
  beforeReportSpeed?: Function;
36
36
  reportAssetSpeed?: boolean | object;
37
+ reportLoadPackageSpeed?: boolean;
37
38
  beforeRequest?: Function;
38
39
  afterRequest?: Function;
39
40
  ext1?: string;
@@ -1,5 +1,6 @@
1
1
  export declare enum Environment {
2
2
  production = "production",
3
+ development = "development",
3
4
  gray = "gray",
4
5
  pre = "pre",
5
6
  daily = "daily",
@@ -46,6 +46,7 @@ export interface SpeedLog {
46
46
  method: string;
47
47
  type: 'static' | 'fetch';
48
48
  duration?: number;
49
+ nextHopProtocol?: string;
49
50
  ret?: string | number | 'unknown';
50
51
  status?: number;
51
52
  isErr?: number;
@@ -69,6 +70,7 @@ export interface StaticAssetsLog {
69
70
  method: string;
70
71
  type: 'static' | 'fetch';
71
72
  duration?: number;
73
+ nextHopProtocol?: string;
72
74
  ret?: string | 'unknown';
73
75
  status?: number;
74
76
  domainLookup: number;
@@ -27,7 +27,8 @@ export declare enum SendType {
27
27
  EVENT = "event",
28
28
  CUSTOM = "custom",
29
29
  SDK_ERROR = "sdkError",
30
- SET_DATA = "setData"
30
+ SET_DATA = "setData",
31
+ LOAD_PACKAGE = "loadPackage"
31
32
  }
32
33
  export declare type SendSuccess = (data: any) => void;
33
34
  export declare type SendFail = (err: any) => void;
@@ -11,6 +11,7 @@ export interface HippyConfig extends Config {
11
11
  userAgent?: string;
12
12
  useSDKReportNetwork?: boolean;
13
13
  getNetworkType?: Function;
14
+ viewPort?: string;
14
15
  }
15
16
  export default class Aegis extends Core {
16
17
  static sessionID: string;
@@ -1,4 +1,4 @@
1
- import { Plugin } from "../../../core/src";
1
+ import Core, { Plugin } from "../../../core/src";
2
2
  export declare enum NetworkType {
3
3
  unknown = 100,
4
4
  wifi = 1,
@@ -8,6 +8,6 @@ export declare enum NetworkType {
8
8
  net5g = 5,
9
9
  net6g = 6
10
10
  }
11
- declare const _default: Plugin<import("../../../core/src").default>;
11
+ declare const _default: Plugin<Core>;
12
12
  export default _default;
13
13
  export declare const getNetworkType: (callback: Function) => void;
@@ -6,6 +6,7 @@ interface PagePerformanceConfig extends PagePerformanceStruct {
6
6
  export interface MpConfig extends Config {
7
7
  reportApiSpeed?: boolean;
8
8
  reportAssetSpeed?: boolean;
9
+ reportLoadPackageSpeed?: boolean;
9
10
  beforeReportSpeed?: Function;
10
11
  onBeforeRequest?: Function;
11
12
  offlineLog?: boolean;
@@ -4,4 +4,5 @@ import onError from './on-error';
4
4
  import onAssetSpeed from './assets-speed';
5
5
  import onPagePerformance from './page-performance';
6
6
  import onDevice from './device';
7
- export { aid, cgiSpeed, onError, onAssetSpeed, onPagePerformance, onDevice };
7
+ import onLoadPackage from './load-package';
8
+ export { aid, cgiSpeed, onError, onAssetSpeed, onPagePerformance, onLoadPackage, onDevice };
@@ -0,0 +1,3 @@
1
+ import Core, { Plugin } from "../../../core/src";
2
+ declare const _default: Plugin<Core>;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { Plugin } from "../../../core/src";
2
+ declare const plugin: Plugin<import("../../../core/src").default>;
3
+ export default plugin;
@@ -1,4 +1,5 @@
1
1
  import aid from './aid';
2
2
  import onError from './on-error';
3
3
  import cgiSpeed from './cgi-speed';
4
- export { aid, onError, cgiSpeed };
4
+ import device from './device';
5
+ export { aid, onError, cgiSpeed, device };
@@ -29,19 +29,12 @@ export default class Aegis extends Core {
29
29
  };
30
30
  constructor(config: WebConfig);
31
31
  getBean(filter?: string[]): string;
32
- requestQueue: {
33
- options: SendOption;
34
- success?: SendSuccess;
35
- fail?: SendFail;
36
- }[];
37
- requesting: boolean;
38
- private resetRequesting;
32
+ private getCurrentPageUrl;
39
33
  request(options: SendOption, success?: SendSuccess, fail?: SendFail): void;
40
34
  speedLogPipeline: import("../../core/src").Pipeline<any, any>;
41
35
  private static asyncPlugin;
42
36
  static useAsyncPlugin(url: string, options?: AsyncPluginOption): void;
43
37
  publishPluginsLogs(): void;
44
- publishLogsQueue(): void;
45
38
  uploadLogs(params?: any, conds?: any): void;
46
39
  static urls: {
47
40
  [key: string]: string;
@@ -5,3 +5,9 @@ export declare const canUseResourceTiming: () => boolean;
5
5
  export declare const canUseWebVitals: () => boolean;
6
6
  export declare type OnHiddenCallback = (event: Event) => void;
7
7
  export declare const onHidden: (cb: OnHiddenCallback, once?: boolean | undefined) => void;
8
+ /**
9
+ * 是否忽略当前 url
10
+ * @param url
11
+ * @returns boolean
12
+ */
13
+ export declare const isIgnoreUrl: (url: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aegis-mp-sdk",
3
- "version": "1.24.57",
3
+ "version": "1.36.1",
4
4
  "description": "aegis sdk for wechat and qq mini program",
5
5
  "author": "tickli <tickli@tencent.com>",
6
6
  "homepage": "",
@@ -1,9 +0,0 @@
1
- /**
2
- * 过滤log
3
- * @param {Any} log 要发送单个log对象
4
- * @return {Any} 过滤后的log对象
5
- */
6
- export declare const filteLog: (log: any) => any;
7
- export declare const loadScript: (url: string, name?: string | undefined, cb?: Function | undefined) => void;
8
- export declare const canUseResourceTiming: () => boolean;
9
- export declare const canUseWebVitals: () => boolean;