/** * ================================================================= * aegis-web-sdk@1.38.6 (c) 2023 TencentCloud Real User Monitoring. * Author pumpkincai. * Last Release Time Thu Oct 26 2023 21:44:26 GMT+0800 (中国标准时间). * Released under the MIT License. * Thanks for supporting RUM & 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 H,_;function j(e){this.name="__st"+(1e9*Math.random()>>>0)+H+"__",null!=e&&e.forEach(this.add,this),H+=1}Array.prototype.find||Object.defineProperty(Array.prototype,"find",{configurable:!0,writable:!0,value:function(e){if(null===this)throw new TypeError('"this" is null or not defined');var t=Object(this),n=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var r=arguments[1],o=0;o>e/4).toString(16)})}function z(){return"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)})}function Q(e){for(var t,n,r,o="",i=0,a=(e=String(e)).length%3;i>18&63)+s.charAt(t>>12&63)+s.charAt(t>>6&63)+s.charAt(63&t)}return a?o.slice(0,a-3)+"===".substring(a):o}function Y(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!ee.test(e))throw new TypeError("Failed to execute 'atob': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var n,r,o="",i=0;i>16&255):64===r?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return o}function Z(e){var t,n="";return n="object"==typeof e&&(t=(e=function(e,t){for(var n=0;n=r||n.sendNow&&0n)return w[r]||Pe(r),!1;o[e]=1+~~o[e],T[r]=o}return!0}))}),(d=this.lifeCycle.emit,p=this.config,function(e,t){var n,r=p.logCreated;return"function"==typeof r?(n=e.filter(function(e){return!1!==r(e)}),d("beforeWrite",n),t(n)):(d("beforeWrite",e),t(e))}),(f=this,setTimeout(function(){var e=f.config,t=e.pvUrl,n=void 0===t?"":t,t=e.spa,e=-1<["web-sdk","mp-sdk"].indexOf("web-sdk");n&&(e&&!t||!e)&&f.sendPipeline([function(e,t){t({url:n,type:v.PV})}],v.PV)(null)},100),function(e,t){t(e)}),(u=c=s=!1,l=[],(a=this).lifeCycle.on("onConfigChange",function(){i&&clearTimeout(i),i=setTimeout(function(){var e,n;!u&&a.config&&(u=!0,e=a.config.whiteListUrl,(n=void 0===e?"":e)&&a.sendPipeline([function(e,t){t({url:n,type:v.WHITE_LIST,success:function(e){c=!0;try{var t=e.data||JSON.parse(e),n=t.retcode,r=t.result,o=void 0===r?{}:r,i=(0===n&&(s=o.is_in_white_list,a.isWhiteList=s,0<=o.rate)&&o.rate<=1&&(a.config.random=o.rate,a.isGetSample=!1),a.isWhiteList&&l.length?Le(a)(l.splice(0),function(){}):!a.isWhiteList&&l.length&&(l.length=0),a.config.onWhitelist);"function"==typeof i&&i(s)}catch(e){}},fail:function(){c=!0}})}],v.WHITE_LIST)(null),u=!1)},a.config.uin?50:500)}),a.lifeCycle.on("destroy",function(){l.length=0}),function(e,t){var n;s||null!=(n=null==(n=a.config)?void 0:n.api)&&n.reportRequest?t(e.concat(l.splice(0)).map(function(e){return xe(e),e})):(n=e.filter(function(e){return e.level!==O.INFO&&e.level!==O.API_RESPONSE?(xe(e),!0):(c||(l.push(e),200<=l.length&&(l.length=200)),!1)})).length&&t(n)}),function(e,t){try{var n=JSON.parse(JSON.stringify(e)),r=(g.lifeCycle.emit("beforeReport",n),g.config.beforeReport);(e="function"==typeof r?e.filter(function(e){return!1!==r(e)}):e).length&&t(e)}catch(e){}},Le(this)]),this.eventPipeline=m([ce(this,10),(o=this,function(e){o.sendPipeline([function(e,t){var n=e.map(function(e){return{name:e.name,ext1:e.ext1||o.config.ext1||"",ext2:e.ext2||o.config.ext2||"",ext3:e.ext3||o.config.ext3||""}});t({url:o.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(n)),type:v.EVENT,log:e})}],v.EVENT)(e)})]),this.timeMap={},this.failRequestCount=0,this.customTimePipeline=m([ce(this,10),(r=this,function(e){return r.sendPipeline([function(e,t){t({url:r.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:v.CUSTOM,log:e})}],v.CUSTOM)(e)})]),this.config=(t=this.config,void 0===(e=e.hostUrl)&&(e="https://aegis.qq.com"),t.url=t.url||e+"/collect",t.offlineUrl=t.offlineUrl||e+"/offline",t.whiteListUrl=t.whiteListUrl||e+"/collect/whitelist",t.pvUrl=t.pvUrl||e+"/collect/pv",t.eventUrl=t.eventUrl||e+"/collect/events",t.speedUrl=t.speedUrl||e+"/speed",t.customTimeUrl=t.customTimeUrl||e+"/speed/custom",t.performanceUrl=t.performanceUrl||e+"/speed/performance",t.performanceUrlForHippy=t.performanceUrlForHippy||e+"/speed/hippyPerformance",t.webVitalsUrl=t.webVitalsUrl||e+"/speed/webvitals",t.setDataReportUrl=t.SetDataReportUrl||e+"/speed/miniProgramData",t),S.instances.push(this)}a.macos=function(){return r("mac")},a.ios=function(){return a.iphone()||a.ipod()||a.ipad()},a.iphone=function(){return!a.windows()&&r("iphone")},a.ipod=function(){return r("ipod")},a.ipad=function(){var e="MacIntel"===navigator.platform&&1r&&f.isInFirstScreen(e.roots[t])&&(r=e.rootsDomNum[t],n=e.time,u.setFirstScreenInfo(s,n,e.roots[t]))}),d.length=0,Object.keys(p).forEach(function(e){p[e]=p[e].map(function(e){var t={tagName:e.tagName},n=e.attributes;if(!n)return e;for(var r=0;rr[1]?"poor":e>r[0]?"needs-improvement":"good",t(n))}}function gt(e){requestAnimationFrame(function(){return requestAnimationFrame(function(){return e()})})}function mt(t){function e(e){"pagehide"!==e.type&&"hidden"!==document.visibilityState||t(e)}addEventListener("visibilitychange",e,!0),addEventListener("pagehide",e,!0)}function vt(t){var n=!1;return function(e){n||(t(e),n=!0)}}function yt(){return U<0&&(U=Ut(),Ht(),At(function(){setTimeout(function(){U=Ut(),Ht()},0)})),{get firstHiddenTime(){return U}}}function wt(e){document.prerendering?addEventListener("prerenderingchange",function(){return e()},!0):e()}function bt(i,a){a=a||{},wt(function(){var t,n=yt(),r=A("FCP"),o=ht("paint",function(e){e.forEach(function(e){"first-contentful-paint"===e.name&&(o.disconnect(),e.startTimen.value&&(n.value=r,n.entries=o,t())}var t,n=A("CLS",0),r=0,o=[],i=ht("layout-shift",e);i&&(t=I(a,n,jt,s.reportAllChanges),mt(function(){e(i.takeRecords()),t(!0)}),At(function(){n=A("CLS",r=0),t=I(a,n,jt,s.reportAllChanges),gt(function(){return t()})}),setTimeout(t,0))})),ge(this.publish.bind(this,e),{once:!0,delay:{visibilitychange:10}})}catch(e){}var a,s,c,u,l,f},publish:function(t){this.$walk(function(i){var e;i===t&&null!=(e=i.sendPipeline)&&e.call(i,[function(e,t){var n,r=[];for(n in e)r.push(n+"="+e[n]);var o=-1===(null==(o=null==(o=i.config)?void 0:o.performanceUrl)?void 0:o.indexOf("?"))?"?":"&";t({url:i.config.webVitalsUrl+o+r.join("&"),type:v.VITALS,log:e,sendBeacon:!0})}],v.VITALS)(l({},Xt))})},destroy:function(){this.option.publish=function(){}}}),$t=(new i({name:"spa"}),["replaceState","pushState","popstate","hashchange"]),Jt=new i({name:"spa",originFireUrl:"",onNewAegis:function(t){var n=this;history.pushState=this.wr("pushState")||history.pushState,history.replaceState=this.wr("replaceState")||history.replaceState,this.sendPv=this.sendPv.bind(this),t.config.spa&&this.sendPv(t),$t.forEach(function(e){return window.addEventListener(e,function(){return n.sendPv.call(n,t)})})},wr:function(n){var r=history[n],e="__"+n+"__hasWrittenByTamSpa";return"function"==typeof r&&!history[e]&&(Object.defineProperty(history,e,{value:!0,enumerable:!1}),function(){var e=r.apply(this,arguments),t=null;return"function"==typeof Event?t=new Event(n):(t=document.createEvent("HTMLEvents")).initEvent(n,!1,!0),window.dispatchEvent(t),e})},sendPv:function(r){var o=this;setTimeout(function(){var t=location.pathname+location.hash+r.config.id;o.$walk(function(e){var n;e===r&&(n=e.config.pvUrl)&&t&&t!==o.originFireUrl&&(e.sendPipeline([function(e,t){t({url:""+n,type:v.PV})}],v.PV)(null),o.originFireUrl=t)})},0)},destroy:function(){this.option.sendPv=function(){}}}),o=(B(Lt=q,o=kt=o),Lt.prototype=null===o?Object.create(o):(Kt.prototype=o.prototype,new Kt),q.prototype.getBean=function(t){var n=this;return void 0===t&&(t=[]),""+Object.getOwnPropertyNames(this.bean).filter(function(e){return-1===t.indexOf(e)}).map(function(e){return"from"===e?"from="+n.getCurrentPageUrl():e+"="+n.bean[e]}).join("&")},q.prototype.getCurrentPageUrl=function(){var e=this.config.pageUrl||location.href,e=(e="function"==typeof this.config.urlHandler?this.config.urlHandler()||location.href:e).slice(0,2048);return encodeURIComponent(e)},q.prototype.ready=function(){function i(){var e,n,r,o;t.reportRequestQueue.length&&(e=t.reportRequestQueue.splice(0,1)[0],n=e.options,r=e.success,o=e.fail,t.$request(n,function(){for(var e=[],t=0;t