aegis-mp-sdk 1.24.55 → 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.
Files changed (42) hide show
  1. package/README.md +1 -0
  2. package/lib/aegis.min.js +5 -5
  3. package/lib/packages/core/src/core.d.ts +5 -4
  4. package/lib/packages/core/src/interface/config.d.ts +2 -0
  5. package/lib/packages/core/src/interface/env.d.ts +1 -0
  6. package/lib/packages/core/src/interface/log.d.ts +4 -1
  7. package/lib/packages/core/src/interface/send.d.ts +2 -1
  8. package/lib/packages/core/src/pipes/index.d.ts +1 -1
  9. package/lib/packages/core/src/pipes/report.d.ts +2 -0
  10. package/lib/packages/core/src/util/index.d.ts +2 -0
  11. package/lib/packages/hippy-sdk/src/aegis.d.ts +4 -0
  12. package/lib/packages/hippy-sdk/src/plugins/device.d.ts +13 -0
  13. package/lib/packages/hippy-sdk/src/plugins/index.d.ts +2 -1
  14. package/lib/packages/liteapp-sdk/src/aegis.d.ts +22 -0
  15. package/lib/packages/liteapp-sdk/src/constant/index.d.ts +4 -0
  16. package/lib/packages/liteapp-sdk/src/index.d.ts +4 -0
  17. package/lib/packages/liteapp-sdk/src/plugins/aid.d.ts +3 -0
  18. package/lib/packages/liteapp-sdk/src/plugins/cgi-speed.d.ts +3 -0
  19. package/lib/packages/liteapp-sdk/src/plugins/device.d.ts +3 -0
  20. package/lib/packages/liteapp-sdk/src/plugins/index.d.ts +5 -0
  21. package/lib/packages/liteapp-sdk/src/plugins/on-error.d.ts +6 -0
  22. package/lib/packages/liteapp-sdk/src/util/index.d.ts +3 -0
  23. package/lib/packages/liteapp-sdk/src/util/lite.d.ts +10 -0
  24. package/lib/packages/liteapp-sdk/src/util/request.d.ts +21 -0
  25. package/lib/packages/liteapp-sdk/src/util/store.d.ts +7 -0
  26. package/lib/packages/mp-sdk/src/aegis.d.ts +1 -0
  27. package/lib/packages/mp-sdk/src/plugins/index.d.ts +2 -1
  28. package/lib/packages/mp-sdk/src/plugins/load-package.d.ts +3 -0
  29. package/lib/packages/mp-sdk/src/util/hack-api.d.ts +7 -3
  30. package/lib/packages/mp-sdk/src/util/hack-network.d.ts +17 -0
  31. package/lib/packages/mp-sdk/src/util/hack-wsConnect.d.ts +21 -0
  32. package/lib/packages/mp-sdk/src/util/index.d.ts +5 -0
  33. package/lib/packages/rn-sdk/src/plugins/device.d.ts +3 -0
  34. package/lib/packages/rn-sdk/src/plugins/index.d.ts +2 -1
  35. package/lib/packages/web-sdk/src/aegis.d.ts +4 -8
  36. package/lib/packages/web-sdk/src/plugins/index.d.ts +2 -1
  37. package/lib/packages/web-sdk/src/plugins/on-close.d.ts +3 -0
  38. package/lib/packages/web-sdk/src/util/device-type.d.ts +3 -0
  39. package/lib/packages/web-sdk/src/util/hack-websocket.d.ts +14 -0
  40. package/lib/packages/web-sdk/src/util/index.d.ts +6 -0
  41. package/package.json +1 -1
  42. package/lib/packages/cocos-sdk/src/util/index.d.ts +0 -9
package/README.md CHANGED
@@ -395,6 +395,7 @@ Aegis 通过劫持 `wx.request || qq.request` 进行接口测速。
395
395
  | delay | 可选,number,默认 1000 ms。<br>上报节流时间,在该时间段内的上报将会合并到一个上报请求中。 |
396
396
  | repeat | 可选,number,默认 5。<br>重复上报次数,对于同一个错误超过多少次不上报。 |
397
397
  | enableHttp2 | 可选,boolean,默认 false。<br> 上报数据是否支持 HTTP2,默认没有开启,以后会考虑改成默认开启。 |
398
+ | websocketHack | 可选,boolean,默认 false <br>是否开启websocket监控。 |
398
399
  | offlineLog | 可选,boolean,默认 false。<br>是否使用离线日志 |
399
400
  | offlineLogExp | 可选,number,默认 3。<br>离线日志过期天数 |
400
401
  | url | 可选,string,默认 '//aegis.qq.com/collect'。<br>日志上报地址 |
package/lib/aegis.min.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * ==========================================================================
3
- * @tencent/aegis-mp-sdk@1.24.54 (c) 2022 TencentCloud Real User Monitoring.
2
+ * =================================================================
3
+ * aegis-mp-sdk@1.36.1 (c) 2022 TencentCloud Real User Monitoring.
4
4
  * Author pumpkincai.
