/** * ==================================================================== * @tencent/aegis-mp-sdk@1.34.75 (c) 2021 Tencent Application Monitor. * Author pumpkincai. * Last Release Time Tue Dec 07 2021 14:47:12 GMT+0800 (GMT+08:00). * Released under the MIT License. * Thanks for supporting TAM & Aegis! * ==================================================================== **/ !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=n)return o=A(o),t(o.splice(0,o.length)),void(i&&clearTimeout(i));i&&clearTimeout(i),i=setTimeout(function(){i=null,0<(o=A(o)).length&&t(o.splice(0,o.length))},r.delay)}}function O(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(b).join(" ")})})):t(a(a({},e),{msg:"string"==typeof e.msg?e.msg:b(e.msg)}))}function R(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)})}),0l){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)}})}})},re),V=new D({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]n))}))}),(r=this.lifeCycle.emit,c=this.config,function(e,t){var n=c.logCreated;if("function"!=typeof n)return r("beforeWrite",e),t(e);e=e.filter(function(e){return!1!==n(e)});return r("beforeWrite",e),t(e)}),(i=this,setTimeout(function(){var e=i.config.pvUrl,n=void 0===e?"":e;n&&i.sendPipeline([function(e,t){t({url:n,type:m.PV,fail:function(e){"403 forbidden"===e&&i.destroy()}})}],m.PV)(null)},100),function(e,t){t(e)}),(o=l=a=!1,u=[],(s=this).lifeCycle.on("onConfigChange",function(){n&&clearTimeout(n),n=setTimeout(function(){var e,n;!o&&s.config&&(o=!0,e=s.config.whiteListUrl,(n=void 0===e?"":e)&&s.sendPipeline([function(e,t){t({url:n,type:m.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?_(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}})}],m.WHITE_LIST)(null),o=!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 I(e),e})):(e=e.filter(function(e){return e.level!==g.INFO&&e.level!==g.API_RESPONSE?(I(e),!0):(l||(u.push(e),200<=u.length&&(u.length=200)),!1)})).length&&t(e)}),function(e,t){var n=JSON.parse(JSON.stringify(e));d.lifeCycle.emit("beforeReport",n);var i=d.config.beforeReport;(e="function"==typeof i?e.filter(function(e){return!1!==i(e)}):e).length&&t(e)},_(this)]),this.eventPipeline=S([w(this,5),function(e){d.sendPipeline([function(e,t){var n=e.map(function(e){return{name:e.name,ext1:e.ext1||d.config.ext1||"",ext2:e.ext2||d.config.ext2||"",ext3:e.ext3||d.config.ext3||""}});t({url:d.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(n)),type:m.EVENT,log:e,fail:function(e){"403 forbidden"===e&&d.destroy()}})}],m.EVENT)(e)}]),this.timeMap={},this.customTimePipeline=S([w(this,5),function(e){return d.sendPipeline([function(e,t){t({url:d.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:m.CUSTOM,log:e,fail:function(e){"403 forbidden"===e&&d.destroy()}})}],m.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),ae.instances.push(this)}return W.use(ee),W.use(F),W.use(G),W.use($),W.use(D),W.use(V),W});