aegis-mp-sdk 1.24.46 → 1.24.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/aegis.min.js +3 -3
- package/lib/packages/core/src/core.d.ts +13 -5
- package/lib/packages/core/src/index.d.ts +1 -1
- package/lib/packages/core/src/interface/config.d.ts +1 -1
- package/lib/packages/core/src/interface/env.d.ts +9 -0
- package/lib/packages/core/src/interface/index.d.ts +3 -2
- package/lib/packages/core/src/interface/log.d.ts +2 -2
- package/lib/packages/core/src/interface/send.d.ts +5 -2
- package/lib/packages/core/src/pipes/beforeRequestHooks.d.ts +2 -2
- package/lib/packages/core/src/pipes/index.d.ts +2 -1
- package/lib/packages/core/src/pipes/modifyRequestHooks.d.ts +3 -0
- package/lib/packages/core/src/util/index.d.ts +15 -2
- package/lib/packages/hippy-sdk/src/aegis.d.ts +1 -2
- package/lib/packages/hippy-sdk/src/plugins/offline-log.d.ts +2 -2
- package/lib/packages/mp-sdk/__tests__/util/common-test.d.ts +5 -0
- package/lib/packages/mp-sdk/__tests__/util/index.d.ts +3 -0
- package/lib/packages/mp-sdk/src/adaptor/index.d.ts +1 -0
- package/lib/packages/mp-sdk/src/aegis.d.ts +4 -5
- package/lib/packages/mp-sdk/src/plugins/offlineLog.d.ts +2 -2
- package/lib/packages/mp-sdk/src/plugins/page-performance.d.ts +1 -1
- package/lib/packages/mp-sdk/src/util/hack-api.d.ts +24 -0
- package/lib/packages/mp-sdk/src/util/hack-cloud.d.ts +9 -0
- package/lib/packages/mp-sdk/src/util/hack-request.d.ts +9 -9
- package/lib/packages/mp-sdk/src/util/wxApi.d.ts +1 -0
- package/lib/packages/node-sdk/src/index.d.ts +0 -1
- package/lib/packages/quickapp-sdk/src/aegis.d.ts +1 -2
- package/lib/packages/quickapp-sdk/src/plugins/offline-log.d.ts +2 -2
- package/lib/packages/rn-sdk/src/aegis.d.ts +0 -1
- package/lib/packages/viola-sdk/src/aegis.d.ts +0 -1
- package/lib/packages/web-sdk/src/aegis.d.ts +1 -2
- package/lib/packages/web-sdk/src/plugins/device.d.ts +2 -2
- package/lib/packages/web-sdk/src/util/index.d.ts +2 -0
- package/lib/packages/weex-sdk/src/aegis.d.ts +1 -2
- package/lib/packages/weex-sdk/src/plugins/offline-log.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -384,15 +384,15 @@ Aegis 通过劫持 `wx.request || qq.request` 进行接口测速。
|
|
|
384
384
|
| reportApiSpeed | 可选,boolean,默认 false。<br>是否开启接口测速 |
|
|
385
385
|
| version | 可选,string,默认 sdk 版本号。<br>当前上报版本,当页面使用了pwa或者存在离线包时,可用来判断当前的上报是来自哪一个版本的代码,仅支持`字母数字.,:_-`,长度在 60 位以内 `/^[0-9a-zA-Z.,:_-]{1,60}$/` |
|
|
386
386
|
| delay | 可选,number,默认 1000 ms。<br>上报节流时间,在该时间段内的上报将会合并到一个上报请求中。 |
|
|
387
|
-
| apiDetail | 可选,boolean,默认false。api 失败的时候,是否上报 api 的请求参数和返回值 |
|
|
388
387
|
| repeat | 可选,number,默认 5。<br>重复上报次数,对于同一个错误超过多少次不上报。 |
|
|
388
|
+
| enableHttp2 | 可选,boolean,默认 false。<br> 上报数据是否支持 HTTP2,默认没有开启,以后会考虑改成默认开启。 |
|
|
389
389
|
| offlineLog | 可选,boolean,默认 false。<br>是否使用离线日志 |
|
|
390
390
|
| offlineLogExp | 可选,number,默认 3。<br>离线日志过期天数 |
|
|
391
391
|
| url | 可选,string,默认 '//aegis.qq.com/collect'。<br>日志上报地址 |
|
|
392
392
|
| speedUrl | 可选,string,默认 '//aegis.qq.com/speed'。<br>测速日志上报地址 |
|
|
393
393
|
| performanceUrl | 可选,string,默认 '//aegis.qq.com/speed/performance'。<br>页面性能日志上报地址 |
|
|
394
394
|
| whiteListUrl | 可选,string,默认 '//aegis.qq.com/collect/whitelist'。<br>白名单确认接口 <br>如果想要关闭白名单接口请求,可以传空字符串|
|
|
395
|
-
| api | 可选,object,默认为{}。相关的配置: <br> retCodeHandler: Function, 返回码上报钩子函数。 会传入接口返回数据,返回值为{isErr: boolean, code: string}。<span id="jump">[见示例[1]](#exp1)</span> |
|
|
395
|
+
| api | 可选,object,默认为{}。相关的配置: <br> apiDetail : 可选,boolean,默认false。api 失败的时候,是否上报 api 的请求参数和返回值; <br> retCodeHandler: Function, 返回码上报钩子函数。 会传入接口返回数据,返回值为{isErr: boolean, code: string}。<span id="jump">[见示例[1]](#exp1)</span> |
|
|
396
396
|
| ext1 | 可选,string,自定义上报的额外维度,上报的时候可以被覆盖 |
|
|
397
397
|
| ext2 | 可选,string,自定义上报的额外维度,上报的时候可以被覆盖 |
|
|
398
398
|
| ext3 | 可选,string,自定义上报的额外维度,上报的时候可以被覆盖 |
|
package/lib/aegis.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ====================================================================
|
|
3
|
-
* @tencent/aegis-mp-sdk@1.24.
|
|
3
|
+
* @tencent/aegis-mp-sdk@1.24.49 (c) 2021 Tencent Application Monitor.
|
|
4
4
|
* Author pumpkincai.
|
|
5
|
-
* Last Release Time
|
|
5
|
+
* Last Release Time Tue Dec 07 2021 17:42:24 GMT+0800 (GMT+08:00).
|
|
6
6
|
* Released under the MIT License.
|
|
7
7
|
* Thanks for supporting TAM & 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 n=function(e,t){return(n=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)},s=function(){return(s=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)};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}});function i(t){try{return encodeURIComponent(decodeURIComponent(t))}catch(e){return t}}var g=(e.prototype.indexOf=function(e,t){for(var n=0;n<e.length;n++)if(e[n].callback===t)return n;return-1},e.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)}},e.prototype.one=function(e,t){this.on(e,t,1)},e.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}},e.prototype.clear=function(){this.eventsList={}},e),t=function(e){return(e=Array.isArray(e)?e:[e]).map(function(t,n){return Object.getOwnPropertyNames(t).map(function(e){return i(e)+"["+n+"]="+(void 0===t[e]?"":i(t[e]))}).join("&")}).join("&")+(e.length?"&count="+e.length:"")};function e(){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={}}(U=N=N||{})[U.number=-1]="number",U.string="";function c(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)}var m,a,u,y,f=["ret","retcode","code"],p=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};(P=m=m||{}).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",(q=a=a||{})[q.android=1]="android",q[q.ios=2]="ios",q[q.windows=3]="windows",q[q.macos=4]="macos",q[q.linux=5]="linux",q[q.devtools=6]="devtools",q[q.other=100]="other",(D=u=u||{})[D.unknown=100]="unknown",D[D.wifi=1]="wifi",D[D.net2g=2]="net2g",D[D.net3g=3]="net3g",D[D.net4g=4]="net4g",D[D.net5g=5]="net5g",D[D.net6g=6]="net6g",(J=y=y||{}).LOG="log",J.SPEED="speed",J.PERFORMANCE="performance",J.OFFLINE="offline",J.WHITE_LIST="whiteList",J.VITALS="vitals",J.PV="pv",J.CUSTOM_PV="customPV",J.EVENT="event",J.CUSTOM="custom",J.SDK_ERROR="sdkError";function v(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=S(o),t(o.splice(0,o.length)),void(i&&clearTimeout(i));i&&clearTimeout(i),i=setTimeout(function(){i=null,0<(o=S(o)).length&&t(o.splice(0,o.length))},r.delay)}}function w(e,t){return Array.isArray(e)?t(e.map(function(e){return s(s({},e),{msg:"string"==typeof e.msg?e.msg:[].concat(e.msg).map(p).join(" ")})})):t(s(s({},e),{msg:"string"==typeof e.msg?e.msg:p(e.msg)}))}function b(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||C)}:n.reduce(function(n,i){return function(e,t){return void 0===t&&(t=C),n(e,function(e){return null==i?void 0:i(e,t)})}})}function d(t,n){Object.getOwnPropertyNames(t).forEach(function(e){"function"==typeof t[e]&&"constructor"!==e&&(n?n[e]=function(){}:t[e]=function(){})})}function h(){try{var e=getCurrentPages();return(e[e.length-1]||{}).route||""}catch(e){return""}}function O(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}}}(A.getSystemInfoSync().SDKVersion,"1.1.1")&&A.canIUse?A.canIUse(e):!!A[e]}function R(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])&&void 0!==t&&t.test(e)){i=u[r];break}}return i}function o(i){return M.forEach(function(e){var t;try{i.aegisRequestStartTime=Date.now(),null===(t=e.onStart)||void 0===t||t.call(e,i)}catch(e){}}),B(s(s({},i),{success:function(n){var e;M.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)},fail:function(n){var e;M.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)},complete:function(n){var e;M.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)}}))}function r(e){V||function(){try{Object.defineProperty(F,"request",{get:function(){return o}})}catch(e){console.warn("cannot override `request`, error is: ",e)}finally{V=!0}}(),M.push(e)}var x,E,P,S=function(e){return e.filter(function(n,i){return"static"!==n.type||!e.find(function(e,t){return i!==t&&n.url===e.url&&200===n.status})})},T=function(e){e.level===m.INFO_ALL&&(e.level=m.INFO)},L=function(i){return function(e,n){return i.send({url:i.config.url||"",data:t(e),method:"post",contentType:"application/x-www-form-urlencoded",type:y.LOG,log:e},function(){var t=i.config.onReport;"function"==typeof t&&e.forEach(function(e){t(e)}),"function"==typeof n&&n([])},function(e){"403 forbidden"===e&&i.destroy()})}},C=function(){},k=(G.prototype.init=function(e){this.setConfig(e);for(var t=0;t<G.installedPlugins.length;t++)try{G.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},G.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=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.45",this.bean.aid=e||"",r&&(this.bean.ext1=r),s&&(this.bean.ext2=s),a&&(this.bean.ext3=a),t&&this.lifeCycle.emit("onConfigChange",this.config),this.config},G.use=function(e){-1===G.installedPlugins.indexOf(e)&&e.aegisPlugin&&G.installedPlugins.push(e)},G.unuse=function(e){e=G.installedPlugins.indexOf(e);-1!==e&&G.installedPlugins.splice(e,1)},G.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:m.INFO,msg:e};1===e.length&&e[0].msg&&Object.assign(n,s({},e[0]),{level:m.INFO}),this.normalLogPipeline(n)},G.prototype.infoAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:m.INFO_ALL,msg:e};1===e.length&&e[0].msg&&Object.assign(n,s({},e[0]),{level:m.INFO_ALL}),this.normalLogPipeline(n)},G.prototype.report=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:m.REPORT,msg:e};1===e.length&&e[0].msg&&Object.assign(n,s({},e[0])),this.normalLogPipeline(n)},G.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:m.ERROR,msg:e};1===e.length&&e[0].msg&&Object.assign(n,s({},e[0]),{level:m.ERROR}),this.normalLogPipeline(n)},G.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},G.prototype.reportPv=function(e){var t,n=this;e&&(console.warn("reportPv is deprecated, please use reportEvent"),t=""+Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+n.bean[e]}).join("&"),this.send({url:this.config.url+"/"+e+"?"+t,addBean:!1,type:y.CUSTOM_PV},function(){},function(e){"403 forbidden"===e&&n.destroy()}))},G.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"))},G.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")},G.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")},G.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")},G.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")},G.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})},G.prototype.extendBean=function(e,t){this.bean[e]=t},G.prototype.send=function(o,r,s){var i,a,u,e=this;b([(a=o.type,function(e,t){if(!e)return t(e);e=Array.isArray(e)?e:[e],i.lifeCycle.emit("beforeRequest",e);var n=i.config.beforeRequest;(e="function"==typeof n?e.filter(function(e){return!1!==n({logs:e,logType:a})}):e).length&&t(e)}),function(n,i){e.request(o,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i({isErr:!1,result:e,logType:o.type,logs:n}),null==r||r.apply(void 0,e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i({isErr:!0,result:e,logType:o.type,logs:n}),null==s||s(e)})},(u=i=this,function(e,t){u.lifeCycle.emit("afterRequest",e);var n=u.config.afterRequest;"function"==typeof n&&!1===n(e)||t(e)})])(o.log)},G.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},G.prototype.sendSDKError=function(e){this.send({url:this.config.url+"?id=1085&msg[0]="+encodeURIComponent(p(e))+"&level[0]=2&from="+this.config.id+"&count=1&version="+this.config.id+"(1.24.45)",addBean:!1,method:"get",type:y.SDK_ERROR})},G.prototype.destroy=function(e){void 0===e&&(e=!1);var t,n,i=G.instances.indexOf(this);-1!==i&&G.instances.splice(i,1);for(var o=G.installedPlugins.length-1;0<=o;o--)try{var r=G.installedPlugins[o];r.unpatch(this),0===r.countInstance()&&(r.uninstall(),G.unuse(r),r=null)}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 s=this;s.constructor!==Object&&d(s,this),s=Object.getPrototypeOf(s););0===G.instances.length&&(e=Object.getPrototypeOf(this).constructor,d(e),d(G))}},G.instances=[],G.LOG_TYPE=m,G.installedPlugins=[],G),N=(K.prototype.patch=function(e){this.canUse(e)&&this.exist(e)&&(this.instances.push(e),this.triggerInit(e),this.triggerOnNewAegis(e))},K.prototype.unpatch=function(e){e=this.instances.indexOf(e);-1!==e&&this.instances.splice(e,1)},K.prototype.countInstance=function(){return this.instances.length},K.prototype.uninstall=function(){var e;null===(e=null===(e=this.option)||void 0===e?void 0:e.destroy)||void 0===e||e.apply(this)},K.prototype.walk=function(n){var i=this;this.instances.forEach(function(e){var t=i.canUse(e);t&&n(e,t)})},K.prototype.canUse=function(e){e=this.getConfig(e);return!(!e||"object"!=typeof e)||!!e},K.prototype.getConfig=function(e){return null===(e=e.config)||void 0===e?void 0:e[this.name]},K.prototype.exist=function(e){return-1===this.instances.indexOf(e)},K.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)))},K.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))},K),A=wx||qq,I=new N({name:"offlineLog",onNewAegis:function(o,e){if(A.getFileSystemManager)try{var t=o.config,n=t.id,r=void 0===n?"":n,i=t.uin,s=void 0===i?0:i,a=t.offlineUrl,u=void 0===a?"":a,c=t.offlineLogLimit,l=new j({limit:c});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:u+"/offlineAuto"},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:u+"/offlineLog",data:{logs:t,secretKey:n,id:r,uin:s,aid:i},method:"post"},function(){l.clearLogs()})}))})})}catch(o){console.error(o)}else console.warn("[aegis-mp-sdk]unsupport getFileSystemManager offline log not work!")}}),j=(H.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)}})},H.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)}})}})},H),U=new N({name:"device",onNewAegis:function(u){return e=this,c=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(c.next(e))}catch(e){t(e)}}function o(e){try{r(c.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((c=c.apply(e,s||[])).next())});var e,s,a,c},setSystemInfo:function(n){var i=this;try{O("getSystemInfo")&&A.getSystemInfo({success:function(e){var t=e.platform,e=e.model;n.extendBean("platform",i.getPlatFormType(t)),n.extendBean("model",e)}})}catch(n){}},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){O("onNetworkStatusChange")&&A.onNetworkStatusChange(function(e){e=R(e.networkType);t.extendBean("netType",e)})},setNetworkType:function(t){O("getNetworkType")&&A.getNetworkType({success:function(e){e=R(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)}}),_=A.request,q=(n(E=W,P=x=k),E.prototype=null===P?Object.create(P):($.prototype=P.prototype,new $),Object.defineProperty(W.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(h()):"from="+encodeURIComponent(h())},enumerable:!1,configurable:!0}),W.prototype.initOfflineLog=function(){W.use(I)},W.prototype.uploadLogs=function(e,t){this.lifeCycle.emit("uploadLogs",e=void 0===e?{}:e,t=void 0===t?{}:t)},W.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(h()),this.send({url:this.config.url+"/"+e+"?"+t,addBean:!1},function(){},function(){}))},W.__version__="1.24.45",W.sessionID="session-"+Date.now(),W.asyncPluginIndex=0,W),D=new N({name:"aid",onNewAegis:function(t){this.initAid(function(e){t.bean.aid=e,t.config.aid=e})},initAid:function(t){A.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)});A.setStorage({key:"AEGIS_ID",data:e,success:function(){t(e)}})}})}}),F=wx||qq,M=[],B=F.request,V=!1,J=new N({name:"reportApiSpeed",override:!1,onNewAegis:function(e){this.override||(this.override=!0,this.hackRequest(e.config))},hackRequest:function(a){var u=this;r({success:function(e,t){var n={method:t.method||"get",url:c(t.url),duration:Date.now()-t.aegisRequestStartTime,status:e.statusCode||0,isHttps:l(t.url),type:"fetch"},i=a.apiDetail,o="req url: "+n.url+" \n \nreq method: "+n.method+" \n \nreq param: "+(i?p(t.data):"")+" \n \nres duration: "+n.duration+" \n \nres status: "+(e.statusCode||0)+" \n \nres data: "+(i?JSON.stringify(e.data):"");u.publishNormalLog({msg:o,level:m.API_RESPONSE}),u.publishSpeedLog(n);var r,s;("function"==typeof(null===(i=a.api)||void 0===i?void 0:i.retCodeHandler)?(s=(r=a.api.retCodeHandler(e.data,t.url,t,e)||{}).code,r=void 0!==(r=r.isErr)&&r,n.ret=s=void 0===s?0:s,r):(r=function(e,t){var n;try{"string"==typeof e&&(e=JSON.parse(e)),"function"==typeof(null===(n=null==t?void 0:t.ret)||void 0===n?void 0:n.join)&&(f=[].concat(t.ret.map(function(e){return e.toLowerCase()})));var i=Object.getOwnPropertyNames(e).filter(function(e){return-1!==f.indexOf(e.toLowerCase())});return i.length?""+e[i[0]]:"unknown"}catch(e){return"unknown"}}(e.data,a.api),n.ret=r,n=(n=null===(e=a.api)||void 0===e?void 0:e.errCode)&&[].concat(n),s=(s=null===(e=a.api)||void 0===e?void 0:e.code)&&[].concat(s),n&&-1!==n.indexOf(r)||s&&-1===s.indexOf(r)||!n&&!s&&"0"!==r&&"unknown"!==r))&&u.publishNormalLog({msg:o,level:m.RET_ERROR})},fail:function(e,t){t={method:t.method||"get",url:c(t.url),duration:Date.now()-t.aegisRequestStartTime,status:0,isHttps:l(t.url),type:"fetch"};u.publishSpeedLog(t)}})},publishSpeedLog:function(t){this.$walk(function(e){e.speedLogPipeline(t)})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})}}),k=new N({name:"onError",onNewAegis:function(e){e=e.config;this.listenError(),this.hackRequest(e)},listenError:function(){var t=this;A.onError(function(e){e&&t.publishErrorLog({msg:e,level:m.ERROR})})},publishErrorLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},hackRequest:function(s){var a=this;r({complete:function(e,t){var n=e.errMsg,i=e.statusCode,o=e.data,r=s.apiDetail,e="";-1<n.indexOf("timeout")?e="timeout":-1<n.indexOf("fail")||!i||i<0?e="failed":400<=i&&(e="error"),e&&a.publishErrorLog({msg:"AJAX_ERROR: request "+e+"\n \nres status: "+(i||0)+"\n \nres duration: "+(Date.now()-t.aegisRequestStartTime)+"\n \nres data: "+(r?p(o):"")+"\n \nreq url: "+t.url+"\n \nreq method: "+(t.method||"get")+"\n \nreq param: "+(r?p(t.data):"")+"\n \nerrMsg: "+n.slice(0,1e3),level:m.AJAX_ERROR})}})}}),P=new N({name:"reportAssetSpeed",isStart:!1,onNewAegis:function(e){this.isStart||(this.isStart=!0,this.start(e))},start:function(){var t=this;A.getPerformance&&A.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:c(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))})}}),N=(new N({name:"pagePerformance"}),new N({name:"pagePerformance",onNewAegis:function(e){try{O("getPerformance")&&this.reportPerformance(e),this.setPagePV(e)}catch(e){}},reportPerformance:function(r){var s=this,e=A.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(e,t){var n,i,o=[],r=this.$getConfig(t),s=-1===(null===(n=t.config.performanceUrl)||void 0===n?void 0:n.indexOf("?"))?"?":"&";for(i in e)o.push(i+"="+e[i]);"function"==typeof r.urlHandler?this.$walk(function(e){e.send({url:t.config.performanceUrl+s+o.join("&")+"&from="+(encodeURIComponent(r.urlHandler())||window.location.href),beanFilter:["from"],type:y.PERFORMANCE})}):this.$walk(function(e){e.send({url:t.config.performanceUrl+s+o.join("&"),type:y.PERFORMANCE})})},setPagePV:function(e){var t=this;A.onAppRoute&&A.onAppRoute(function(e){"appLaunch"!==e.openType&&t.$walk(function(e){e.send({url:""+e.config.pvUrl,type:y.PV})})})}}));function W(e){var i,o,r,c=x.call(this,e)||this;c.originRequest=_,c.speedLogPipeline=b([(o=c.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)}),v(c),(i=c,function(t,n){O("getNetworkType")?A.getNetworkType({success:function(e){e=R(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)},function(e){var t,n,i,o;c.send({url:""+c.config.speedUrl,method:"post",data:(t=e,n=c.bean,i={fetch:[],static:[]},o={},Array.isArray(t)?t.forEach(function(e){var t;null===(t=i[e.type])||void 0===t||t.push(e)}):null===(e=i[t.type])||void 0===e||e.push(t),o.payload=JSON.stringify(s({duration:i},n)),o)})}]),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||O("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.send(e.options,e.success,e.fail)},a=e,u=c.config.onBeforeRequest;if((a=u?u(e,c):a)&&a.url)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({url:o,success:t,fail:n,complete:s})):("string"==typeof a.data&&(a.data=a.data.replace(/eval/gi,"evaI")),c.originRequest({url:o,header:a.contentType?{"content-type":a.contentType}:void 0,method:"POST",data:a.data,success:t,fail:n,complete:s})),!0;o="";return a||(o="Sending request blocked",console.log(o)),a.url||(o="Please handle the parameters reasonably, options.url is necessary",console.warn(o)),null==n||n(o),s(),!1}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",W.sessionID),c.extendBean("referer",(O("getLaunchOptionsSync")?A.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 $(){this.constructor=E}function H(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:h()},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=A.env.USER_DATA_PATH+e,this.fileSystem=A.getFileSystemManager(),this.limitSize=t}function K(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 G(e){var n,t,s,i,a,u,o,c,r,l,f,p,d,h=this;this.config={version:0,delay:1e3,onError:!0,apiDetail:!1,repeat:5,random:1,aid:!0,device:!0,pagePerformance:!0,webVitals:!0,speedSample:!0,hostUrl:"https://aegis.qq.com",url:"",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",webVitalsUrl:"",eventUrl:""},this.isWhiteList=!1,this.lifeCycle=new g,this.bean={},this.normalLogPipeline=b([v(this,5),w,function(e,t){if("number"!=typeof n.config.random&&(console.warn("random must in [0, 1], default is 1."),n.config.random=1),Math.random()<n.config.random)return t(e)},(p=(n=this).config,d={},function(e,t){var n="number"==typeof p.repeat?p.repeat:5;if(0===n)return t(e);t(e.filter(function(e){return e.level!==m.ERROR&&e.level!==m.PROMISE_ERROR&&e.level!==m.AJAX_ERROR&&e.level!==m.SCRIPT_ERROR&&e.level!==m.IMAGE_ERROR&&e.level!==m.CSS_ERROR&&e.level!==m.MEDIA_ERROR||(d[e.msg]=d[e.msg]||0,d[e.msg]+=1,!(d[e.msg]>n))}))}),(l=this.lifeCycle.emit,f=this.config,function(e,t){var n=f.logCreated;if("function"!=typeof n)return l("beforeWrite",e),t(e);e=e.filter(function(e){return!1!==n(e)});return l("beforeWrite",e),t(e)}),(r=this,setTimeout(function(){var e=r.config.pvUrl,e=void 0===e?"":e;e&&r.send({url:e,type:y.PV},function(){},function(e){"403 forbidden"===e&&r.destroy()})},100),function(e,t){t(e)}),(o=u=a=!1,c=[],(s=this).lifeCycle.on("onConfigChange",function(){i&&clearTimeout(i),i=setTimeout(function(){var e;!o&&s.config&&(o=!0,(e=void 0===(e=s.config.whiteListUrl)?"":e)&&s.send({url:e,type:y.WHITE_LIST},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.isWhiteList&&c.length?L(s)(c.splice(0),function(){}):!s.isWhiteList&&c.length&&(c.length=0);var r=s.config.onWhitelist;"function"==typeof r&&r(a)}catch(e){}},function(e){"403 forbidden"===e&&s.destroy(),u=!0}),o=!1)},s.config.uin?50:500)}),s.lifeCycle.on("destroy",function(){c.length=0}),function(e,t){a?t(e.concat(c.splice(0)).map(function(e){return T(e),e})):(e=e.filter(function(e){return e.level!==m.INFO&&e.level!==m.API_RESPONSE?(T(e),!0):(u||(c.push(e),200<=c.length&&(c.length=200)),!1)})).length&&t(e)}),function(e,t){var n=JSON.parse(JSON.stringify(e));h.lifeCycle.emit("beforeReport",n);var i=h.config.beforeReport;(e="function"==typeof i?e.filter(function(e){return!1!==i(e)}):e).length&&t(e)},L(this)]),this.eventPipeline=b([v(this,5),function(e){var t=e.map(function(e){return{name:e.name,ext1:e.ext1||h.config.ext1||"",ext2:e.ext2||h.config.ext2||"",ext3:e.ext3||h.config.ext3||""}});return h.send({url:h.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(t)),type:y.EVENT,log:e},function(){},function(e){"403 forbidden"===e&&h.destroy()})}]),this.timeMap={},this.customTimePipeline=b([v(this,5),function(e){return h.send({url:h.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:y.CUSTOM,log:e},function(){},function(e){"403 forbidden"===e&&h.destroy()})}]),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),G.instances.push(this)}return q.use(k),q.use(J),q.use(D),q.use(P),q.use(N),q.use(U),q});
|
|
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 a=function(){return(a=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function s(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var i=Array(e),o=0,t=0;t<n;t++)for(var r=arguments[t],s=0,a=r.length;s<a;s++,o++)i[o]=r[s];return i}Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(null==e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),n=1;n<arguments.length;n++)if(null!=(i=arguments[n]))for(var i=Object(i),o=Object.keys(Object(i)),r=0,s=o.length;r<s;r++){var a=o[r],l=Object.getOwnPropertyDescriptor(i,a);null!=l&&l.enumerable&&(t[a]=i[a])}return t}});var n=(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={}}(V={})[V.number=-1]="number",V.string="";function l(e,t){return"string"==typeof e?e.split("?")[t?1:0]||"":e}function u(e){return"string"==typeof e&&e.startsWith("//")?"undefined"!=typeof location&&"https:"===location.protocol:/^https/.test(e)}function c(e,t,n){var i;try{if("function"==typeof(null==t?void 0:t.retCodeHandler)){var o=t.retCodeHandler(e,null==n?void 0:n.url,null==n?void 0:n.ctx)||{};return{code:void 0===(r=o.code)?"unknown":r,isErr:o.isErr}}"string"==typeof e&&(e=JSON.parse(e)),"function"==typeof(null===(i=null==t?void 0:t.ret)||void 0===i?void 0:i.join)&&(v=[].concat(t.ret.map(function(e){return e.toLowerCase()})));var r,s=Object.getOwnPropertyNames(e).filter(function(e){return-1!==v.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(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}var p,d,h,g,m,v=["ret","retcode","code","errcode"],y=function(n,i){void 0===i&&(i=3);var o,r,s,a="";return Array.isArray(n)?(a+="[",o=n.length,n.forEach(function(e,t){a+="object"==typeof e&&1<i?y(e,i-1):w(e),a+=t===o-1?"":","}),a+="]"):n instanceof Object?(a="{",r=Object.keys(n),s=r.length,r.forEach(function(e,t){"object"==typeof n[e]&&1<i?a+='"'+e+'":'+y(n[e],i-1):a+=b(e,n[e]),a+=t===s-1||t<s-1&&void 0===n[r[t+1]]?"":","}),a+="}"):a+=n,a},b=function(e,t){var n=typeof t,i="";return"string"==n||"object"==n?i+='"'+e+'":"'+t+'"':"function"==typeof t?i+='"'+e+'":"function '+t.name+'"':"symbol"==typeof t?i+='"'+e+'":"symbol"':"number"!=typeof t&&"boolean"!=n||(i+='"'+e+'": '+t),i},w=function(e){var t=typeof e;return""+("undefined"==t||"symbol"==t||"function"==t?"null":"string"==t||"object"==t?'"'+e+'"':e)},r=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(a({duration:i},t)),o};(Q=p=p||{}).INFO_ALL="-1",Q.API_RESPONSE="1",Q.INFO="2",Q.ERROR="4",Q.PROMISE_ERROR="8",Q.AJAX_ERROR="16",Q.SCRIPT_ERROR="32",Q.IMAGE_ERROR="64",Q.CSS_ERROR="128",Q.CONSOLE_ERROR="256",Q.MEDIA_ERROR="512",Q.RET_ERROR="1024",Q.REPORT="2048",Q.PV="4096",Q.EVENT="8192",(z=d=d||{})[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",(Y=h=h||{})[Y.unknown=100]="unknown",Y[Y.wifi=1]="wifi",Y[Y.net2g=2]="net2g",Y[Y.net3g=3]="net3g",Y[Y.net4g=4]="net4g",Y[Y.net5g=5]="net5g",Y[Y.net6g=6]="net6g",(Z=g=g||{}).LOG="log",Z.SPEED="speed",Z.PERFORMANCE="performance",Z.OFFLINE="offline",Z.WHITE_LIST="whiteList",Z.VITALS="vitals",Z.PV="pv",Z.CUSTOM_PV="customPV",Z.EVENT="event",Z.CUSTOM="custom",Z.SDK_ERROR="sdkError",(se=m=m||{}).production="production",se.gray="gray",se.pre="pre",se.daily="daily",se.local="local",se.others="others";function O(e){return e.filter(function(n,i){return"static"!==n.type||!e.find(function(e,t){return i!==t&&n.url===e.url&&200===n.status})})}function R(e){e.level===p.INFO_ALL&&(e.level=p.INFO)}function P(o){return function(e,t){o.lifeCycle.emit("modifyRequest",e);var n=o.config.modifyRequest;if("function"==typeof n)try{var i=n(e);"object"==typeof i&&"url"in i&&(e=i)}catch(e){console.error(e)}t(e)}}function 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 S(){}function x(t,n){Object.getOwnPropertyNames(t).forEach(function(e){"function"==typeof t[e]&&"constructor"!==e&&(n?n[e]="sendPipeline"===e?function(){return function(){}}:function(){}:t[e]=function(){})})}function T(){try{var e=getCurrentPages();return(e[e.length-1]||{}).route||""}catch(e){return""}}function L(e){return C?C.addCallback(e):C=new ne(e),C}var C,k,N,U,j=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)}},A=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=O(o),t(o.splice(0,o.length)),void(i&&clearTimeout(i));i&&clearTimeout(i),i=setTimeout(function(){i=null,0<(o=O(o)).length&&t(o.splice(0,o.length))},r.delay)}},I=function(e,t){return Array.isArray(e)?t(e.map(function(e){return a(a({},e),{msg:"string"==typeof e.msg?e.msg:[].concat(e.msg).map(f).join(" ")})})):t(a(a({},e),{msg:"string"==typeof e.msg?e.msg:f(e.msg)}))},_=function(s){var e,a=!1,l=!1,t=!1,u=[];return s.lifeCycle.on("onConfigChange",function(){e&&clearTimeout(e),e=setTimeout(function(){var e,n;!t&&s.config&&(t=!0,e=s.config.whiteListUrl,(n=void 0===e?"":e)&&s.sendPipeline([function(e,t){t({url:n,type:g.WHITE_LIST,success:function(e){l=!0;try{var t=e.data||JSON.parse(e),n=t.retcode,i=t.result,o=void 0===i?{}:i;if(0===n){if(a=o.is_in_white_list,s.isWhiteList=a,o.shutdown)return void s.destroy();0<=o.rate&&o.rate<=1&&(s.config.random=o.rate,s.isGetSample=!1)}s.isWhiteList&&u.length?D(s)(u.splice(0),function(){}):!s.isWhiteList&&u.length&&(u.length=0);var r=s.config.onWhitelist;"function"==typeof r&&r(a)}catch(e){}},fail:function(e){"403 forbidden"===e&&s.destroy(),l=!0}})}],g.WHITE_LIST)(null),t=!1)},s.config.uin?50:500)}),s.lifeCycle.on("destroy",function(){u.length=0}),function(e,t){var n;a||null!==(n=null===(n=s.config)||void 0===n?void 0:n.api)&&void 0!==n&&n.reportRequst?t(e.concat(u.splice(0)).map(function(e){return R(e),e})):(e=e.filter(function(e){return e.level!==p.INFO&&e.level!==p.API_RESPONSE?(R(e),!0):(l||(u.push(e),200<=u.length&&(u.length=200)),!1)})).length&&t(e)}},q=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!==p.ERROR&&e.level!==p.PROMISE_ERROR&&e.level!==p.AJAX_ERROR&&e.level!==p.SCRIPT_ERROR&&e.level!==p.IMAGE_ERROR&&e.level!==p.CSS_ERROR&&e.level!==p.MEDIA_ERROR||(o[e.msg]=o[e.msg]||0,o[e.msg]+=1,!(o[e.msg]>n))}))}},D=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(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:g.LOG,log:e,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}],g.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]=""}),a(a({},t),e)}))),e}(i,["ext1","ext2","ext3"]),t(n?i:i[0]))}},M=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||S)}:n.reduce(function(n,i){return function(e,t){return void 0===t&&(t=S),n(e,function(e){return null==i?void 0:i(e,t)})}})},B=(Object.defineProperty(de.prototype,"__version__",{get:function(){return console.warn("__version__ has discard, please use version"),"1.24.49"},enumerable:!1,configurable:!0}),Object.defineProperty(de.prototype,"LogType",{get:function(){return console.warn("LogType has discard, please use logType"),p},enumerable:!1,configurable:!0}),de.prototype.init=function(e){this.setConfig(e);for(var t=0;t<de.installedPlugins.length;t++)try{de.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},de.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,l=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.49",this.bean.aid=e||"",this.bean.env=function(){switch(l){case m.production:case m.gray:case m.pre:case m.daily:case m.local:case m.others:return 1;default:return}}()?l:m.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},de.use=function(e){-1===de.installedPlugins.indexOf(e)&&e.aegisPlugin&&de.installedPlugins.push(e)},de.unuse=function(e){e=de.installedPlugins.indexOf(e);-1!==e&&de.installedPlugins.splice(e,1)},de.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:p.INFO,msg:e};1===e.length&&e[0].msg&&Object.assign(n,a({},e[0]),{level:p.INFO}),this.normalLogPipeline(n)},de.prototype.infoAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:p.INFO_ALL,msg:e};1===e.length&&e[0].msg&&Object.assign(n,a({},e[0]),{level:p.INFO_ALL}),this.normalLogPipeline(n)},de.prototype.report=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:p.REPORT,msg:e};1===e.length&&e[0].msg&&Object.assign(n,a({},e[0])),this.normalLogPipeline(n)},de.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:p.ERROR,msg:e};1===e.length&&e[0].msg&&Object.assign(n,a({},e[0]),{level:p.ERROR}),this.normalLogPipeline(n)},de.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},de.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:g.CUSTOM_PV,fail:function(e){"403 forbidden"===e&&o.destroy()}})}],g.CUSTOM_PV)(null))},de.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"))},de.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")},de.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")},de.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")},de.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")},de.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})},de.prototype.extendBean=function(e,t){this.bean[e]=t},de.prototype.sendPipeline=function(e,t){var n,r=this;return M(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];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];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)]))},de.prototype.send=function(e,o,r){var t=this;return M([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)},de.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},de.prototype.sendSDKError=function(e){var n=this;this.sendPipeline([function(e,t){t({url:n.config.url+"?id=1085&msg[0]="+encodeURIComponent(f(e))+"&level[0]=2&from="+n.config.id+"&count=1&version="+n.config.id+"(1.24.49)",addBean:!1,method:"get",type:g.SDK_ERROR,log:e})}],g.SDK_ERROR)(e)},de.prototype.destroy=function(e){void 0===e&&(e=!1);var t,n,i=de.instances.indexOf(this);-1!==i&&de.instances.splice(i,1);for(var o=de.installedPlugins.length-1;0<=o;o--)try{de.installedPlugins[o].unpatch(this)}catch(e){this.sendSDKError(e)}if(this.lifeCycle.emit("destroy"),this.lifeCycle.clear(),e)t=this,n=Object.getOwnPropertyDescriptors(t),Object.keys(n).forEach(function(e){n[e].writable&&(t[e]=null)}),Object.setPrototypeOf(this,null);else{for(var r=this;r.constructor!==Object&&x(r,this),r=Object.getPrototypeOf(r););0===de.instances.length&&(e=Object.getPrototypeOf(this).constructor,x(e),x(de))}},de.version="1.24.49",de.instances=[],de.logType=p,de.environment=m,de.installedPlugins=[],de),V=(pe.prototype.patch=function(e){this.canUse(e)&&this.exist(e)&&(this.instances.push(e),this.triggerInit(e),this.triggerOnNewAegis(e))},pe.prototype.unpatch=function(e){e=this.instances.indexOf(e);-1!==e&&this.instances.splice(e,1)},pe.prototype.countInstance=function(){return this.instances.length},pe.prototype.uninstall=function(){var e;null===(e=null===(e=this.option)||void 0===e?void 0:e.destroy)||void 0===e||e.apply(this)},pe.prototype.walk=function(n){var i=this;this.instances.forEach(function(e){var t=i.canUse(e);t&&n(e,t)})},pe.prototype.canUse=function(e){e=this.getConfig(e);return!(!e||"object"!=typeof e)||!!e},pe.prototype.getConfig=function(e){return null===(e=e.config)||void 0===e?void 0:e[this.name]},pe.prototype.exist=function(e){return-1===this.instances.indexOf(e)},pe.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)))},pe.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))},pe),J=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}}}(J.getSystemInfoSync().SDKVersion,"1.1.1")&&J.canIUse?J.canIUse(e):!!J[e]},G=new V({name:"offlineLog",onNewAegis:function(o){if(J.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 $({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:g.OFFLINE,log:g.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:g.OFFLINE,log:t},function(){u.clearLogs()})}))})})}catch(o){console.error(o)}else console.warn("[aegis-mp-sdk]unsupport getFileSystemManager offline log not work!")}}),$=(fe.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)}})},fe.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)}})}})},fe),K=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=h.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=h[r];break}}return i},Q=new V({name:"device",onNewAegis:function(l){return e=this,u=function(){return n=this,i=function(e){return this.setSystemInfo(l),this.refreshNetwork(l),this.setNetworkChange(l),[2]},a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,r&&(s=2&t[0]?r.return:t[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,t[1])).done)return s;switch(r=0,(t=s?[2&t[0],s.value]:t)[0]){case 0:case 1:s=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,r=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!((s=0<(s=a.trys).length&&s[s.length-1])||6!==t[0]&&2!==t[0])){a=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){a.label=t[1];break}if(6===t[0]&&a.label<s[1]){a.label=s[1],s=t;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(t);break}s[2]&&a.ops.pop(),a.trys.pop();continue}t=i.call(n,a)}catch(e){t=[6,e],r=0}finally{o=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}var n,i,o,r,s,a,t},new(a=(a=s=void 0)||Promise)(function(n,t){function i(e){try{r(u.next(e))}catch(e){t(e)}}function o(e){try{r(u.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?n(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(i,o)}r((u=u.apply(e,s||[])).next())});var e,s,a,u},setSystemInfo:function(s){var a=this;try{W("getSystemInfo")&&J.getSystemInfo({success:function(e){var t=e.platform,n=e.model,i=e.windowHeight,o=e.windowWidth,r=e.screenWidth,e=e.screenHeight;s.extendBean("platform",a.getPlatFormType(t)),s.extendBean("model",n),s.extendBean("vp",o+" * "+i),s.extendBean("sr",r+" * "+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=d.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=d[r];break}}return i},setNetworkChange:function(t){W("onNetworkStatusChange")&&J.onNetworkStatusChange(function(e){e=K(e.networkType);t.extendBean("netType",e)})},setNetworkType:function(t){W("getNetworkType")&&J.getNetworkType({success:function(e){e=K(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)}}),X=J.request,z=(e(ce,U=B),Object.defineProperty(ce.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}),ce.prototype.initOfflineLog=function(){ce.use(G)},ce.prototype.uploadLogs=function(e,t){this.lifeCycle.emit("uploadLogs",e=void 0===e?{}:e,t=void 0===t?{}:t)},ce.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:g.CUSTOM_PV,log:g.CUSTOM_PV},function(){},function(){}))},ce.sessionID="session-"+Date.now(),ce.asyncPluginIndex=0,ce),Y=new V({name:"aid",onNewAegis:function(t){this.initAid(function(e){t.bean.aid=e,t.config.aid=e})},initAid:function(t){J.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)});J.setStorage({key:"AEGIS_ID",data:e,success:function(){t(e)}})}})}}),Z=(ue.prototype.addCallback=function(e){e&&this.callbacks.push(e)},ue.prototype.prefixHandler=function(e){e.aegisRequestStartTime=Date.now()},ue.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)},ue.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)},ue.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)},ue.prototype.override=function(){try{this.defineApiProperty()}catch(e){console.warn("cannot override `"+this.apiName+"`, error is: "+e)}finally{this.isOverride=!0}},ue),ee=wx||qq,te=ee.request,ne=(e(le,N=Z),le.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(ee,"request",{get:function(){return e.hackHandler.bind(e)}})},le.prototype.hackHandler=function(i){var o=this;return this.prefixHandler(i),new Promise(function(t,n){te(a(a({},i),{success:function(e){o.successHandler(e,i),t(e)},fail:function(e){o.failHandler(e,i),n(e)},complete:function(e){o.completeHandler(e,i)}}))})},le),ie=wx||qq,oe=null===(se=ie.cloud)||void 0===se?void 0:se.callFunction,re=(e(ae,k=Z),ae.prototype.defineApiProperty=function(){var e=this;ie.cloud&&ie.cloud.callFunction&&Object.defineProperty(ie.cloud,"callFunction",{get:function(){return e.hackHandler.bind(e)}})},ae.prototype.hackHandler=function(i){var o=this;return this.prefixHandler(i),new Promise(function(t,n){oe(a(a({},i),{success:function(e){o.successHandler(e,i),t(e)},fail:function(e){o.failHandler(e,i),n(e)},complete:function(e){o.completeHandler(e,i)}}))})},ae),B=new V({name:"reportApiSpeed",override:!1,onNewAegis:function(e){this.override||(this.override=!0,this.hackRequest(e.config),this.overrideCallFunction(e.config))},hackRequest:function(o){var r=this;L({success:function(e,t){var n={method:t.method||"get",url:l(t.url),duration:Date.now()-t.aegisRequestStartTime,status:e.statusCode||0,isHttps:u(t.url),type:"fetch"},i=null===(i=o.api)||void 0===i?void 0:i.apiDetail,i="req url: "+n.url+" \n \nreq method: "+n.method+" \n \nreq param: "+(i?f(t.data):"")+" \n \nres duration: "+n.duration+" \n \nres status: "+(e.statusCode||0)+" \n \nres data: "+(i?y(e.data):"");r.publishNormalLog({msg:i,level:p.API_RESPONSE});t=c(e.data,o.api,{url:t.url,ctx:e})||{},e=t.code,t=t.isErr;n.ret=e,n.isErr=+t,r.publishSpeedLog(n),t&&r.publishNormalLog({msg:i,level:p.RET_ERROR})},fail:function(e,t){t={method:t.method||"get",url:l(t.url),duration:Date.now()-t.aegisRequestStartTime,status:0,isHttps:u(t.url),type:"fetch"};r.publishSpeedLog(t)}})},overrideCallFunction:function(l){var u=this;new re({success:function(e,t){var n={method:"call",url:"wx.cloud.callFunction."+t.name,duration:Date.now()-t.aegisRequestStartTime,status:200,type:"fetch",errMsg:e.errMsg,isHttps:!0},i=null===(a=l.api)||void 0===a?void 0:a.apiDetail,o="req url: "+n.url+"\n \nreq type: "+n.type+"\n \nres duration: "+n.duration+"\n \nres errMsg: "+n.errMsg+"\n \nres data: "+(i?y(e.result):"")+"\n ";u.publishNormalLog({msg:o,level:p.API_RESPONSE});var r,s,a=!1,a=(s="function"==typeof(null===(i=l.api)||void 0===i?void 0:i.retCodeCloudFunctionHandler)?(r=(t=l.api.retCodeCloudFunctionHandler(e.result,t.name,t,e)||{}).code,void 0!==(t=t.isErr)&&t):(r=(s=c(e.result,l.api,{url:n.url,ctx:e})||{}).code,s.isErr),n.ret=r,s);n.isErr=+a,u.publishSpeedLog(n),a&&u.publishNormalLog({msg:o,level:p.RET_ERROR})},fail:function(e,t){e={method:"call",url:"wx.cloud.callFunction."+t.name,duration:Date.now()-t.aegisRequestStartTime,status:0,type:"fetch",errMsg:e.errMsg,isHttps:!0};u.publishSpeedLog(e)}})},publishSpeedLog:function(t){this.$walk(function(e){e.speedLogPipeline(t)})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})}}),se=new V({name:"onError",onNewAegis:function(e){e=e.config;this.listenError(),this.hackRequest(e)},listenError:function(){var t=this;J.onError(function(e){e&&t.publishErrorLog({msg:e,level:p.ERROR})}),W("onUnhandledRejection")&&J.onUnhandledRejection(function(e){e=e.reason;e&&t.publishErrorLog({msg:e,level:p.PROMISE_ERROR})})},publishErrorLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},hackRequest:function(s){var a=this;L({complete:function(e,t){var n,i=e.errMsg,o=e.statusCode,r=e.data,e=null===(e=s.api)||void 0===e?void 0:e.apiDetail;s.hostUrl&&-1<(null===(n=t.url)||void 0===n?void 0:n.indexOf(s.hostUrl))||(n="",-1<i.indexOf("timeout")?n="timeout":-1<i.indexOf("fail")||!o||o<0?n="failed":400<=o&&(n="error"),n&&a.publishErrorLog({msg:"AJAX_ERROR: request "+n+"\n \nres status: "+(o||0)+"\n \nres duration: "+(Date.now()-t.aegisRequestStartTime)+"\n \nres data: "+(e?f(r):"")+"\n \nreq url: "+t.url+"\n \nreq method: "+(t.method||"get")+"\n \nreq param: "+(e?f(t.data):"")+"\n \nerrMsg: "+i.slice(0,1e3),level:p.AJAX_ERROR}))}})}}),Z=new V({name:"reportAssetSpeed",isStart:!1,onNewAegis:function(e){this.isStart||(this.isStart=!0,this.start(e))},start:function(){var t=this;J.getPerformance&&J.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:l(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))})}}),V=new V({name:"pagePerformance",onNewAegis:function(e){try{W("getPerformance")&&this.reportPerformance(e),this.setPagePV(e),this.reportSetDataTiming(e)}catch(e){}},reportPerformance:function(r){var s=this,e=J.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=this.$getConfig(n),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:g.PERFORMANCE,log:t})}):this.$walk(function(e){e.send({url:n.config.performanceUrl+s+o.join("&"),type:g.PERFORMANCE,log:t})})},setPagePV:function(e){var t=this;J.onAppRoute&&J.onAppRoute(function(e){"appLaunch"!==e.openType&&t.$walk(function(e){e.send({url:""+e.config.pvUrl,type:g.PV})})})},reportSetDataTiming:function(t){function o(e,t){var n=t.updateStartTimestamp,i=t.updateEndTimestamp,t=void 0===(t=t.dataPaths)?[]:t,n=i-n;isNaN(n)||n<l||(n={from:e.is,duration:n},a&&0<t.length&&Object.assign(n,{dataPaths:t.slice(0,30)}),r(n))}var e,r=M([A(t,5),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}});t.send({url:t.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({miniProgramData:e})),type:g.CUSTOM,log:e})}]),i=Page,s=Component,n=null===(e=null===(n=t.config)||void 0===n?void 0:n.setDataReportConfig)||void 0===e?void 0:e.timeThreshold,a=!1!==(null===(e=null===(e=t.config)||void 0===e?void 0:e.setDataReportConfig)||void 0===e?void 0:e.withDataPaths),l=Boolean(n&&!isNaN(+n)&&5<n)?+n:5;Page=function(e){var n=e.onReady;return e.onReady=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:a},function(e){o(t,e)}),null==n?void 0:n.call(this)},i(e)},Component=function(e){var n,i;return e.lifetimes&&e.lifetimes.attached?(n=e.lifetimes.attached,e.lifetimes.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:a},function(e){o(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:a},function(e){o(t,e)}),null==i?void 0:i.call(this)}),s(e)}}});function ae(){return null!==k&&k.apply(this,arguments)||this}function le(){return null!==N&&N.apply(this,arguments)||this}function ue(e){this.callbacks=[],this.isOverride=!1,this.isOverride||this.override(),this.callbacks.push(e)}function ce(e){var i,c=U.call(this,e)||this;c.originRequest=X,c.speedLogPipeline=M([q(c.config),A(c),function(t,n){W("getNetworkType")?J.getNetworkType({success:function(e){e=K(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,g.SPEED),function(e){c.send({url:""+c.config.speedUrl,method:"post",data:r(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||W("getNetworkType")&&void 0===c.bean.netType)){c.requesting=!0;var i,o=e.url;c.config.whiteListUrl===o&&(i=t,t=function(e){null==i||i(JSON.stringify(e.data))}),!1!==e.addBean&&(o=o+(-1===o.indexOf("?")?"?":"&")+c.getBean);var r=e.method||"get",s=function(){c.requesting=!1;var e=c.requestQueue.shift();e&&c.request(e.options,e.success,e.fail)},a=e,l=c.config.onBeforeRequest;if(!(a=l?l(e,c):a)||!a.url){var u="";return a||(u="Sending request blocked",console.log(u)),a.url||(u="Please handle the parameters reasonably, options.url is necessary",console.warn(u)),null==n||n(u),s(),!1}u=c.config.enableHttp2||!1;return"get"===r?(o=function(e,n){if("string"!=typeof e)return"";if("object"==typeof n&&n){var t=Object.getOwnPropertyNames(n).map(function(e){var t=n[e];return e+"="+("string"==typeof t?encodeURIComponent(t):encodeURIComponent(JSON.stringify(t)))}).join("&").replace(/eval/gi,"evaI");return e+(-1===e.indexOf("?")?"?":"&")+t}return e}(o,a.data),c.originRequest({url:o,enableHttp2:u,success:t,fail:n,complete:s})):("string"==typeof a.data&&(a.data=a.data.replace(/eval/gi,"evaI")),c.originRequest({url:o,enableHttp2:u,header:a.contentType?{"content-type":a.contentType}:void 0,method:"POST",data:a.data,success:t,fail:n,complete:s})),!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",ce.sessionID),c.extendBean("referer",(W("getLaunchOptionsSync")?J.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 fe(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=J.env.USER_DATA_PATH+e,this.fileSystem=J.getFileSystemManager(),this.limitSize=t}function pe(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 de(e){var i,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:""},this.isWhiteList=!1,this.lifeCycle=new n,this.bean={},this.normalLogPipeline=M([A(this,5),I,F(this.config),j(this.lifeCycle.emit,this.config),(i=this,setTimeout(function(){var e=i.config.pvUrl,n=void 0===e?"":e;n&&i.sendPipeline([function(e,t){t({url:n,type:g.PV,fail:function(e){"403 forbidden"===e&&i.destroy()}})}],g.PV)(null)},100),function(e,t){t(e)}),_(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)},D(this)]),this.eventPipeline=M([A(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:g.EVENT,log:e,fail:function(e){"403 forbidden"===e&&o.destroy()}})}],g.EVENT)(e)}]),this.timeMap={},this.customTimePipeline=M([A(this,5),function(e){return o.sendPipeline([function(e,t){t({url:o.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:g.CUSTOM,log:e,fail:function(e){"403 forbidden"===e&&o.destroy()}})}],g.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),de.instances.push(this)}return z.use(se),z.use(B),z.use(Y),z.use(Z),z.use(V),z.use(Q),z});
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { InterfaceEventEmitter } from './util';
|
|
2
|
-
import { Config,
|
|
2
|
+
import { Config, LogType, Environment, SendOption, SendSuccess, SendFail, SpeedLog, ReportTimeLog, SendType, EventLog } from './interface';
|
|
3
3
|
import Plugin from './plugin';
|
|
4
|
+
import { Pipe } from './pipes';
|
|
4
5
|
export default class Core {
|
|
6
|
+
static version: string;
|
|
5
7
|
static instances: Core[];
|
|
6
8
|
constructor(config: Config);
|
|
7
|
-
|
|
9
|
+
get __version__(): string;
|
|
10
|
+
isGetSample: boolean;
|
|
11
|
+
isHidden: boolean;
|
|
12
|
+
static logType: typeof LogType;
|
|
13
|
+
get LogType(): typeof LogType;
|
|
14
|
+
static environment: typeof Environment;
|
|
8
15
|
config: Config;
|
|
9
16
|
isWhiteList: boolean;
|
|
10
17
|
lifeCycle: InterfaceEventEmitter;
|
|
@@ -21,7 +28,7 @@ export default class Core {
|
|
|
21
28
|
report(...msg: any): void;
|
|
22
29
|
error(...msg: any): void;
|
|
23
30
|
normalLogPipeline: import("./pipes").Pipeline<any, any>;
|
|
24
|
-
speedLogPipeline(
|
|
31
|
+
speedLogPipeline(_log?: SpeedLog): void;
|
|
25
32
|
reportPv(id: number): void;
|
|
26
33
|
reportEvent(event: string | EventLog): void;
|
|
27
34
|
private eventPipeline;
|
|
@@ -33,8 +40,9 @@ export default class Core {
|
|
|
33
40
|
private submitCustomTime;
|
|
34
41
|
private customTimePipeline;
|
|
35
42
|
extendBean(key: string, value: any): void;
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
sendPipeline(pipes: Pipe[], type: SendType): import("./pipes").Pipeline<any, any>;
|
|
44
|
+
send(options: SendOption, success?: SendSuccess, fail?: SendFail): any;
|
|
45
|
+
request(_options: SendOption, _success?: SendSuccess, _fail?: SendFail): void;
|
|
38
46
|
sendSDKError(err: any): void;
|
|
39
47
|
destroy(force?: boolean): void;
|
|
40
48
|
}
|
|
@@ -3,7 +3,7 @@ import Core from './core';
|
|
|
3
3
|
import Plugin from './plugin';
|
|
4
4
|
export { Plugin };
|
|
5
5
|
export default Core;
|
|
6
|
-
export {
|
|
6
|
+
export { LogType, NormalLog, SpeedLog, StaticAssetsLog, PagePerformanceLog, Config, SendOption, SendSuccess, SendFail, SendType, PlatTypeNum, NetworkTypeNum, } from './interface';
|
|
7
7
|
export { getDefaultConfig, setConfigUrl, globalAny } from './constant';
|
|
8
8
|
export * from './pipes';
|
|
9
9
|
export * from './util';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { Config } from './config';
|
|
2
|
-
export { NormalLog, SpeedLog, StaticAssetsLog, PagePerformanceLog,
|
|
3
|
-
export { SendOption, SendSuccess, SendFail,
|
|
2
|
+
export { NormalLog, SpeedLog, StaticAssetsLog, PagePerformanceLog, LogType, ReportTimeLog, EventLog, PlatTypeNum, NetworkTypeNum, } from './log';
|
|
3
|
+
export { SendOption, SendSuccess, SendFail, SendType, } from './send';
|
|
4
|
+
export { Environment, } from './env';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare enum
|
|
1
|
+
export declare enum LogType {
|
|
2
2
|
INFO_ALL = "-1",
|
|
3
3
|
API_RESPONSE = "1",
|
|
4
4
|
INFO = "2",
|
|
@@ -35,7 +35,7 @@ export declare enum NetworkTypeNum {
|
|
|
35
35
|
}
|
|
36
36
|
export interface NormalLog {
|
|
37
37
|
msg: any;
|
|
38
|
-
level:
|
|
38
|
+
level: LogType;
|
|
39
39
|
[key: string]: any;
|
|
40
40
|
}
|
|
41
41
|
export interface SpeedLog {
|
|
@@ -6,10 +6,13 @@ export interface SendOption {
|
|
|
6
6
|
addBean?: boolean;
|
|
7
7
|
from?: string;
|
|
8
8
|
beanFilter?: string[];
|
|
9
|
-
type?:
|
|
9
|
+
type?: SendType;
|
|
10
10
|
log?: any;
|
|
11
|
+
success?: (data: any) => void;
|
|
12
|
+
fail?: (err: any) => void;
|
|
13
|
+
sendBeacon?: boolean;
|
|
11
14
|
}
|
|
12
|
-
export declare enum
|
|
15
|
+
export declare enum SendType {
|
|
13
16
|
LOG = "log",
|
|
14
17
|
SPEED = "speed",
|
|
15
18
|
PERFORMANCE = "performance",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import Core from '../core';
|
|
2
|
-
import {
|
|
2
|
+
import { SendType } from '../interface';
|
|
3
3
|
import { Pipe } from './index';
|
|
4
|
-
export declare const beforeRequestHooks: (aegis: Core, logType:
|
|
4
|
+
export declare const beforeRequestHooks: (aegis: Core, logType: SendType | undefined) => Pipe;
|
|
@@ -7,8 +7,9 @@ export { createPvPipe } from './pv';
|
|
|
7
7
|
export { createSpeedRepeatLimitPipe, createErrorLogLimitPipe } from './repeat-limit';
|
|
8
8
|
export { reportPipe } from './report';
|
|
9
9
|
export { beforeRequestHooks } from './beforeRequestHooks';
|
|
10
|
+
export { modifyRequestHooks } from './modifyRequestHooks';
|
|
10
11
|
export { afterRequestHooks } from './afterRequestHooks';
|
|
11
12
|
export declare type Pipe<M = any, N = any> = (msg: M, resolve: Resolve<N>) => void;
|
|
12
13
|
export declare type Resolve<M> = (msg: M) => void;
|
|
13
14
|
export declare type Pipeline<M = any, N = any> = (msg: M, end?: Resolve<N>) => any;
|
|
14
|
-
export declare const createPipeline: (pipeArr:
|
|
15
|
+
export declare const createPipeline: (pipeArr: Pipe[]) => Pipeline;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NormalLog, SpeedLog } from '../interface';
|
|
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
4
|
interface P {
|
|
@@ -15,7 +15,19 @@ export declare const formatUrl: (url: string, isGetQuery?: boolean | undefined)
|
|
|
15
15
|
export declare const urlIsHttps: (url: string) => boolean;
|
|
16
16
|
export declare const isNative: (Ctor: any) => boolean;
|
|
17
17
|
export declare const isRequestAsset: (contentType: string) => boolean;
|
|
18
|
-
|
|
18
|
+
interface TryToGetRetCodeRsp {
|
|
19
|
+
code: string;
|
|
20
|
+
isErr: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface TryToGetRetCodeParams {
|
|
23
|
+
url?: string;
|
|
24
|
+
ctx?: any;
|
|
25
|
+
}
|
|
26
|
+
export declare const tryToGetRetCode: (obj: any, api?: Record<string, any> | undefined, params?: TryToGetRetCodeParams | undefined) => TryToGetRetCodeRsp;
|
|
27
|
+
/**
|
|
28
|
+
* 判断cgi返回的code是否为错误code
|
|
29
|
+
*/
|
|
30
|
+
export declare const judgeIsErrorRet: (config: Config, ret: string) => boolean;
|
|
19
31
|
export declare const stringifyPlus: (target: any) => string;
|
|
20
32
|
export declare const stringifyObj: (obj: any, deep?: number) => string;
|
|
21
33
|
/**
|
|
@@ -47,3 +59,4 @@ export declare class PayloadFetch {
|
|
|
47
59
|
}
|
|
48
60
|
export declare const generateAid: () => string;
|
|
49
61
|
export declare const speedShim: (logs: SpeedLog | SpeedLog[], bean: any) => any;
|
|
62
|
+
export declare const completionLogsKeys: (logs: any, keys: string[] | string) => any;
|
|
@@ -10,7 +10,6 @@ export interface HippyConfig extends Config {
|
|
|
10
10
|
reqCallback?: (data?: unknown, options?: unknown) => {};
|
|
11
11
|
}
|
|
12
12
|
export default class Aegis extends Core {
|
|
13
|
-
static __version__: string;
|
|
14
13
|
static sessionID: string;
|
|
15
14
|
hippy: any;
|
|
16
15
|
originRequest: typeof fetch;
|
|
@@ -35,5 +34,5 @@ export default class Aegis extends Core {
|
|
|
35
34
|
* @description 上报离线日志,在offlineLogPlugin中会重写改方法
|
|
36
35
|
* @param logs 日志
|
|
37
36
|
*/
|
|
38
|
-
uploadOfflineLogs(
|
|
37
|
+
uploadOfflineLogs(_logs: any | any[]): void;
|
|
39
38
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import Core, { Plugin,
|
|
1
|
+
import Core, { Plugin, LogType } from "../../../core/src";
|
|
2
2
|
export interface ErrorMsg {
|
|
3
3
|
msg: string;
|
|
4
4
|
rowNum: string;
|
|
5
5
|
colNum: string;
|
|
6
6
|
target: string;
|
|
7
|
-
level:
|
|
7
|
+
level: LogType;
|
|
8
8
|
from: string;
|
|
9
9
|
id?: string;
|
|
10
10
|
time?: number;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
/// <reference types="miniprogram-api-typings" />
|
|
2
|
+
import simulate from 'miniprogram-simulate';
|
|
1
3
|
export declare const join: (paths: string) => string;
|
|
2
4
|
export declare const getQuery: (url: string, name: string) => string;
|
|
5
|
+
export declare const triggerEvent: (aegisBtn: simulate.Component<any, any, any> | undefined, method?: string, params?: string[], config?: {}) => void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="miniprogram-api-typings" />
|
|
1
2
|
import Core, { Config, SendOption, SendSuccess, SendFail } from "../../core/src";
|
|
2
3
|
export interface MpConfig extends Config {
|
|
3
4
|
reportApiSpeed?: boolean;
|
|
@@ -7,15 +8,13 @@ export interface MpConfig extends Config {
|
|
|
7
8
|
offlineLog?: boolean;
|
|
8
9
|
offlineLogExp?: number;
|
|
9
10
|
offlineLogLimit?: number;
|
|
11
|
+
enableHttp2?: boolean;
|
|
12
|
+
updatePerformanceReportThreshold?: number;
|
|
10
13
|
}
|
|
11
14
|
export default class Aegis extends Core {
|
|
12
|
-
static __version__: string;
|
|
13
15
|
static sessionID: string;
|
|
14
16
|
static asyncPluginIndex: number;
|
|
15
|
-
originRequest:
|
|
16
|
-
(option: WechatMiniprogram.RequestOption<string | Record<string, any> | ArrayBuffer>): WechatMiniprogram.RequestTask;
|
|
17
|
-
<T extends string | Record<string, any> | ArrayBuffer = string | Record<string, any> | ArrayBuffer>(option: WechatMiniprogram.RequestOption<T>): WechatMiniprogram.RequestTask;
|
|
18
|
-
};
|
|
17
|
+
originRequest: (option: WechatMiniprogram.RequestOption) => WechatMiniprogram.RequestTask;
|
|
19
18
|
speedLogPipeline: import("../../core/src").Pipeline<any, any>;
|
|
20
19
|
constructor(config: MpConfig);
|
|
21
20
|
get getBean(): string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Plugin,
|
|
1
|
+
import { Plugin, LogType } from "../../../core/src";
|
|
2
2
|
export interface ErrorMsg {
|
|
3
3
|
msg: string;
|
|
4
4
|
rowNum: string;
|
|
5
5
|
colNum: string;
|
|
6
6
|
target: string;
|
|
7
|
-
level:
|
|
7
|
+
level: LogType;
|
|
8
8
|
from: string;
|
|
9
9
|
id?: string;
|
|
10
10
|
time?: number;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ReqOption {
|
|
2
|
+
aegisRequestStartTime: number;
|
|
3
|
+
}
|
|
4
|
+
export interface HackApiCallback<RequestOption = any, SucessRes = any, FailRes = any> {
|
|
5
|
+
onStart?: (options: RequestOption) => void;
|
|
6
|
+
success?: (res: SucessRes, options: RequestOption) => void;
|
|
7
|
+
fail?: (err: FailRes, options: RequestOption) => void;
|
|
8
|
+
complete?: (err: SucessRes | FailRes, options: RequestOption) => void;
|
|
9
|
+
}
|
|
10
|
+
declare type HackApiCallbackOption = ReqOption & HackApiCallback;
|
|
11
|
+
export default abstract class HackApiCore<T extends HackApiCallbackOption, U extends HackApiCallback> {
|
|
12
|
+
private callbacks;
|
|
13
|
+
private isOverride;
|
|
14
|
+
abstract apiName: string;
|
|
15
|
+
constructor(cb: U);
|
|
16
|
+
addCallback(cb: U): void;
|
|
17
|
+
protected prefixHandler(opts: T): void;
|
|
18
|
+
protected successHandler<R>(res: R, opts: T): void;
|
|
19
|
+
protected failHandler<R>(res: R, opts: T): void;
|
|
20
|
+
protected completeHandler<R>(res: R, opts: T): void;
|
|
21
|
+
private override;
|
|
22
|
+
protected abstract defineApiProperty(): void;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="miniprogram-api-typings" />
|
|
2
|
+
import HackApiCore, { ReqOption, HackApiCallback } from './hack-api';
|
|
3
|
+
export declare type CloudFunctionReqOption = ReqOption & ICloud.CallFunctionParam;
|
|
4
|
+
export declare type HackCloudFunctionReqOption = HackApiCallback<CloudFunctionReqOption, ICloud.CallFunctionResult, IAPIError>;
|
|
5
|
+
export declare class HackCloud extends HackApiCore<CloudFunctionReqOption, HackCloudFunctionReqOption> {
|
|
6
|
+
apiName: 'callFunction';
|
|
7
|
+
protected defineApiProperty(): void;
|
|
8
|
+
private hackHandler;
|
|
9
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="miniprogram-api-typings" />
|
|
2
|
+
import HackApiCore, { ReqOption, HackApiCallback } from './hack-api';
|
|
3
|
+
export declare type RequestOption = ReqOption & WechatMiniprogram.RequestOption;
|
|
4
|
+
export declare type HackRequestCallback = HackApiCallback<RequestOption, WechatMiniprogram.RequestSuccessCallbackResult, WechatMiniprogram.GeneralCallbackResult>;
|
|
5
|
+
export declare class HackRequest extends HackApiCore<RequestOption, HackRequestCallback> {
|
|
6
|
+
apiName: 'request';
|
|
7
|
+
protected defineApiProperty(): void;
|
|
8
|
+
private hackHandler;
|
|
3
9
|
}
|
|
4
|
-
export
|
|
5
|
-
onStart?: (options: RequestOption) => void;
|
|
6
|
-
success?: (res: WechatMiniprogram.RequestSuccessCallbackResult, options: RequestOption) => void;
|
|
7
|
-
fail?: (err: WechatMiniprogram.GeneralCallbackResult, options: RequestOption) => void;
|
|
8
|
-
complete?: (err: WechatMiniprogram.GeneralCallbackResult, options: RequestOption) => void;
|
|
9
|
-
}
|
|
10
|
-
export declare const hackRequest: (option: HackRequestCallback) => void;
|
|
10
|
+
export declare const hackRequest: (option: HackRequestCallback) => HackRequest;
|
|
@@ -2,7 +2,6 @@ import Core, { Config, SendFail, SendOption, SendSuccess } from "../../core/src"
|
|
|
2
2
|
import { BaseProtocal } from './protocol/protocol_base';
|
|
3
3
|
import { SelectorBase } from './selector/selector_base';
|
|
4
4
|
export default class Aegis extends Core {
|
|
5
|
-
static __version__: string;
|
|
6
5
|
static sessionID: string;
|
|
7
6
|
reportSpeedLog: import("../../core/src").Pipeline<any, any>;
|
|
8
7
|
protected selector: SelectorBase;
|
|
@@ -8,7 +8,6 @@ export interface QuickappConfig extends Config {
|
|
|
8
8
|
offlineLogExp?: number;
|
|
9
9
|
}
|
|
10
10
|
export default class Aegis extends Core {
|
|
11
|
-
static __version__: string;
|
|
12
11
|
static sessionID: string;
|
|
13
12
|
originRequest: (url: string, options: any) => Promise<unknown>;
|
|
14
13
|
aegisFetch: (url: string, options: any) => Promise<unknown>;
|
|
@@ -26,6 +25,6 @@ export default class Aegis extends Core {
|
|
|
26
25
|
* @description 上报离线日志,在offlineLogPlugin中会重写改方法
|
|
27
26
|
* @param logs 日志
|
|
28
27
|
*/
|
|
29
|
-
uploadOfflineLogs(
|
|
28
|
+
uploadOfflineLogs(_logs: any | any[]): void;
|
|
30
29
|
getFetch(): (url: string, options: any) => Promise<unknown>;
|
|
31
30
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import Core, { Plugin,
|
|
1
|
+
import Core, { Plugin, LogType } from "../../../core/src";
|
|
2
2
|
export interface ErrorMsg {
|
|
3
3
|
msg: string;
|
|
4
4
|
rowNum: string;
|
|
5
5
|
colNum: string;
|
|
6
6
|
target: string;
|
|
7
|
-
level:
|
|
7
|
+
level: LogType;
|
|
8
8
|
from: string;
|
|
9
9
|
id?: string;
|
|
10
10
|
time?: number;
|
|
@@ -21,7 +21,6 @@ declare enum PLATFORM {
|
|
|
21
21
|
DEFAULT = 100
|
|
22
22
|
}
|
|
23
23
|
export default class Aegis extends Core {
|
|
24
|
-
static __version__: string;
|
|
25
24
|
static sessionID: string;
|
|
26
25
|
static asyncPluginIndex: number;
|
|
27
26
|
originRequest: (options: Record<string, any>, cb: Function) => Promise<unknown>;
|
|
@@ -23,7 +23,6 @@ interface AsyncPluginOption {
|
|
|
23
23
|
onAegisInitAndPluginLoaded?: (aegis: Aegis, exportsConstructor?: Function) => void;
|
|
24
24
|
}
|
|
25
25
|
export default class Aegis extends Core {
|
|
26
|
-
static __version__: string;
|
|
27
26
|
static sessionID: string;
|
|
28
27
|
firstScreenInfo: {
|
|
29
28
|
element: any;
|
|
@@ -38,7 +37,7 @@ export default class Aegis extends Core {
|
|
|
38
37
|
fail?: SendFail;
|
|
39
38
|
}[];
|
|
40
39
|
requesting: boolean;
|
|
41
|
-
request(options: SendOption, success?: SendSuccess, fail?: SendFail): void;
|
|
40
|
+
request(options: SendOption, success?: SendSuccess, fail?: SendFail): boolean | void;
|
|
42
41
|
speedLogPipeline: import("../../core/src").Pipeline<any, any>;
|
|
43
42
|
private static asyncPlugin;
|
|
44
43
|
static useAsyncPlugin(url: string, options?: AsyncPluginOption): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from "../../../core/src";
|
|
1
|
+
import Core, { Plugin } from "../../../core/src";
|
|
2
2
|
declare global {
|
|
3
3
|
interface Navigator {
|
|
4
4
|
connection: any;
|
|
@@ -13,6 +13,6 @@ export declare enum NetworkTypeNum {
|
|
|
13
13
|
net5g = 5,
|
|
14
14
|
net6g = 6
|
|
15
15
|
}
|
|
16
|
-
declare const _default: Plugin<
|
|
16
|
+
declare const _default: Plugin<Core>;
|
|
17
17
|
export default _default;
|
|
18
18
|
export declare const getNetworkType: (callback: Function) => void;
|
|
@@ -3,3 +3,5 @@ export declare const speedShim: (logs: SpeedLog | SpeedLog[], bean: any) => Form
|
|
|
3
3
|
export declare const loadScript: (url: string, name?: string | undefined, cb?: Function | undefined) => void;
|
|
4
4
|
export declare const canUseResourceTiming: () => boolean;
|
|
5
5
|
export declare const canUseWebVitals: () => boolean;
|
|
6
|
+
export declare type OnHiddenCallback = (event: Event) => void;
|
|
7
|
+
export declare const onHidden: (cb: OnHiddenCallback, once?: boolean | undefined) => void;
|
|
@@ -10,7 +10,6 @@ export interface WeexConfig extends Config {
|
|
|
10
10
|
reqCallback?: (data?: unknown, options?: unknown) => {};
|
|
11
11
|
}
|
|
12
12
|
export default class Aegis extends Core {
|
|
13
|
-
static __version__: string;
|
|
14
13
|
static sessionID: string;
|
|
15
14
|
weex: any;
|
|
16
15
|
originRequest: (url: string, options?: object) => Promise<unknown>;
|
|
@@ -37,5 +36,5 @@ export default class Aegis extends Core {
|
|
|
37
36
|
* @description 上报离线日志,在offlineLogPlugin中会重写改方法
|
|
38
37
|
* @param logs 日志
|
|
39
38
|
*/
|
|
40
|
-
uploadOfflineLogs(
|
|
39
|
+
uploadOfflineLogs(_logs: any | any[]): void;
|
|
41
40
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import Core, { Plugin,
|
|
1
|
+
import Core, { Plugin, LogType } from "../../../core/src";
|
|
2
2
|
export interface ErrorMsg {
|
|
3
3
|
msg: string;
|
|
4
4
|
rowNum: string;
|
|
5
5
|
colNum: string;
|
|
6
6
|
target: string;
|
|
7
|
-
level:
|
|
7
|
+
level: LogType;
|
|
8
8
|
from: string;
|
|
9
9
|
id?: string;
|
|
10
10
|
time?: number;
|