5
- * Last Release Time Fri Mar 11 2022 16:16:45 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],u=Object.getOwnPropertyDescriptor(i,a);null!=u&&u.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),o=function(t){try{return encodeURIComponent(decodeURIComponent(t))}catch(e){return 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={}}(J={})[J.number=-1]="number",J.string="";function u(e,t){return"string"==typeof e?e.split("?")[t?1:0]||"":e}function l(e){return"string"==typeof e&&e.startsWith("//")?"undefined"!=typeof location&&"https:"===location.protocol:/^https/.test(e)}function p(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}}}var d,a,c,h,g,m=["ret","retcode","code","errcode"],y=function(e){if("string"==typeof e)return e;try{return(JSON.stringify(e,(i=[],o=[],function(e,t){if(t instanceof Error)return"Error.message: "+t.message+" \n Error.stack: "+t.stack;if("object"==typeof t&&null!==t){var n=i.indexOf(t);if(-1!==n)return"[Circular "+o[n]+"]";i.push(t),o.push(e||"root")}return t}),4)||"undefined").replace(/"/gim,"")}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}var i,o},v=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?v(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+'":'+v(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)},n=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};(X=d=d||{}).INFO_ALL="-1",X.API_RESPONSE="1",X.INFO="2",X.ERROR="4",X.PROMISE_ERROR="8",X.AJAX_ERROR="16",X.SCRIPT_ERROR="32",X.IMAGE_ERROR="64",X.CSS_ERROR="128",X.CONSOLE_ERROR="256",X.MEDIA_ERROR="512",X.RET_ERROR="1024",X.REPORT="2048",X.PV="4096",X.EVENT="8192",X.PAGE_NOT_FOUND_ERROR="16384",(Z=a=a||{})[Z.android=1]="android",Z[Z.ios=2]="ios",Z[Z.windows=3]="windows",Z[Z.macos=4]="macos",Z[Z.linux=5]="linux",Z[Z.devtools=6]="devtools",Z[Z.other=100]="other",(ee=c=c||{})[ee.unknown=100]="unknown",ee[ee.wifi=1]="wifi",ee[ee.net2g=2]="net2g",ee[ee.net3g=3]="net3g",ee[ee.net4g=4]="net4g",ee[ee.net5g=5]="net5g",ee[ee.net6g=6]="net6g",(te=h=h||{}).LOG="log",te.SPEED="speed",te.PERFORMANCE="performance",te.OFFLINE="offline",te.WHITE_LIST="whiteList",te.VITALS="vitals",te.PV="pv",te.CUSTOM_PV="customPV",te.EVENT="event",te.CUSTOM="custom",te.SDK_ERROR="sdkError",te.SET_DATA="setData",(ue=g=g||{}).production="production",ue.gray="gray",ue.pre="pre",ue.daily="daily",ue.local="local",ue.test="test",ue.others="others";function w(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===d.INFO_ALL&&(e.level=d.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 E(i){return function(e,t){i.lifeCycle.emit("afterRequest",e);var n=i.config.afterRequest;"function"==typeof n&&!1===n(e)||t(e)}}function x(){}function S(t,n){Object.getOwnPropertyNames(t).forEach(function(e){"function"==typeof t[e]&&"constructor"!==e&&(n?n[e]="sendPipeline"===e?function(){return function(){}}:function(){}:t[e]=function(){})})}function T(){try{var e=getCurrentPages();return(e[e.length-1]||{}).route||""}catch(e){return""}}function L(e){return C?C.addCallback(e):C=new oe(e),C}var C,N,k,U,A=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)}},j=function(e,n){var i,o=[],r=e.config;return e.lifeCycle.on("destroy",function(){o.length=0}),function(e,t){if(o.push(e),n&&o.length>=n)return o=w(o),t(o.splice(0,o.length)),void(i&&clearTimeout(i));i&&clearTimeout(i),i=setTimeout(function(){i=null,0<(o=w(o)).length&&t(o.splice(0,o.length))},r.delay)}},I=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(y).join(" ")})})):t(f(f({},e),{msg:"string"==typeof e.msg?e.msg:y(e.msg)}))},_=function(s){var e,a=!1,u=!1,t=!1,l=[];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){u=!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&&l.length?M(s)(l.splice(0),function(){}):!s.isWhiteList&&l.length&&(l.length=0);var r=s.config.onWhitelist;"function"==typeof r&&r(a)}catch(e){}},fail:function(e){"403 forbidden"===e&&s.destroy(),u=!0}})}],h.WHITE_LIST)(null),t=!1)},s.config.uin?50:500)}),s.lifeCycle.on("destroy",function(){l.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(l.splice(0)).map(function(e){return R(e),e})):(e=e.filter(function(e){return e.level!==d.INFO&&e.level!==d.API_RESPONSE?(R(e),!0):(u||(l.push(e),200<=l.length&&(l.length=200)),!1)})).length&&t(e)}},q=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)}},F=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!==d.ERROR&&e.level!==d.PROMISE_ERROR&&e.level!==d.AJAX_ERROR&&e.level!==d.SCRIPT_ERROR&&e.level!==d.IMAGE_ERROR&&e.level!==d.CSS_ERROR&&e.level!==d.MEDIA_ERROR||(o[e.msg]=o[e.msg]||0,o[e.msg]+=1,!(o[e.msg]>n))}))}},M=function(i){return function(e){return i.sendPipeline([function(e,n){return n({url:i.config.url||"",data:(t=e,t=(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:d.INFO,msg:""})}),(t=Array.isArray(t)?t:[t]).map(function(t,n){return Object.getOwnPropertyNames(t).map(function(e){return o(e)+"["+n+"]="+(void 0===t[e]?"":o(t[e]))}).join("&")}).join("&")+(t.length?"&count="+t.length:"")),method:"post",contentType:"application/x-www-form-urlencoded",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)}},H=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"]),t(n?i:i[0]))}},B=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||x)}:n.reduce(function(n,i){return function(e,t){return void 0===t&&(t=x),n(e,function(e){return null==i?void 0:i(e,t)})}})},V=(Object.defineProperty(me.prototype,"__version__",{get:function(){return console.warn("__version__ has discard, please use version"),"1.24.54"},enumerable:!1,configurable:!0}),Object.defineProperty(me.prototype,"LogType",{get:function(){return console.warn("LogType has discard, please use logType"),d},enumerable:!1,configurable:!0}),me.prototype.init=function(e){this.setConfig(e);for(var t=0;t<me.installedPlugins.length;t++)try{me.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},me.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,e=t.aid,t=t.env,u=void 0===t?"production":t,t=this.bean.id!==n||this.bean.uin!==i||this.bean.aid!==e;return this.bean.id=n||"",this.bean.uin=i||"",this.bean.version=o||"1.24.54",this.bean.aid=e||"",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,r&&(this.bean.ext1=encodeURIComponent(r)),s&&(this.bean.ext2=encodeURIComponent(s)),a&&(this.bean.ext3=encodeURIComponent(a)),t&&this.lifeCycle.emit("onConfigChange",this.config),this.config},me.use=function(e){-1===me.installedPlugins.indexOf(e)&&e.aegisPlugin&&me.installedPlugins.push(e)},me.unuse=function(e){e=me.installedPlugins.indexOf(e);-1!==e&&me.installedPlugins.splice(e,1)},me.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:d.INFO,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:d.INFO}),this.normalLogPipeline(n)},me.prototype.infoAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:d.INFO_ALL,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:d.INFO_ALL}),this.normalLogPipeline(n)},me.prototype.report=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:d.REPORT,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0])),this.normalLogPipeline(n)},me.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:d.ERROR,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:d.ERROR}),this.normalLogPipeline(n)},me.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},me.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))},me.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"))},me.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")},me.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")},me.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")},me.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")},me.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})},me.prototype.extendBean=function(e,t){this.bean[e]=t},me.prototype.sendPipeline=function(e,t){var n,r=this;return B(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}},H(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))})},E(this)]))},me.prototype.send=function(e,o,r){var t=this;return B([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)})},E(this)])(e)},me.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},me.prototype.sendSDKError=function(e){var n=this;this.sendPipeline([function(e,t){t({url:n.config.url+"?id=1085&msg[0]="+encodeURIComponent(y(e))+"&level[0]=2&from="+n.config.id+"&count=1&version="+n.config.id+"(1.24.54)",addBean:!1,method:"get",type:h.SDK_ERROR,log:e})}],h.SDK_ERROR)(e)},me.prototype.destroy=function(e){void 0===e&&(e=!1);var t,n,i=me.instances.indexOf(this);-1!==i&&me.instances.splice(i,1);for(var o=me.installedPlugins.length-1;0<=o;o--)try{me.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&&S(r,this),r=Object.getPrototypeOf(r););0===me.instances.length&&(e=Object.getPrototypeOf(this).constructor,S(e),S(me))}},me.version="1.24.54",me.instances=[],me.logType=d,me.environment=g,me.installedPlugins=[],me),J=(ge.prototype.patch=function(e){this.canUse(e)&&this.exist(e)&&(this.instances.push(e),this.triggerInit(e),this.triggerOnNewAegis(e))},ge.prototype.unpatch=function(e){e=this.instances.indexOf(e);-1!==e&&this.instances.splice(e,1)},ge.prototype.countInstance=function(){return this.instances.length},ge.prototype.uninstall=function(){var e;null===(e=null===(e=this.option)||void 0===e?void 0:e.destroy)||void 0===e||e.apply(this)},ge.prototype.walk=function(n){var i=this;this.instances.forEach(function(e){var t=i.canUse(e);t&&n(e,t)})},ge.prototype.canUse=function(e){e=this.getConfig(e);return!(!e||"object"!=typeof e)||!!e},ge.prototype.getConfig=function(e){return null===(e=e.config)||void 0===e?void 0:e[this.name]},ge.prototype.exist=function(e){return-1===this.instances.indexOf(e)},ge.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)))},ge.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))},ge),G=wx||qq,W="",$=function(e){return function(e,t){if("string"==typeof e){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}}}(W=W||G.getSystemInfoSync().SDKVersion,"1.1.1")&&G.canIUse?G.canIUse(e):!!G[e]},K=new J({name:"offlineLog",onNewAegis:function(o){if(G.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,u=e.offlineLogLimit,l=new z({limit:u});o.lifeCycle.on("beforeWrite",function(e){l.save2Offline(e=void 0===e?[]:e,o.config)}),l.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||l.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(){l.clearLogs()})}))})})}catch(o){console.error(o)}else console.warn("[aegis-mp-sdk]unsupport getFileSystemManager offline log not work!")}}),z=(he.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)}})},he.prototype.checkLimit=function(o,r){void 0===r&&(r=function(){});var s=this.fileSystem,a=this.filePath,u=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>u){for(var t=e.split("\n"),n="",i=t.length-1;0<=i&&!(t[i]&&(n=t[i]+"\n"+n).length>u);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)}})}})},he),Q=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=c.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=c[r];break}}return i},X=new J({name:"device",onNewAegis:function(u){return e=this,l=function(){return n=this,i=function(e){return this.setSystemInfo(u),this.refreshNetwork(u),this.setNetworkChange(u),[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(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{$("getSystemInfo")&&G.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){$("onNetworkStatusChange")&&G.onNetworkStatusChange(function(e){e=Q(e.networkType);t.extendBean("netType",e)})},setNetworkType:function(t){$("getNetworkType")&&G.getNetworkType({success:function(e){e=Q(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)}}),Y=G.request,Z=(e(de,U=V),Object.defineProperty(de.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(T()):"from="+encodeURIComponent(T())},enumerable:!1,configurable:!0}),de.prototype.initOfflineLog=function(){de.use(K)},de.prototype.uploadLogs=function(e,t){this.lifeCycle.emit("uploadLogs",e=void 0===e?{}:e,t=void 0===t?{}:t)},de.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(T()),this.send({url:this.config.url+"/"+e+"?"+t,addBean:!1,type:h.CUSTOM_PV,log:h.CUSTOM_PV},function(){},function(){}))},de.sessionID="session-"+Date.now(),de.asyncPluginIndex=0,de),ee=new J({name:"aid",onNewAegis:function(t){this.initAid(function(e){t.bean.aid=e,t.config.aid=e})},initAid:function(t){G.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)});G.setStorage({key:"AEGIS_ID",data:e,success:function(){t(e)}})}})}}),te=(pe.prototype.addCallback=function(e){e&&this.callbacks.push(e)},pe.prototype.prefixHandler=function(e){return f(f({},e),{aegisRequestStartTime:+new Date})},pe.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)},pe.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)},pe.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)},pe.prototype.override=function(){try{this.defineApiProperty()}catch(e){console.warn("cannot override `"+this.apiName+"`, error is: "+e)}finally{this.isOverride=!0}},pe),ne=wx||qq,ie=ne.request,oe=(e(fe,k=te),fe.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(ne,"request",{get:function(){return e.hackHandler.bind(e)}})},fe.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e);return ie(f(f({},n),{success:function(e){t.successHandler(e,n)},fail:function(e){t.failHandler(e,n)},complete:function(e){t.completeHandler(e,n)}}))},fe),re=wx||qq,se=null===(ue=re.cloud)||void 0===ue?void 0:ue.callFunction,ae=(e(ce,N=te),ce.prototype.defineApiProperty=function(){var e=this;re.cloud&&re.cloud.callFunction&&Object.defineProperty(re.cloud,"callFunction",{get:function(){return e.hackHandler.bind(e)}})},ce.prototype.hackHandler=function(e){var i=this,o=this.prefixHandler(e);return new Promise(function(t,n){se(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)}}))})},ce),V=new J({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({success:function(e,t){var n,i,o,r;s.hostUrl&&-1<t.url.indexOf(s.hostUrl)||(n={method:t.method||"get",url:u(t.url),duration:Date.now()-t.aegisRequestStartTime,status:e.statusCode||0,isHttps:l(t.url),type:"fetch"},r=null===(i=s.api)||void 0===i?void 0:i.apiDetail,i=(o=p(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?y(t.data):"")+" \n \nres duration: "+n.duration+"ms \n \nres status: "+(e.statusCode||0)+" \n \nres retcode: "+i+" \n \nres data: "+(r?v(e.data):""),a.publishNormalLog({msg:r,level:d.API_RESPONSE,ctx:e}),n.ret=i,n.isErr=+o,a.publishSpeedLog(n),o&&a.publishNormalLog({msg:r,level:d.RET_ERROR,ctx:e}))},fail:function(e,t){s.hostUrl&&-1<t.url.indexOf(s.hostUrl)||(t={method:t.method||"get",url:u(t.url),duration:Date.now()-t.aegisRequestStartTime,status:0,isHttps:l(t.url),type:"fetch"},a.publishSpeedLog(t))}})},overrideCallFunction:function(u){var l=this;new ae({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=u.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?v(e.result):"")+"\n ";l.publishNormalLog({msg:o,level:d.API_RESPONSE,ctx:e});var r,s,a=!1,a=(s="function"==typeof(null===(i=u.api)||void 0===i?void 0:i.retCodeCloudFunctionHandler)?(r=(t=u.api.retCodeCloudFunctionHandler(e.result,t.name,t,e)||{}).code,void 0!==(t=t.isErr)&&t):(r=(s=p(e.result,u.api,{url:n.url,ctx:e})||{}).code,s.isErr),n.ret=r,s);n.isErr=+a,l.publishSpeedLog(n),a&&l.publishNormalLog({msg:o,level:d.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};l.publishSpeedLog(e)}})},publishSpeedLog:function(t){this.$walk(function(e){e.speedLogPipeline(t)})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})}}),ue=new J({name:"onError",onNewAegis:function(e){this.listenError(),this.hackRequest(e)},listenError:function(){var t=this;"function"==typeof G.onError&&G.onError(function(e){e&&t.publishErrorLog({msg:e,level:d.ERROR})}),$("onUnhandledRejection")&&G.onUnhandledRejection(function(e){e=e.reason;e&&(-1<JSON.stringify(e).indexOf("request:fail")||t.publishErrorLog({msg:e,level:d.PROMISE_ERROR}))}),$("onPageNotFound")&&G.onPageNotFound(function(e){e&&t.publishErrorLog({msg:e,level:d.PAGE_NOT_FOUND_ERROR})})},publishErrorLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},hackRequest:function(u){var l=this,c=u.config;L({complete:function(e,t){var n,i,o=e.errMsg,r=e.statusCode,s=e.data,a=null===(n=c.api)||void 0===n?void 0:n.apiDetail;c.hostUrl&&-1<(null===(i=t.url)||void 0===i?void 0:i.indexOf(c.hostUrl))||(n="",-1<o.indexOf("timeout")||-1<o.indexOf("超时")?n="timeout":400<=r?n="error":(-1<o.indexOf("fail")||!r||r<0)&&(n="failed"),n&&(i="wx.cloud.callFunction."+t.url,e=p(e.data,u.config.api,{url:i,ctx:e}).code,l.publishErrorLog({msg:"AJAX_ERROR: request "+n+"\n \nres status: "+(r||0)+"\n \nres retcode: "+e+"\n \nres duration: "+(Date.now()-t.aegisRequestStartTime)+"ms\n \nres data: "+(a?y(s):"")+"\n \nreq url: "+t.url+"\n \nreq method: "+(t.method||"get")+"\n \nreq param: "+(a?y(t.data):"")+"\n \nerrMsg: "+o.slice(0,1e3),level:d.AJAX_ERROR})))}})}}),te=new J({name:"reportAssetSpeed",isStart:!1,onNewAegis:function(e){this.isStart||(this.isStart=!0,this.start(e))},start:function(){var t=this;G.getPerformance&&G.getPerformance().createObserver(function(e){e.getEntries().forEach(function(e){!e.duration||e.duration<=0||"script"===e.entryType&&t.publishAssetLog(e)})}).observe({entryTypes:["script"]})},generateLog:function(e){return{url:u(e.path||e.moduleName)+"js",method:"get",duration:Number(e.duration.toFixed(2)),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))})}}),le=["onLaunch","onHide","onError","onLoad","onReady","onShow","onUnload"],J=new J({name:"pagePerformance",onNewAegis:function(e){try{$("getPerformance")&&this.reportPerformance(e),this.setPagePV(e),this.reportSetDataTiming(e)}catch(e){}},reportPerformance:function(r){var s=this,e=G.getPerformance(),e=null==e?void 0:e.createObserver(function(e){var t=e.getEntries(),n={},i=t.find(function(e){return"appLaunch"===e.name&&0<e.duration}),o=t.find(function(e){return"firstRender"===e.name&&0<e.duration}),e=t.find(function(e){return"evaluateScript"===e.name&&0<e.duration}),t=t.find(function(e){return"route"===e.name&&0<e.duration});i&&(n.appLaunch=i.duration),o&&(n.firstScreenTiming=o.duration),e&&(n.scriptEvaluateTiming=e.duration),t&&(n.pageRouteTiming=t.duration),s.publish(n,r)});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;G.onAppRoute&&G.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:d.INFO})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},reportSetDataTiming:function(t){var e,o,a,u,n,r,s,l,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,u=B([j(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)}),u(n))},l=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:d.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 i;"function"!=typeof t[e]||le.includes(e)||(i=t[e],t[e]=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return"tap"===(null===(e=null==t?void 0:t[0])||void 0===e?void 0:e.type)&&l(t),null==i?void 0:i.apply(this,t)})}),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 i;"function"==typeof t[e]&&(i=t[e],t[e]=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return"tap"===(null===(e=null==t?void 0:t[0])||void 0===e?void 0:e.type)&&l(t),null==i?void 0:i.apply(this,t)})}),r(e)})}});function ce(){return null!==N&&N.apply(this,arguments)||this}function fe(){return null!==k&&k.apply(this,arguments)||this}function pe(e){this.callbacks=[],this.isOverride=!1,this.isOverride||this.override(),this.callbacks.push(e)}function de(e){var i,c=U.call(this,e)||this;c.originRequest=Y,c.speedLogPipeline=B([D(c.config),j(c),function(t,n){$("getNetworkType")?G.getNetworkType({success:function(e){e=Q(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)},H(i=c,h.SPEED),function(e){c.send({url:""+c.config.speedUrl,method:"post",data:n(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||$("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,u=c.config.onBeforeRequest;if(!(a=u?u(e,c):a)||!a.url){var l="";return a||(l="Sending request blocked",console.log(l)),a.url||(l="Please handle the parameters reasonably, options.url is necessary",console.warn(l)),null==n||n(l),s(),!1}l=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:l,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:l,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",de.sessionID),c.extendBean("referer",($("getLaunchOptionsSync")?G.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 he(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:T()},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=G.env.USER_DATA_PATH+e,this.fileSystem=G.getFileSystemManager(),this.limitSize=t}function ge(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 me(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,hostUrl:"https://aegis.qq.com",env:"production",url:"",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",webVitalsUrl:"",eventUrl:"",setDataReportUrl:""},this.isWhiteList=!1,this.lifeCycle=new r,this.bean={},this.normalLogPipeline=B([j(this,5),I,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=y(e.msg).substring(0,i.maxLength)}return e}))},F((n=this).config),A(this.lifeCycle.emit,this.config),q(this),_(this),function(e,t){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)},M(this)]),this.eventPipeline=B([j(this,5),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:h.EVENT,log:e,fail:function(e){"403 forbidden"===e&&o.destroy()}})}],h.EVENT)(e)}]),this.timeMap={},this.failRequestCount=0,this.customTimePipeline=B([j(this,5),function(e){return o.sendPipeline([function(e,t){t({url:o.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:h.CUSTOM,log:e,fail:function(e){"403 forbidden"===e&&o.destroy()}})}],h.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),me.instances.push(this)}return Z.use(ue),Z.use(V),Z.use(ee),Z.use(te),Z.use(J),Z.use(X),Z});
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});
@@ -18,9 +18,10 @@ export default class Core {
18
18
  bean: {
19
19
  [key: string]: string | number | boolean;
20
20
  };
21
+ sendNow: boolean;
21
22
  init(config: Config): void;
22
23
  setConfig(config: Partial<Config>): Config;
23
- private static installedPlugins;
24
+ static installedPlugins: Plugin[];
24
25
  static use(plugin: Plugin): void;
25
26
  static unuse(plugin: Plugin): void;
26
27
  info(...msg: any): void;
@@ -28,10 +29,10 @@ export default class Core {
28
29
  report(...msg: any): void;
29
30
  error(...msg: any): void;
30
31
  normalLogPipeline: import("./pipes").Pipeline<any, any>;
31
- speedLogPipeline(_log?: SpeedLog): void;
32
+ speedLogPipeline(_log?: SpeedLog | SpeedLog[]): void;
32
33
  reportPv(id: number): void;
33
34
  reportEvent(event: string | EventLog): void;
34
- private eventPipeline;
35
+ eventPipeline: import("./pipes").Pipeline<any, any>;
35
36
  private timeMap;
36
37
  private failRequestCount;
37
38
  reportTime(key: string | ReportTimeLog, duration?: number): void;
@@ -39,7 +40,7 @@ export default class Core {
39
40
  time(key: string): void;
40
41
  timeEnd(key: string): void;
41
42
  private submitCustomTime;
42
- private customTimePipeline;
43
+ customTimePipeline: import("./pipes").Pipeline<any, any>;
43
44
  extendBean(key: string, value: any): void;
44
45
  sendPipeline(pipes: Pipe[], type: SendType): import("./pipes").Pipeline<any, any>;
45
46
  send(options: SendOption, success?: SendSuccess, fail?: SendFail): any;
@@ -26,6 +26,7 @@ export interface Config {
26
26
  setDataReportUrl?: string;
27
27
  pageUrl?: string;
28
28
  getNetworkType?: Function;
29
+ websocketHack?: boolean;
29
30
  beforeReport?: Function;
30
31
  logCreated?: Function;
31
32
  onReport?: Function;
@@ -33,6 +34,7 @@ export interface Config {
33
34
  api?: Record<string, any>;
34
35
  beforeReportSpeed?: Function;
35
36
  reportAssetSpeed?: boolean | object;
37
+ reportLoadPackageSpeed?: boolean;
36
38
  beforeRequest?: Function;
37
39
  afterRequest?: Function;
38
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",
@@ -14,7 +14,8 @@ export declare enum LogType {
14
14
  REPORT = "2048",
15
15
  PV = "4096",
16
16
  EVENT = "8192",
17
- PAGE_NOT_FOUND_ERROR = "16384"
17
+ PAGE_NOT_FOUND_ERROR = "16384",
18
+ WEBSOCKET_ERROR = "32768"
18
19
  }
19
20
  export declare enum PlatTypeNum {
20
21
  android = 1,
@@ -45,6 +46,7 @@ export interface SpeedLog {
45
46
  method: string;
46
47
  type: 'static' | 'fetch';
47
48
  duration?: number;
49
+ nextHopProtocol?: string;
48
50
  ret?: string | number | 'unknown';
49
51
  status?: number;
50
52
  isErr?: number;
@@ -68,6 +70,7 @@ export interface StaticAssetsLog {
68
70
  method: string;
69
71
  type: 'static' | 'fetch';
70
72
  duration?: number;
73
+ nextHopProtocol?: string;
71
74
  ret?: string | 'unknown';
72
75
  status?: number;
73
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;
@@ -6,7 +6,7 @@ export { createLimitLengthPipe } from './length-limit';
6
6
  export { createWhitelistPipe } from './whitelist';
7
7
  export { createPvPipe } from './pv';
8
8
  export { createSpeedRepeatLimitPipe, createErrorLogLimitPipe } from './repeat-limit';
9
- export { reportPipe } from './report';
9
+ export { reportPipe, reportEventPipe, reportCustomPipe } from './report';
10
10
  export { beforeRequestHooks } from './beforeRequestHooks';
11
11
  export { modifyRequestHooks } from './modifyRequestHooks';
12
12
  export { afterRequestHooks } from './afterRequestHooks';
@@ -6,3 +6,5 @@ import Core from '../core';
6
6
  * @returns
7
7
  */
8
8
  export declare const reportPipe: (aegis: Core) => Pipe;
9
+ export declare const reportEventPipe: (aegis: Core) => Pipe;
10
+ export declare const reportCustomPipe: (aegis: Core) => Pipe;
@@ -1,6 +1,7 @@
1
1
  import { NormalLog, SpeedLog, Config } from '../interface';
2
2
  export { EventEmitter, InterfaceEventEmitter } from './event-emitter';
3
3
  export declare const buildLogParam: (logs: NormalLog | NormalLog[]) => string;
4
+ export declare const buildLog2Json: (logs: NormalLog | NormalLog[]) => string;
4
5
  interface P {
5
6
  [k: string]: any;
6
7
  }
@@ -29,6 +30,7 @@ export declare const tryToGetRetCode: (obj: any, api?: Record<string, any> | und
29
30
  */
30
31
  export declare const judgeIsErrorRet: (config: Config, ret: string) => boolean;
31
32
  export declare const stringifyPlus: (target: any) => string;
33
+ export declare const stringify: (target: any) => string;
32
34
  export declare const stringifyObj: (obj: any, deep?: number) => string;
33
35
  /**
34
36
  * 获取xhr相关资源
@@ -8,6 +8,10 @@ export interface HippyConfig extends Config {
8
8
  dbConfig?: any;
9
9
  offlineLogExp?: number;
10
10
  reqCallback?: (data?: unknown, options?: unknown) => {};
11
+ userAgent?: string;
12
+ useSDKReportNetwork?: boolean;
13
+ getNetworkType?: Function;
14
+ viewPort?: string;
11
15
  }
12
16
  export default class Aegis extends Core {
13
17
  static sessionID: string;
@@ -0,0 +1,13 @@
1
+ import Core, { Plugin } from "../../../core/src";
2
+ export declare enum NetworkType {
3
+ unknown = 100,
4
+ wifi = 1,
5
+ net2g = 2,
6
+ net3g = 3,
7
+ net4g = 4,
8
+ net5g = 5,
9
+ net6g = 6
10
+ }
11
+ declare const _default: Plugin<Core>;
12
+ export default _default;
13
+ export declare const getNetworkType: (callback: Function) => void;
@@ -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 };
@@ -0,0 +1,22 @@
1
+ import Core, { Config, SendFail, SendOption, SendSuccess, SpeedLog } from "../../core/src";
2
+ export interface LiteConfig extends Config {
3
+ reportApiSpeed?: boolean;
4
+ beforeReportSpeed?: (log: SpeedLog) => boolean;
5
+ useStore?: boolean;
6
+ }
7
+ export default class Aegis extends Core {
8
+ static sessionID: string;
9
+ originRequest: (opts: import("./util").OriginRequestReq) => Promise<import("./util").OriginRequestResp>;
10
+ speedLogPipeline: import("../../core/src").Pipeline<any, any>;
11
+ constructor(config: LiteConfig);
12
+ request: (options: SendOption, success?: SendSuccess | undefined, fail?: SendFail | undefined) => void;
13
+ /**
14
+ * 构造请求参数
15
+ * @param url
16
+ * @param options
17
+ * @returns requestOptions
18
+ */
19
+ private genRequestParams;
20
+ uploadLogs(params?: any, conds?: any): void;
21
+ private rewriteNormalLogPipeline;
22
+ }
@@ -0,0 +1,4 @@
1
+ export declare const STORE_ACTION_KEY = "AEGIS_REPORT";
2
+ export declare const STORE_MODULE_NAME = "AEGIS";
3
+ export declare const STORE_ACTION: string;
4
+ export declare const AEGIS_ID_KEY = "AEGIS_ID";
@@ -0,0 +1,4 @@
1
+ import Aegis from './aegis';
2
+ import { UseStore } from './util';
3
+ export default Aegis;
4
+ export { UseStore };
@@ -0,0 +1,3 @@
1
+ import { Plugin } from "../../../core/src";
2
+ declare const _default: Plugin<import("../../../core/src").default>;
3
+ export default _default;
@@ -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 Core, { Plugin } from "../../../core/src";
2
+ declare const plugin: Plugin<Core>;
3
+ export default plugin;
@@ -0,0 +1,5 @@
1
+ import aid from './aid';
2
+ import onError from './on-error';
3
+ import onDevice from './device';
4
+ import cgiSpeed from './cgi-speed';
5
+ export { aid, onError, onDevice, cgiSpeed };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @插件 该插件会监听页面的错误,并发布至每一个 Aegis 实例
3
+ */
4
+ import Core, { Plugin } from "../../../core/src";
5
+ declare const _default: Plugin<Core>;
6
+ export default _default;
@@ -0,0 +1,3 @@
1
+ export * from './lite';
2
+ export * from './store';
3
+ export * from './request';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * PageView与Store通用的lite API
3
+ */
4
+ export declare const setKvItem: (key: string, item: string, options?: {
5
+ expireTime?: number | undefined;
6
+ } | undefined) => Promise<void>;
7
+ export declare const getKvItem: (key: string) => Promise<string>;
8
+ export declare const isPageRuntime: () => boolean;
9
+ export declare const getSystemInfo: () => any;
10
+ export declare const getCurrPageUrl: () => string;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * liteapp 请求方法重写
3
+ *
4
+ * @param opts
5
+ * @returns
6
+ */
7
+ export interface OriginRequestResp {
8
+ status: number;
9
+ data?: any;
10
+ }
11
+ export interface OriginRequestReq extends RequestInit {
12
+ url: RequestInfo;
13
+ }
14
+ export declare const originRequest: (opts: OriginRequestReq) => Promise<OriginRequestResp>;
15
+ export interface HackFetchOptions {
16
+ name: string;
17
+ beforeFetch?: (url: string, option: RequestInit) => void;
18
+ then?: (res: Response, duration: number, url: string, option?: RequestInit) => void;
19
+ catch?: (err: any, duration: number, url: string, option?: RequestInit) => void;
20
+ }
21
+ export declare const hackFetch: (options: HackFetchOptions) => void;
@@ -0,0 +1,7 @@
1
+ import Aegis from '../aegis';
2
+ declare type UseStoreReq = {
3
+ store: any;
4
+ aegisFactory: () => Aegis;
5
+ };
6
+ declare const UseStore: ({ store, aegisFactory }: UseStoreReq) => any;
7
+ export { UseStore };
@@ -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;
@@ -1,17 +1,22 @@
1
+ export declare type WxApi = keyof typeof wx;
2
+ export declare type CloudApi = 'callFunction';
3
+ export declare type HackApi = WxApi | CloudApi;
1
4
  export interface ReqOption {
2
5
  aegisRequestStartTime: number;
6
+ apiName: HackApi;
3
7
  }
4
8
  export interface HackApiCallback<RequestOption = any, SucessRes = any, FailRes = any> {
9
+ apiName?: HackApi;
5
10
  onStart?: (options: RequestOption) => void;
6
11
  success?: (res: SucessRes, options: RequestOption) => void;
7
12
  fail?: (err: FailRes, options: RequestOption) => void;
8
13
  complete?: (err: SucessRes | FailRes, options: RequestOption) => void;
9
14
  }
10
- declare type HackApiCallbackOption = ReqOption & HackApiCallback;
15
+ export declare type HackApiCallbackOption = ReqOption & HackApiCallback;
11
16
  export default abstract class HackApiCore<T extends HackApiCallbackOption, U extends HackApiCallback> {
17
+ apiName?: string;
12
18
  private callbacks;
13
19
  private isOverride;
14
- abstract apiName: string;
15
20
  constructor(cb: U);
16
21
  addCallback(cb: U): void;
17
22
  protected prefixHandler(opts: T): T & {
@@ -23,4 +28,3 @@ export default abstract class HackApiCore<T extends HackApiCallbackOption, U ext
23
28
  private override;
24
29
  protected abstract defineApiProperty(): void;
25
30
  }
26
- export {};
@@ -0,0 +1,17 @@
1
+ import HackApiCore, { HackApiCallback, HackApiCallbackOption, WxApi } from './hack-api';
2
+ declare type HackApiMap = {
3
+ [x in WxApi]?: {
4
+ originApi: Function;
5
+ hackReq: HackNetWork<any, any>;
6
+ };
7
+ };
8
+ export declare const originApiMap: HackApiMap;
9
+ export declare class HackNetWork<T extends HackApiCallbackOption, U extends HackApiCallback> extends HackApiCore<T, U> {
10
+ protected defineApiProperty(): void;
11
+ private hackHandler;
12
+ }
13
+ export declare const hackNetWork: <T extends HackApiCallbackOption, U extends HackApiCallback<any, any, any>>(option: U) => {
14
+ originApi: Function;
15
+ hackReq: HackNetWork<any, any>;
16
+ } | undefined;
17
+ export {};
@@ -0,0 +1,21 @@
1
+ import HackApiCore, { ReqOption, HackApiCallback } from './hack-api';
2
+ export declare type ConnectOption = ReqOption & WechatMiniprogram.ConnectSocketOption;
3
+ export declare type HackConnectCallback = HackApiCallback<ConnectOption, WechatMiniprogram.ConnectSocketSuccessCallback, WechatMiniprogram.GeneralCallbackResult>;
4
+ declare type TaskHackConf = {
5
+ onError: WechatMiniprogram.UDPSocketOnErrorCallback;
6
+ send: HackApiCallback;
7
+ };
8
+ declare type HackWsConnectOpt = {
9
+ connectCallback: HackConnectCallback;
10
+ taskOpt?: TaskHackConf;
11
+ };
12
+ export declare class HackWsConnect extends HackApiCore<ConnectOption, HackConnectCallback> {
13
+ apiName: 'connectSocket';
14
+ private taskHack;
15
+ constructor(props: HackConnectCallback);
16
+ addTaskConf(conf: TaskHackConf): void;
17
+ protected defineApiProperty(): void;
18
+ private hackHandler;
19
+ }
20
+ export declare const toHackWsConnect: (option: HackWsConnectOpt) => HackWsConnect;
21
+ export {};
@@ -1,2 +1,7 @@
1
1
  export declare const getCurrPageUrl: () => string;
2
2
  export declare const extend: (...args: object[]) => object;
3
+ /**
4
+ * 对比版本号
5
+ * 只传一个参数则默认和当前版本对比
6
+ */
7
+ export declare const compareVersion: (ver1: string, ver2: string) => boolean;
@@ -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 };
@@ -21,6 +21,7 @@ interface AsyncPluginOption {
21
21
  }
22
22
  export default class Aegis extends Core {
23
23
  static sessionID: string;
24
+ sendNow: boolean;
24
25
  firstScreenInfo: {
25
26
  element: any;
26
27
  timing: number;
@@ -28,17 +29,12 @@ export default class Aegis extends Core {
28
29
  };
29
30
  constructor(config: WebConfig);
30
31
  getBean(filter?: string[]): string;
31
- requestQueue: {
32
- options: SendOption;
33
- success?: SendSuccess;
34
- fail?: SendFail;
35
- }[];
36
- requesting: boolean;
37
- private resetRequesting;
38
- request(options: SendOption, success?: SendSuccess, fail?: SendFail): boolean | void;
32
+ private getCurrentPageUrl;
33
+ request(options: SendOption, success?: SendSuccess, fail?: SendFail): void;
39
34
  speedLogPipeline: import("../../core/src").Pipeline<any, any>;
40
35
  private static asyncPlugin;
41
36
  static useAsyncPlugin(url: string, options?: AsyncPluginOption): void;
37
+ publishPluginsLogs(): void;
42
38
  uploadLogs(params?: any, conds?: any): void;
43
39
  static urls: {
44
40
  [key: string]: string;
@@ -8,4 +8,5 @@ import webVitals from './web-vitals';
8
8
  import offlineLog from './offline-log';
9
9
  import spa from './spa';
10
10
  import ie from './ie-patch';
11
- export { aid, assetSpeed, cgiSpeed, device, onError, pagePerformance, webVitals, offlineLog, spa, ie, };
11
+ import onClose from './on-close';
12
+ export { aid, assetSpeed, cgiSpeed, device, onError, pagePerformance, webVitals, offlineLog, spa, ie, onClose, };
@@ -0,0 +1,3 @@
1
+ import { Plugin } from "../../../core/src";
2
+ declare let plugin: Plugin<import("../../../core/src").default>;
3
+ export default plugin;
@@ -0,0 +1,3 @@
1
+ export declare const device: {
2
+ [key: string]: Function;
3
+ };
@@ -0,0 +1,14 @@
1
+ export declare type WsError = {
2
+ readyState: number;
3
+ msg: string;
4
+ connectUrl: string;
5
+ };
6
+ declare type EmitError = (e: WsError) => void;
7
+ export declare type HackWsConfig = {
8
+ key: string;
9
+ onErr: EmitError;
10
+ sendErr: EmitError;
11
+ };
12
+ export declare const unHackWs: (conf: HackWsConfig) => void;
13
+ declare const hackWebSocket: (config: HackWsConfig) => void;
14
+ export default hackWebSocket;
@@ -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.55",
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;