@sanseng/liveavatar-js-sdk-skywalking 1.0.0
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/LICENSE +21 -0
- package/README.md +42 -0
- package/dist/index.cjs.js +1410 -0
- package/dist/index.d.ts +286 -0
- package/dist/index.esm.js +1403 -0
- package/dist/index.umd.js +1414 -0
- package/package.json +60 -0
|
@@ -0,0 +1,1414 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@sanseng/liveavatar-js-sdk')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@sanseng/liveavatar-js-sdk'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LiveavatarSkyWalkingPlugin = {}, global.LiveavatarSDK));
|
|
5
|
+
})(this, (function (exports, liveavatarJsSdk) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Build-time placeholder for the bundled SkyWalking browser client.
|
|
9
|
+
*
|
|
10
|
+
* Rollup replaces the marker inside this function with the upstream 1.1.27
|
|
11
|
+
* IIFE. Keeping it in a function is intentional: importing this package must
|
|
12
|
+
* remain safe in SSR and other non-browser environments.
|
|
13
|
+
*/
|
|
14
|
+
function installEmbeddedSkyWalkingClient() {
|
|
15
|
+
/*!
|
|
16
|
+
SkyWalking js-sdk
|
|
17
|
+
@version 1.1.27
|
|
18
|
+
@time 2026.01.12
|
|
19
|
+
*/
|
|
20
|
+
!function(){var e,t,r={"./src/index.ts":function(){function e(){return Math.random()}function t(e){return e>=10?"".concat(e):"0".concat(e)}function r(e){var r,n=new Date;return {year:t(n.getFullYear()),month:t(n.getMonth()+1),day:t(n.getDate()),hours:t(n.getHours()),minutes:t(n.getMinutes()),seconds:t(n.getSeconds()),miSeconds:(r=n.getMilliseconds(),"0000".concat(r).slice(-3))}}function n(){var e={browser:"",browserVersion:"",os:"",osVersion:"",UA:navigator.userAgent};return function(e){var t=navigator.userAgent,r={Chrome:/Chrome/,IE:/MSIE/,Firefox:/Firefox/,Opera:/Presto/,Safari:/Version\/([\d.]+).*Safari/,360:/360SE/,QQBrowser:/QQ/};for(var n in r)r[n].test(t)&&(e.browser=n,"Chrome"===n?e.browserVersion=t.split("Chrome/")[1].split(" ")[0]:"IE"===n?e.browserVersion=t.split("MSIE ")[1].split(" ")[1]:"Firefox"===n?e.browserVersion=t.split("Firefox/")[1]:"Opera"===n?e.browserVersion=t.split("Version/")[1]:"Safari"===n?e.browserVersion=t.split("Version/")[1].split(" ")[0]:"360"===n?e.browserVersion="":"QQBrowser"===n&&(e.browserVersion=t.split("Version/")[1].split(" ")[0]));}(e),function(e){var t=navigator.userAgent,r={iPhone:/iPhone/,iPad:/iPad/,Android:/Android/,Windows:/Windows/,Mac:/Macintosh/};for(var n in r)r[n].test(t)&&(e.os=n,"Windows"===n?e.osVersion=t.split("Windows NT ")[1].split(";")[0]:"Mac"===n?e.osVersion=t.split("Mac OS X ")[1].split(")")[0]:"iPhone"===n?e.osVersion=t.split("iPhone OS ")[1].split(" ")[0]:"iPad"===n?e.osVersion=t.split("iPad; CPU OS ")[1].split(" ")[0]:"Android"===n&&(e.osVersion=t.split("Android ")[1].split(";")[0]));}(e),e}function o(e){return e.replace(/(\d+)|./g,(function(e,t){return t?"*":e}))}function i(e){return e>0?Math.floor(e):0}var a,c,s;!function(e){e.AJAX_ERROR="ajax",e.FETCH_ERROR="fetch",e.RESOURCE_ERROR="resource",e.VUE_ERROR="vue",e.PROMISE_ERROR="promise",e.JS_ERROR="js",e.WHITE_SCREEN_ERROR="whiteScreen",e.UNKNOWN_ERROR="unknown";}(a||(a={})),function(e){e.INFO="Info",e.WARNING="Warning",e.ERROR="Error";}(c||(c={})),function(e){e.ERROR="/browser/errorELKLog",e.ERRORS="/browser/errorELKLogs",e.PERF="/browser/perfData",e.SEGMENT="/v3/segment",e.SEGMENTS="/v3/segments",e.SLOW_INTERACTIONS="/browser/perfData";}(s||(s={}));var u,l="Http",f="Exit";!function(e){e[e.OPENED=1]="OPENED",e[e.DONE=4]="DONE";}(u||(u={}));var p=10001,h="<browser>",d=2048,v="--- FETCH ERROR START: ",y="FETCH ERROR START END ---";var g={getLogTime:function(){var e=r(),t=e.year,n=e.month,o=e.day,i=e.hours,a=e.minutes,c=e.seconds,s=e.miSeconds;return "".concat(t,"-").concat(n,"-").concat(o," ").concat(i,":").concat(a,":").concat(c,".").concat(s)}},m=function(){return m=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},m.apply(this,arguments)},w=navigator.userAgent.toLowerCase();var b={getUserid:function(){var e=document.cookie,t="";if(0!==e.length)for(var r=e.split(";"),n=0;n<r.length;n++){var o=r[n].split("="),i=o[0],a=o[1];"userid"===i.trim()&&(t=a.trim());}return t||function(){var e=w.indexOf("userid/");if(e>-1)return w.substr(e+7).split(" ")[0].replace(/^-/,"")}()}},E=b=m(m({},b),g),R=function(){return R=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},R.apply(this,arguments)};function S(e,t){if(["SLOW_INTERACTIONS"].indexOf(e)>-1)return function(e){if(!e)return "";var t=Array.isArray(e)?e:[e],r="";return t.forEach((function(e){r+="".concat(JSON.stringify(e),"\n");})),r}(t);if(-1===["ERRORS","ERROR"].indexOf(e))return JSON.stringify(t);var r="",i=E.getUserid(),a=n(),c=[];return t.forEach((function(e){var t=e.category,n=e.logtime;if("ajax"===t)c.push(n);else if("promise"===t&&c.indexOf(n)>-1)return;var s=e.stack;if(s)try{"string"!=typeof s&&(s=JSON.stringify(s));var u=s.match(/(?:([^\s\(]+)\s*\()?\s*(https?:\/\/[^:\s]+(?:\/[^:\s]*)*):(\d+):(\d+)\)?/);u&&u[0]&&(s=s.split(u[0])[0]+u[0],e.stack=s);}catch(e){}if(i&&(e.userid=i),(e=R(R({},e),a)).pagePath){var l=o(e.pagePath),f=e.pagePath.startsWith("/")?"":"/";e.pagePath.startsWith("http")?e.groupedPagePath=e.pagePath:e.groupedPagePath=location.origin+f+l;}r+="".concat(JSON.stringify(e),"\n");})),r}var T=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,[])).next());}))},O=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}},k=function(){function e(e,t,r){switch(this.url="",this.type="",this.hook=void 0,r&&(this.hook=r),this.type=e,e){case "ERROR":this.url=t+s.ERROR;break;case "ERRORS":this.url=t+s.ERRORS;break;case "SEGMENT":this.url=t+s.SEGMENT;break;case "SEGMENTS":this.url=t+s.SEGMENTS;break;case "PERF":this.url=t+s.PERF;break;case "SLOW_INTERACTIONS":this.url=t+s.SLOW_INTERACTIONS;}if(t.includes("//apm.myhexin.com/apm-web/")){var n="isZip=0";"ERRORS"===e?this.url+="?appId=skywalking-log&".concat(n):"PERF"===e&&(this.url+="?appId=skywalking-perf-log&".concat(n));}}return e.prototype.send=function(e){return T(this,void 0,void 0,(function(){var t,r;return O(this,(function(n){switch(n.label){case 0:return this.url?this.hook?[4,this.hook({type:this.type,url:this.url,data:e})]:[3,2]:[2];case 1:if(!n.sent())return [2];n.label=2;case 2:return (t=new XMLHttpRequest).open("post",this.url,true),t.setRequestHeader("Content-Type","application/json"),t.onreadystatechange=function(){4===t.readyState&&t.status<400&&console.log("Report successfully");},r=S(this.type,e),t.send(r),[2]}}))}))},e}();function I(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var r=16*e()|0;return ("x"===t?r:3&r|8).toString(16)}))}var x=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,[])).next());}))},P=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}};var _,C=location.host,L="v1.1.27",A=function(e,t){ void 0===t&&(t=[]);var r,n={uniqueId:window.ELK_WHITESCREEN_TRACEID||I(),collector:"",service:"",serviceVersion:"",group:"",subGroup:"",pagePath:"",domain:C,sdkVersion:L};return (r=["collector","service","serviceVersion","group","subGroup","pagePath","reportHook","pageKey"],t.forEach((function(e){ -1===r.indexOf(e)&&r.push(e);})),r).forEach((function(t){var r;if("pagePath"!==t||e[t])n[t]="reportHook"===t?(null===(r=e.hooks)||void 0===r?void 0:r.reportHook)||e.reportHook:e[t];else {var o=location.pathname,i=location.hash,a="";o&&"/"!==o&&(a+=o),i&&(a+=o?i:i.replace("#","")),n[t]=a||"/";}})),n.logtime=E.getLogTime(),n},H=function(e,t){var r=t,n=e.extraMsg;return n&&("function"==typeof n&&(n=n()),r="".concat(r," -(").concat(n,")")),r},q=function(e,t){return x(void 0,void 0,void 0,(function(){var r,n;return P(this,(function(o){switch(o.label){case 0:if("function"!=typeof(r=(null===(n=e.hooks)||void 0===n?void 0:n.filterHook)||e.filterHook))return [3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,r(t)];case 2:return [2,o.sent()];case 3:return o.sent(),[2,true];case 4:return [2,true]}}))}))},M=function(){function e(){}return e.prototype.getPerfTiming=function(e){try{return this._returnPerfData(e)}catch(e){throw e}},e.prototype._returnPerfData=function(e){var t=function(){if(window.performance&&window.performance.timing)return window.performance.timing}();if(t){var r={redirectTime:void 0!==t.navigationStart?i(t.fetchStart-t.navigationStart):void 0!==t.redirectEnd?i(t.redirectEnd-t.redirectStart):0,dnsTime:i(t.domainLookupEnd-t.domainLookupStart),tcpTime:i(t.connectEnd-t.connectStart),ttfbTime:i(t.responseStart-t.requestStart),transTime:i(t.responseEnd-t.responseStart),domAnalysisTime:i(t.domContentLoadedEventStart-t.domLoading),fptTime:i(t.responseEnd-t.fetchStart),domReadyTime:i(t.domContentLoadedEventEnd-t.fetchStart),resTime:i(t.loadEventStart-t.domContentLoadedEventEnd),loadPageTime:i(t.loadEventEnd-t.fetchStart),sslTime:"https:"===location.protocol&&t.secureConnectionStart>0?i(t.connectEnd-t.secureConnectionStart):void 0,ttlTime:i(t.domInteractive-t.fetchStart),firstPackTime:i(t.responseStart-t.domainLookupStart),sdkVersion:L};if(e){var n=["script","link","img"],o=[];performance.getEntries().forEach((function(e,t){if(t){var r=e.name,i=e.initiatorType,a=e.transferSize,c=e.responseEnd,s=e.startTime;if(-1!==n.indexOf(i)){var u=Math.round(c-s),l=r.split("/").pop().replace(/^;/,"");o.push({name:l,type:i,size:a,time:u});}}})),r.entries=o;}return r}console.log("your browser do not support performance");},e}(),D=M,j=-1,N=function(e){addEventListener("pageshow",(function(t){t.persisted&&(j=t.timeStamp,e(t));}),true);},U=function(){var e=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},F=function(){var e=U();return e&&e.activationStart||0},G=function(e,t){var r=U(),n="navigate";return j>=0?n="back-forward-cache":r&&(document.prerendering||F()>0?n="prerender":document.wasDiscarded?n="restore":r.type&&(n=r.type.replace(/_/g,"-"))),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:n}},W=function(e,t,r){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var n=new PerformanceObserver((function(e){Promise.resolve().then((function(){t(e.getEntries());}));}));return n.observe(Object.assign({type:e,buffered:!0},r||{})),n}}catch(e){}},V=function(e,t,r,n){var o,i;return function(a){t.value>=0&&(a||n)&&((i=t.value-(o||0))||void 0===o)&&(o=t.value,t.delta=i,t.rating=function(e,t){return e>t[1]?"poor":e>t[0]?"needs-improvement":"good"}(t.value,r),e(t));}},B=function(e){requestAnimationFrame((function(){return requestAnimationFrame((function(){return e()}))}));},Q=function(e){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&e();}));},K=function(e){var t=false;return function(){t||(e(),t=true);}},J=-1,X=function(){return "hidden"!==document.visibilityState||document.prerendering?1/0:0},z=function(e){"hidden"===document.visibilityState&&J>-1&&(J="visibilitychange"===e.type?e.timeStamp:0,Z());},Y=function(){addEventListener("visibilitychange",z,true),addEventListener("prerenderingchange",z,true);},Z=function(){removeEventListener("visibilitychange",z,true),removeEventListener("prerenderingchange",z,true);},$=function(){return J<0&&(J=X(),Y(),N((function(){setTimeout((function(){J=X(),Y();}),0);}))),{get firstHiddenTime(){return J}}},ee=function(e){document.prerendering?addEventListener("prerenderingchange",(function(){return e()}),true):e();},te=[1800,3e3],re=function(e,t){t=t||{},ee((function(){var r,n=$(),o=G("FCP"),i=W("paint",(function(e){e.forEach((function(e){"first-contentful-paint"===e.name&&(i.disconnect(),e.startTime<n.firstHiddenTime&&(o.value=Math.max(e.startTime-F(),0),o.entries.push(e),r(true)));}));}));i&&(r=V(e,o,te,t.reportAllChanges),N((function(n){o=G("FCP"),r=V(e,o,te,t.reportAllChanges),B((function(){o.value=performance.now()-n.timeStamp,r(true);}));})));}));},ne=[.1,.25],oe=0,ie=1/0,ae=0,ce=function(e){e.forEach((function(e){e.interactionId&&(ie=Math.min(ie,e.interactionId),ae=Math.max(ae,e.interactionId),oe=ae?(ae-ie)/7+1:0);}));},se=function(){return _?oe:performance.interactionCount||0},ue=function(){"interactionCount"in performance||_||(_=W("event",ce,{type:"event",buffered:true,durationThreshold:0}));},le=[],fe=new Map,pe=0,he=[],de=function(e){if(he.forEach((function(t){return t(e)})),e.interactionId||"first-input"===e.entryType){var t=le[le.length-1],r=fe.get(e.interactionId);if(r||le.length<10||e.duration>t.latency){if(r)e.duration>r.latency?(r.entries=[e],r.latency=e.duration):e.duration===r.latency&&e.startTime===r.entries[0].startTime&&r.entries.push(e);else {var n={id:e.interactionId,latency:e.duration,entries:[e]};fe.set(n.id,n),le.push(n);}le.sort((function(e,t){return t.latency-e.latency})),le.length>10&&le.splice(10).forEach((function(e){return fe.delete(e.id)}));}}},ve=function(e){var t=self.requestIdleCallback||self.setTimeout,r=-1;return e=K(e),"hidden"===document.visibilityState?e():(r=t(e),Q(e)),r},ye=[200,500],ge=function(e,t){"PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype&&(t=t||{},ee((function(){var r;ue();var n,o=G("INP"),i=function(e){ve((function(){e.forEach(de);var t=function(){var e=Math.min(le.length-1,Math.floor((se()-pe)/50));return le[e]}();t&&t.latency!==o.value&&(o.value=t.latency,o.entries=t.entries,n());}));},a=W("event",i,{durationThreshold:null!==(r=t.durationThreshold)&&void 0!==r?r:40});n=V(e,o,ye,t.reportAllChanges),a&&(a.observe({type:"first-input",buffered:true}),Q((function(){i(a.takeRecords()),n(true);})),N((function(){pe=se(),le.length=0,fe.clear(),o=G("INP"),n=V(e,o,ye,t.reportAllChanges);})));})));},me=[800,1800],we=function e(t){document.prerendering?ee((function(){return e(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return e(t)}),true):setTimeout(t,0);},be=function(e,t){t=t||{};var r=G("TTFB"),n=V(e,r,me,t.reportAllChanges);we((function(){var o=U();o&&(r.value=Math.max(o.responseStart-F(),0),r.entries=[o],n(true),N((function(){r=G("TTFB",0),(n=V(e,r,me,t.reportAllChanges))(true);})));}));},Ee=(function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,t||[])).next());}))}),Re=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}},Se=function(){function e(){}return e.prototype.createMetricPromise=function(e,t){return void 0===t&&(t=3e3),new Promise((function(r){var n=setTimeout((function(){return r(void 0)}),t),o=false,i=function(e){o||(o=true,clearTimeout(n),r(e));};try{e(i);}catch(e){i(void 0);}}))},e.prototype.getFCP=function(){return Ee(this,void 0,void 0,(function(){return Re(this,(function(e){return [2,this.createMetricPromise((function(e){re((function(t){return e(t.value)}));}))]}))}))},e.prototype.getTTFB=function(){return Ee(this,void 0,void 0,(function(){return Re(this,(function(e){return [2,this.createMetricPromise((function(e){be((function(t){return e(t.value)}));}))]}))}))},e.prototype.getCLS=function(){return Ee(this,void 0,void 0,(function(){return Re(this,(function(e){return [2,new Promise((function(e){var t;try{!function(e,t){t=t||{},re(K((function(){var r,n=G("CLS",0),o=0,i=[],a=function(e){e.forEach((function(e){if(!e.hadRecentInput){var t=i[0],r=i[i.length-1];o&&e.startTime-r.startTime<1e3&&e.startTime-t.startTime<5e3?(o+=e.value,i.push(e)):(o=e.value,i=[e]);}})),o>n.value&&(n.value=o,n.entries=i,r());},c=W("layout-shift",a);c&&(r=V(e,n,ne,t.reportAllChanges),Q((function(){a(c.takeRecords()),r(!0);})),N((function(){o=0,n=G("CLS",0),r=V(e,n,ne,t.reportAllChanges),B((function(){return r()}));})),setTimeout(r,0));})));}((function(e){t=Math.round(1e4*e.value)/1e4;}),{reportAllChanges:!0});}catch(t){return void e(void 0)}setTimeout((function(){e(null!=t?t:0);}),5e3);}))]}))}))},e.prototype.getINP=function(){return Ee(this,void 0,void 0,(function(){return Re(this,(function(e){return [2,new Promise((function(e){var t;try{ge((function(e){t=e.value;}),{reportAllChanges:!0});}catch(t){return void e(void 0)}setTimeout((function(){e(t);}),5e3);}))]}))}))},e.prototype.getLCP=function(){return Ee(this,void 0,void 0,(function(){return Re(this,(function(e){return [2,new Promise((function(e){var t,r,n=false,o=0,i=function(t){n||(n=true,e(t));};try{var a=new PerformanceObserver((function(e){for(var t=0,r=e.getEntries();t<r.length;t++){var n=r[t];o=n.startTime;}}));a.observe({type:"largest-contentful-paint",buffered:!0});var c=function(){"hidden"===document.visibilityState&&(document.removeEventListener("visibilitychange",c),a.disconnect(),i(o||void 0));};r=function(){t.forEach((function(e){return document.removeEventListener(e,r)})),a.disconnect(),i(o||void 0);},(t=["click","keydown","touchstart"]).forEach((function(e){return document.addEventListener(e,r,{once:!0})})),document.addEventListener("visibilitychange",c),setTimeout((function(){n||(document.removeEventListener("visibilitychange",c),a.disconnect(),i(o||void 0));}),5e3);}catch(e){i(void 0);}}))]}))}))},e.prototype._roundToInteger=function(e){return e?Math.round(e):e},e.prototype.getNewPerf=function(){return Ee(this,void 0,void 0,(function(){var e,t,r,n,o,i,a;return Re(this,(function(c){switch(c.label){case 0:return e=[this.getFCP(),this.getLCP(),this.getTTFB(),this.getCLS(),this.getINP()],[4,Promise.all(e)];case 1:return t=c.sent(),r=t[0],n=t[1],o=t[2],i=t[3],a=t[4],r=this._roundToInteger(r),n=this._roundToInteger(n),o=this._roundToInteger(o),a=this._roundToInteger(a),[2,{fcpTime:r,lcpTime:n,ttfbTime:o,clsScore:i,inpTime:a}]}}))}))},e}();var Te,Oe=Se,ke=function(e,t){return window.getComputedStyle?window.getComputedStyle(e,null)[t]:e.currentStyle[t]};!function(e){e[e.SVG=2]="SVG",e[e.IMG=2]="IMG",e[e.CANVAS=4]="CANVAS",e[e.OBJECT=4]="OBJECT",e[e.EMBED=4]="EMBED",e[e.VIDEO=4]="VIDEO";}(Te||(Te={}));var Ie=performance.now(),xe=["SCRIPT","STYLE","META","HEAD","LINK"],Pe=window.innerWidth,_e=window.innerHeight,Ce=function(){function e(){this.fmpTime=0,this.statusCollector=[],this.flag=true,this.observer=null,this.callbackCount=0,this.entries={},performance&&performance.getEntries?this.initObserver():console.log("your browser do not support performance.getEntries");}return e.prototype.getFirstSnapShot=function(){var e=performance.now(),t=document.body;t&&this.setTag(t,this.callbackCount),this.statusCollector.push({time:e});},e.prototype.initObserver=function(){var e=this;this.getFirstSnapShot(),this.observer=new MutationObserver((function(){e.callbackCount+=1;var t=performance.now(),r=document.body;r&&e.setTag(r,e.callbackCount),e.statusCollector.push({time:t});})),this.observer.observe(document,{childList:true,subtree:true}),"complete"===document.readyState?this.calculateFinalScore():window.addEventListener("load",(function(){e.calculateFinalScore();}),false);},e.prototype.calculateFinalScore=function(){var e=this;if(window.MutationEvent&&this.flag)if(this.checkNeedCancel(Ie)){this.observer.disconnect(),this.flag=false;for(var t=null,r=0,n=this.getTreeScore(document.body).dpss;r<n.length;r++){var o=n[r];t&&t.st?t.st<o.st&&(t=o):t=o;}if(performance.getEntries().forEach((function(t){e.entries[t.name]=t.responseEnd;})),!t)return false;var i=this.filterResult(t.els),a=this.getFmpTime(i);this.fmpTime=a;}else setTimeout((function(){e.calculateFinalScore();}),500);},e.prototype.getFmpTime=function(e){var t=0;try{for(var r=0,n=e;r<n.length;r++){var o=n[r],i=0;if(1===o.weight){var a=parseInt(o.ele.getAttribute("fmp_c"),10);i=this.statusCollector[a].time;}else if(2===o.weight)if("IMG"===o.ele.tagName)i=this.entries[o.ele.src];else if("SVG"===o.ele.tagName){a=parseInt(o.ele.getAttribute("fmp_c"),10);i=this.statusCollector[a].time;}else {var c=ke(o.ele,"background-image").match(/url\(\"(.*?)\"\)/),s=void 0;c&&c[1]&&(s=c[1]),(null==s?void 0:s.indexOf("http"))>-1&&(s=location.protocol+(c&&c[1]||"-")),i=this.entries[s];}else if(4===o.weight)if("CANVAS"===o.ele.tagName){a=parseInt(o.ele.getAttribute("fmp_c"),10);i=this.statusCollector[a]&&this.statusCollector[a].time;}else "VIDEO"===o.ele.tagName&&((i=this.entries[o.ele.src])||(i=this.entries[o.ele.poster]));"number"!=typeof i&&(i=0),t<i&&(t=i);}}catch(e){console.warn(e);}return t},e.prototype.filterResult=function(e){if(1===e.length)return e;var t=0;e.forEach((function(e){t+=e.st;}));var r=t/e.length;return e.filter((function(e){return e.st>r}))},e.prototype.checkNeedCancel=function(e){var t=performance.now()-e,r=this.statusCollector.length>0?this.statusCollector[this.statusCollector.length-1].time:0;return t>3e3||t-r>1e3},e.prototype.getTreeScore=function(e){if(!e)return {};for(var t=[],r=0,n=e.children;r<n.length;r++){var o=n[r];if(o.getAttribute("fmp_c")){var i=this.getTreeScore(o);i.st&&t.push(i);}}return this.calcaulteGrades(e,t)},e.prototype.calcaulteGrades=function(e,t){var r=e.getBoundingClientRect(),n=r.width,o=r.height,i=r.left,a=r.top,c=true;(_e<a||Pe<i)&&(c=false);var s=0;t.forEach((function(e){s+=e.st;}));var u=Number(Te[e.tagName])||1;1===u&&ke(e,"background-image")&&"initial"!==ke(e,"background-image")&&"none"!==ke(e,"background-image")&&(u=Te.IMG);var l=c?n*o*u:0,f=[{ele:e,st:l,weight:u}],p=e,h=this.calculateAreaParent(e);if(s>l*h||0===h){l=s,f=[];for(var d=0,v=t;d<v.length;d++){var y=v[d];f=f.concat(y.els);}}return {dpss:t,st:l,els:f,root:p}},e.prototype.calculateAreaParent=function(e){var t=e.getBoundingClientRect(),r=t.left,n=t.right,o=t.top,i=t.bottom,a=t.width,c=t.height,s=Pe,u=_e,l=n-r+(s-0)-(Math.max(n,s)-Math.min(r,0)),f=i-o+(u-0)-(Math.max(i,u)-Math.min(o,0));return l<=0||f<=0?0:l*f/(a*c)},e.prototype.setTag=function(e,t){var r=e.tagName;if(-1===xe.indexOf(r)){var n=e.children;if(n&&n.length>0)for(var o=n.length-1;o>=0;o--){var i=n[o];if(!(null!==i.getAttribute("fmp_c"))){var a=i.getBoundingClientRect(),c=a.left,s=a.top,u=a.width,l=a.height;if(_e<s||Pe<c||0===u||0===l)continue;i.setAttribute("fmp_c","".concat(t));}this.setTag(i,t);}}},e}(),Le=Ce,Ae=function(){return Ae=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ae.apply(this,arguments)},He=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,[])).next());}))},qe=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}},Me=new(function(){function e(){this.timer=null,this.customPerfDetail={},this.perfConfig={perfDetail:{}};}return e.prototype.recordPerf=function(e){return He(this,void 0,void 0,(function(){var t,r,i,a,c=this;return qe(this,(function(s){return t=e.options,r=e.uniqueId,i=e.customPerf,a=void 0===i?{}:i,this.timer?(this.customPerfDetail=Ae(Ae({},this.customPerfDetail),a),clearTimeout(this.timer)):this.customPerfDetail=Ae(Ae({},this.customPerfDetail),a),this.timer=setTimeout((function(){return He(c,void 0,void 0,(function(){var e,i,a,c,s,u,l,f,p,h,d,v,y,g,m,w,b,R;return qe(this,(function(S){switch(S.label){case 0:e=new D,this.perfConfig.perfDetail=e.getPerfTiming(t.perfEntries),t.useFmp&&(i=new Le,this.perfConfig.perfDetail.fmpTime=parseInt(String((null==i?void 0:i.fmpTime)||0),10)),S.label=1;case 1:return S.trys.push([1,3,,4]),[4,(new Oe).getNewPerf()];case 2:return c=S.sent(),a=Ae(Ae(Ae({},this.perfConfig.perfDetail),c),this.customPerfDetail),[3,4];case 3:return S.sent(),[3,4];case 4:return s=t.pagePath,u=t.group,l=t.subGroup,f=t.service,p=t.serviceVersion,(h=s)||(h=location.href.replace(location.origin,"")||"/"),d=E.getLogTime(),v=n(),y=Ae(Ae(Ae({},a),{pagePath:h,group:u,subGroup:l,service:f,serviceVersion:p,logtime:d}),v),(g=E.getUserid())&&(y.userid=g),r&&(y.uniqueId=r),s&&(m=o(s),w=s.startsWith("/")?"":"/",s.startsWith("http")?y.groupedPagePath=s:y.groupedPagePath=location.origin+w+m),b=(null===(R=t.hooks)||void 0===R?void 0:R.reportHook)||t.reportHook,[4,new k("PERF",t.collector,b).send(y)];case 5:return S.sent(),this.clearPerf(),[2]}}))}))}),t.sendPerfTime||6e3),[2]}))}))},e.prototype.clearPerf=function(){window.performance&&window.performance.clearResourceTimings&&(window.performance.clearResourceTimings(),this.perfConfig={perfDetail:{}},this.customPerfDetail={},clearTimeout(this.timer));},e}()),De=10240;function je(e,t,r){if(void 0===t&&(t=De),e)try{var n=e;if("string"==typeof e)n=e;else if(e instanceof FormData){var o={};try{for(var i=(u=e.entries()).next();!i.done;){var a=i.value,c=a[0];(f=a[1])instanceof File?o[c]="[File: ".concat(f.name,", size: ").concat(f.size,"]"):o[c]=f,i=u.next();}}catch(e){o._error="[FormData parsing failed]";}n=JSON.stringify(o);}else if(e instanceof URLSearchParams){var s={};try{var u;for(i=(u=e.entries()).next();!i.done;){var l=i.value,f=(c=l[0],l[1]);s[c]=f,i=u.next();}}catch(e){s._error="[URLSearchParams parsing failed]";}n=JSON.stringify(s);}else n=e instanceof ArrayBuffer?"[Binary data, size: ".concat(e.byteLength,"]"):e instanceof Uint8Array?"[Binary data, size: ".concat(e.length,"]"):JSON.stringify(e);if(r&&"function"==typeof r)try{var p=r("string"==typeof n?JSON.parse(n):n);n="string"==typeof p?p:JSON.stringify(p);}catch(e){}return "string"==typeof n&&n.length>t?n.substring(0,t)+"... [truncated]":"string"==typeof n?n:JSON.stringify(n)}catch(e){return "[Error processing request body]"}}function Ne(e){if(e)try{var t={};if(e instanceof Headers)try{for(var r=e.entries(),n=r.next();!n.done;){var o=n.value,i=o[0],a=o[1];i.toLowerCase().includes("content-type")||i.toLowerCase().includes("user-agent")||i.toLowerCase().includes("authorization")||i.toLowerCase().includes("cookie")||i.toLowerCase().includes("token")||i.toLowerCase().includes("sw8")||(t[i]=a),n=r.next();}}catch(e){t._error="[Headers parsing failed]";}else if("object"==typeof e)for(var c=0,s=Object.entries(e);c<s.length;c++){var u=s[c];i=u[0],a=u[1];i.toLowerCase().includes("content-type")||i.toLowerCase().includes("user-agent")||i.toLowerCase().includes("authorization")||i.toLowerCase().includes("cookie")||i.toLowerCase().includes("token")||i.toLowerCase().includes("sw8")||(t[i]=String(a));}return Object.keys(t).length>0?t:void 0}catch(e){return}}function Ue(e){return Boolean(e.collectRequestParams)}var Fe=function(){return Fe=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Fe.apply(this,arguments)},Ge=function(e){return window.btoa(e)};function We(e,t){var r=window.XMLHttpRequest,n=XMLHttpRequest.prototype.send,o=XMLHttpRequest.prototype.open;function i(e){var t=new CustomEvent(e,{detail:this});window.dispatchEvent(t);}r.getRequestConfig=[],window.XMLHttpRequest=function(){var t=new r;return t.addEventListener("readystatechange",(function(){i.call(this,"xhrReadyStateChange");}),false),t.open=function(e,t,r,n,i){return this.getRequestConfig=arguments,o.apply(this,arguments)},t.send=function(t){var r;return Ue(e)&&t&&(this.requestBody=je(t,e.maxRequestBodySize,null===(r=e.hooks)||void 0===r?void 0:r.requestParamsHook)),n.apply(this,arguments)},t};var a=[];window.addEventListener("xhrReadyStateChange",(function(r){var n,o={traceId:"",service:e.service+h,spans:[],serviceInstance:e.serviceVersion,traceSegmentId:""},i=r.detail.readyState,c=r.detail.getRequestConfig,d=c[1],v={};0===c[1].indexOf("http://")||0===c[1].indexOf("https://")?v=new URL(c[1]):0===c[1].indexOf("//")?v=new URL("".concat(window.location.protocol).concat(c[1])):(v=new URL(window.location.href)).pathname=c[1];if((!(null===(n=e.noTraceUrls)||void 0===n?void 0:n.length)||!e.noTraceUrls.some((function(e){if("string"==typeof e){if(e===d)return true}else if(e instanceof RegExp&&e.test(d))return true})))&&(!([s.ERROR,s.ERRORS,s.PERF,s.SEGMENTS].indexOf(v.pathname)>-1)||e.traceSDKInternal)){if(i===u.OPENED){var y=I(),g=I();a.push({event:r.detail,startTime:(new Date).getTime(),traceId:y,traceSegmentId:g});var m=window.ELK_WHITESCREEN_TRACEID||String(Ge(y)),w=String(Ge(g)),b=String(Ge(o.service)),E=String(Ge(o.serviceInstance)),R=String(Ge(e.pagePath)),S=String(Ge(v.host)),T=o.spans.length,O="".concat(1,"-").concat(m,"-").concat(w,"-").concat(T,"-").concat(b,"-").concat(E,"-").concat(R,"-").concat(S);r.detail.setRequestHeader("sw8",O),sessionStorage.setItem("current-sw-traceId",m);}if(i===u.DONE){for(var k=(new Date).getTime(),x=0;x<a.length;x++)if(a[x].event.readyState===u.DONE){var P={};a[x].event.status&&(P=new URL(a[x].event.responseURL));var _={operationName:e.pagePath,startTime:a[x].startTime,endTime:k,spanId:o.spans.length,spanLayer:l,spanType:f,isError:0===r.detail.status||r.detail.status>=400,parentSpanId:o.spans.length-1,componentId:p,peer:P.host,tags:e.detailMode?[{key:"http.method",value:c[0]},{key:"url",value:a[x].event.responseURL}]:void 0};(o=Fe(Fe({},o),{traceId:a[x].traceId,traceSegmentId:a[x].traceSegmentId})).spans.push(_),a.splice(x,1);}t.push(o);}}}));}var Ve=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,[])).next());}))},Be=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}};var Qe=function(){function e(e,t){ void 0===e&&(e=100),this.slowInteractions=[],this.observer=null,this.isSupported=false,this.maxQueueSize=100,this.interactionMap=new Map,this.allowedEventTypes=["pointerup","click","keyup"],this.threshold=e,this.onQueueFull=t,this.isSupported=this.checkBrowserSupport();}return e.prototype.checkBrowserSupport=function(){if("undefined"==typeof window)return false;if(!("PerformanceObserver"in window))return false;try{var e=PerformanceObserver.supportedEntryTypes;if(!e||!e.includes("event"))return !1}catch(e){return false}return true},e.prototype.isSupportedBrowser=function(){return this.isSupported},e.prototype.start=function(){var e=this;if(!this.isSupported)return this.slowInteractions;try{this.observer=new PerformanceObserver((function(t){try{e.handlePerformanceEntries(t.getEntries());}catch(e){}})),this.observer.observe({type:"event",buffered:!0});}catch(e){}return this.slowInteractions},e.prototype.stop=function(){this.observer&&(this.observer.disconnect(),this.observer=null);},e.prototype.handlePerformanceEntries=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];"interactionId"in n&&n.interactionId&&n.interactionId>0?this.processWithInteractionId(n):this.allowedEventTypes.includes(n.name)&&this.processWithoutInteractionId(n);}},e.prototype.processWithInteractionId=function(e){var t=e.interactionId,r=this.interactionMap.get(t);if(r)e.duration>r.sintDuration&&(r.sintDuration=Math.round(e.duration),r.sintEventType=e.name,r.sintTimestamp=this.getEventTimestamp(e),r.sintTargetClass=this.getTargetClass(e),r.sintTargetTag=this.getTargetTag(e),r.logtime=E.getLogTime());else if(e.duration>this.threshold){var n=this.createInteraction(e,t);this.interactionMap.set(t,n),this.addToQueue(n);}},e.prototype.processWithoutInteractionId=function(e){if(e.duration>this.threshold){var t=this.createInteraction(e);this.addToQueue(t);}},e.prototype.createInteraction=function(e,t){return {logtime:E.getLogTime(),sintTimestamp:this.getEventTimestamp(e),sintDuration:Math.round(e.duration),sintEventType:e.name,sintTargetClass:this.getTargetClass(e),sintTargetTag:this.getTargetTag(e),sintThreshold:this.threshold,sintInteractionId:t}},e.prototype.getEventTimestamp=function(e){try{var t=window.performance,r=t&&t.timeOrigin||t&&t.timing&&t.timing.navigationStart||0;if(r)return Math.round(r+e.startTime)}catch(e){}return Date.now()},e.prototype.addToQueue=function(e){if(this.slowInteractions.length>=this.maxQueueSize)if(this.onQueueFull)this.onQueueFull();else {var t=this.slowInteractions.shift();t.sintInteractionId&&this.interactionMap.delete(t.sintInteractionId);}this.slowInteractions.push(e);},e.prototype.getTargetClass=function(e){try{var t=e.target;if(t&&t.className){if("string"==typeof t.className)return t.className;if(t.className&&"object"==typeof t.className)return t.className.baseVal||""}return ""}catch(e){return ""}},e.prototype.getTargetTag=function(e){try{var t=e.target;return t&&t.tagName?t.tagName.toLowerCase():""}catch(e){return ""}},e.prototype.getSlowInteractions=function(){return this.slowInteractions},e.prototype.clearQueue=function(){this.slowInteractions=[],this.interactionMap.clear();},e}(),Ke=function(){return Ke=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ke.apply(this,arguments)},Je=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,[])).next());}))},Xe=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}},ze=function(){function e(e,t){ void 0===e&&(e=100),void 0===t&&(t=3e4);var r=this;this.reportTimer=null,this.options=null,this.unloadListenerAdded=false,this.unloadHandler=null,this.handleQueueFull=function(){r.options&&(r.reportSlowInteractions(),r.reportTimer&&(clearInterval(r.reportTimer),r.reportTimer=null),r.startPeriodicReporting());},this.threshold=e,this.reportInterval=t,this.collector=new Qe(e,this.handleQueueFull);}return e.prototype.start=function(e){e&&(this.options=e);var t=this.collector.start();return this.options&&this.collector.isSupportedBrowser()&&(this.startPeriodicReporting(),this.setupUnloadReporting()),t},e.prototype.startPeriodicReporting=function(){var e=this;this.reportTimer&&clearInterval(this.reportTimer),this.reportTimer=setInterval((function(){e.reportSlowInteractions();}),this.reportInterval);},e.prototype.setupUnloadReporting=function(){var e=this;this.unloadListenerAdded||(this.unloadHandler=function(){e.reportSlowInteractions(true);},window.addEventListener("beforeunload",this.unloadHandler),window.addEventListener("pagehide",this.unloadHandler),this.unloadListenerAdded=true);},e.prototype.reportSlowInteractions=function(e){return Je(this,void 0,void 0,(function(){var e,t,r,o,i,a,c,s,u,l,f,p,h,d;return Xe(this,(function(v){switch(v.label){case 0:if(0===(e=this.collector.getSlowInteractions()).length)return [2];t=e.slice(),this.collector.clearQueue(),v.label=1;case 1:return v.trys.push([1,3,,4]),r=this.options,o=r.group,i=r.subGroup,a=r.service,c=r.serviceVersion,s=r.pagePath,u=r.collector,l=r.hooks,f=E.getUserid(),p=n(),h=t.map((function(e){return Ke(Ke(Ke(Ke({group:o,subGroup:i,service:a,serviceVersion:c,pagePath:s||location.href},e||{}),{sdkVersion:"v1.1.27"}),f?{userid:f}:{}),p)})),d=null==l?void 0:l.reportHook,[4,new k("SLOW_INTERACTIONS",u,d).send(h)];case 2:return v.sent(),[3,4];case 3:return v.sent(),[3,4];case 4:return [2]}}))}))},e.prototype.stop=function(){this.collector.stop(),this.reportTimer&&(clearInterval(this.reportTimer),this.reportTimer=null),this.unloadListenerAdded&&this.unloadHandler&&(window.removeEventListener("beforeunload",this.unloadHandler),window.removeEventListener("pagehide",this.unloadHandler),this.unloadListenerAdded=false,this.unloadHandler=null);},e.prototype.getSlowInteractions=function(){return this.collector.getSlowInteractions()},e.prototype.clearQueue=function(){this.collector.clearQueue();},e.prototype.getConfig=function(){return {threshold:this.threshold,reportInterval:this.reportInterval,queueSize:this.collector.getSlowInteractions().length}},e}(),Ye=null;var Ze,$e=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,[])).next());}))},et=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}},tt=new(function(){function e(){this.queues=[],this.collector="",this.hook=void 0,this.isLock=false;}return e.prototype.addTask=function(e,t,r){this.queues.push(e),this.collector=t,this.hook=r;},e.prototype.fireTasks=function(){return $e(this,void 0,void 0,(function(){return et(this,(function(e){switch(e.label){case 0:return this.queues&&this.queues.length?[4,new k("ERRORS",this.collector,this.hook).send(this.queues)]:[2];case 1:return e.sent(),this.queues=[],[2]}}))}))},e.prototype.finallyFireTasks=function(){var e=this;this.isLock||(this.isLock=true,window.onbeforeunload=function(){e.queues.length&&new k("ERRORS",e.collector,e.hook).send(e.queues);});},e}()),rt=false,nt=function(){function e(){this.logInfo={uniqueId:"",category:a.UNKNOWN_ERROR,service:"",serviceVersion:"",group:"",subGroup:"",pagePath:"",grade:c.INFO,errorUrl:"",line:0,col:0,message:"",firstReportedError:false,collector:"",reportHook:void 0};}return e.prototype.traceInfo=function(e){rt||this.logInfo.category!==a.JS_ERROR||(rt=true,this.logInfo.firstReportedError=true);var t=this.logInfo,r=t.collector,n=t.reportHook;delete this.logInfo.collector,tt.addTask(this.logInfo,r,n),tt.finallyFireTasks(),setTimeout((function(){tt.fireTasks();}),e||3e4);},e}(),ot=(Ze=function(e,t){return Ze=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t;}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);},Ze(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e;}Ze(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r);}),it=function(){return it=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},it.apply(this,arguments)},at=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,[])).next());}))},ct=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}},st=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return ot(t,e),t.prototype.handleErrors=function(e){var t=this,r=window.onerror;window.onerror=function(n,o,i,s,u){return at(t,void 0,void 0,(function(){var t,l;return ct(this,(function(f){switch(f.label){case 0:return r&&r(n,o,i,s,u),n=H(e,n),t={category:a.JS_ERROR,grade:c.ERROR,errorUrl:o,line:i,col:s,message:n,stack:u&&u.stack||""},[4,q(e,t)];case 1:return f.sent()?(l=A(e,[]),this.logInfo=it(it({},l),t),this.traceInfo(e.sendErrorTime),[2]):[2]}}))}))};},t}(nt),ut=new st,lt=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t;}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t;}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n);}}(),ft=function(){return ft=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ft.apply(this,arguments)},pt=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,[])).next());}))},ht=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}},dt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return lt(t,e),t.prototype.handleErrors=function(e){var t=this;window.addEventListener("unhandledrejection",(function(r){return pt(t,void 0,void 0,(function(){var t,n,o,i,s,u,l,f,p,h;return ht(this,(function(d){switch(d.label){case 0:if(!r||!r.reason)return [2];if(null===(h=null==r?void 0:r.reason)||void 0===h?void 0:h.request)return [2];t="",d.label=1;case 1:return d.trys.push([1,3,,4]),r.reason.config&&r.reason.config.url&&(t=r.reason.config.url),n=r.reason.message||"",n=H(e,n),o=r.reason.stack||"",i={category:a.PROMISE_ERROR,grade:c.ERROR,errorUrl:t||location.href,message:n,stack:o},o.includes(v)&&o.includes(y)&&(s=o.split(y),u=s[0],l=s[1],u=u.replace(v,""),i.category=a.FETCH_ERROR,i.stack=l,i.traceId=u),[4,q(e,i)];case 2:return d.sent()?(f=A(e,[]),this.logInfo=ft(ft({},f),i),this.traceInfo(e.sendErrorTime),[3,4]):[2];case 3:return p=d.sent(),console.log(p),[3,4];case 4:return [2]}}))}))}));},t}(nt),vt=new dt,yt=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t;}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t;}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n);}}(),gt=function(){return gt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},gt.apply(this,arguments)},mt=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,[])).next());}))},wt=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}},bt=400,Et=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return yt(t,e),t.prototype.handleWeblogError=function(e,t){if(!e.includes("//cbasspider.10jqka.com.cn"))return t;return gt(gt({},t),{group:"weblog",service:"weblog",subGroup:"weblog"})},t.prototype.isApmApi=function(e,t,r){var n,o,i,a,c;return !(!e||!e.toString().includes(r))||(!!(null===(i=null===(o=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.getRequestConfig)||void 0===o?void 0:o[1])||void 0===i?void 0:i.includes(r))||!!(null===(c=null===(a=null==t?void 0:t.target)||void 0===a?void 0:a.pageSpyRequestUrl)||void 0===c?void 0:c.includes(r)))},t.prototype.shouldReportRequest=function(e,t){var r;if(e)return true;var n=null===(r=null==t?void 0:t.currentTarget)||void 0===r?void 0:r.status;return n>=bt||0===n},t.prototype.handleError=function(e){var r=this;if(window.XMLHttpRequest)if(t.isInterceptorRegistered)console.warn("[SkyWalking] AjaxErrors interceptor already registered, skipping duplicate registration");else {t.isInterceptorRegistered=true;var n=window.XMLHttpRequest.prototype,o=n.open,i=n.send,s=n.setRequestHeader,u=o,l=i,f=s,p=new WeakMap,h=new WeakMap,v=function(t){var n=t.start,o=t.xhr;return function(t){return mt(r,void 0,void 0,(function(){var r,i,s,u,l,f,h,v,y,g,m,w,b,E,R,S,T,O,k,I,x,P,_,C,L,M,D,j,N,U;return wt(this,(function(F){switch(F.label){case 0:r=Date.now(),s=(i=r-n)>=e.maxReqCostTime,u=t.type,F.label=1;case 1:if(F.trys.push([1,3,,4]),!this.shouldReportRequest(s,t))return [2];if(l=p.get(o)||{},f=l.url,h=l.method,v=l.headers,y=l.body,g=e.collector,this.isApmApi(f,t,g))return [2];if(m="error"===(null==t?void 0:t.type)&&0===(null===(M=null==t?void 0:t.currentTarget)||void 0===M?void 0:M.status),w=t.currentTarget.status,b=void 0,"timeout"===u?(b="net::timeout (status: ".concat(w,")"),(null===(D=null==t?void 0:t.target)||void 0===D?void 0:D.timeout)&&(b+=", ajax timeout: ".concat(t.target.timeout))):s?b="net::slowRequest (status: ".concat(w,"), maxReqCostTime: ").concat(e.maxReqCostTime):m?(b="net::CORS_ERROR (possible causes: CORS, network failure, timeout)",f&&(b+=", URL: ".concat(f.toString()))):b=w>=bt?"net::REQUEST_ERROR(status: ".concat(w,")"):"net::ERR_EMPTY(status: ".concat(w,")"),(null==(E=t.target.response)?void 0:E.length)>d&&(E=E.replace(/\s/g,"")).length>d&&(E="".concat(E.slice(0,d),"...(").concat(w,")")),R="接口响应正常",s&&(R="慢请求"),("load"!==u||w>=bt)&&(S=f||"unknown URL",R=m?"CORS Error: ".concat(S):w>=bt?"Request failed with status code ".concat(w,", URL: ").concat(S):t.target.response||b,R=H(e,R)),T=f||(null===(N=null===(j=t.target)||void 0===j?void 0:j.getRequestConfig)||void 0===N?void 0:N[1])||(null===(U=t.target)||void 0===U?void 0:U.responseURL)||"",O={},Ue(e)&&(h&&(O.reqMethod=h),(k=Ne(v))&&(O.reqHeaders=k),y&&(O.reqBody=y),"GET"===h&&T))try{(I=new URL(T,window.location.origin)).search&&(x={},I.searchParams.forEach((function(e,t){x[t]=e;})),Object.keys(x).length>0&&(O.reqQuery=x));}catch(e){}return P=gt({category:a.AJAX_ERROR,grade:c.ERROR,errorUrl:T,message:R,reqErrType:u,stack:b},O),(s||"timeout"===u)&&(P.slowRequest=i),"load"!==u&&(P.stack=t.target.response||b),[4,q(e,P)];case 2:return F.sent()?(_=A(e,[]),_=this.handleWeblogError(T,_),this.logInfo=gt(gt({},_),P),C=sessionStorage.getItem("current-sw-traceId"),sessionStorage.removeItem("current-sw-traceId"),C&&(this.logInfo.traceId=C),this.traceInfo(e.sendErrorTime),[3,4]):[2];case 3:return L=F.sent(),console.log(L),[3,4];case 4:return [2]}}))}))}};XMLHttpRequest.prototype.open=function(e,t){p.set(this,{url:t,method:e,headers:{},body:void 0});try{if("function"==typeof u)return u.apply(this,arguments)}catch(e){return console.error("XHR open error:",e),o.apply(this,arguments)}},XMLHttpRequest.prototype.setRequestHeader=function(t,r){if(Ue(e)){var n=p.get(this)||{},o=gt({},n.headers||{});o[t]=r,p.set(this,gt(gt({},n),{headers:o}));}try{if("function"==typeof f)return f.apply(this,arguments)}catch(e){return console.error("XHR setRequestHeader error:",e),s.apply(this,arguments)}},XMLHttpRequest.prototype.send=function(t){var r,n=Date.now(),o=this;if(Ue(e)&&t){var a=p.get(this)||{};p.set(this,gt(gt({},a),{body:je(t,e.maxRequestBodySize,null===(r=e.hooks)||void 0===r?void 0:r.requestParamsHook)}));}if(this.addEventListener){var c=h.get(this);c&&(c.load&&this.removeEventListener("load",c.load),c.error&&this.removeEventListener("error",c.error),c.abort&&this.removeEventListener("abort",c.abort),c.timeout&&this.removeEventListener("timeout",c.timeout));var s={load:v({start:n,xhr:o}),error:v({start:n,xhr:o}),abort:v({start:n,xhr:o}),timeout:v({start:n,xhr:o})};this.addEventListener("load",s.load),this.addEventListener("error",s.error),this.addEventListener("abort",s.abort),this.addEventListener("timeout",s.timeout),h.set(this,s);}else {var u=this.onreadystatechange;this.onreadystatechange=function(e){u&&u.apply(this,arguments),4===this.readyState&&v({start:n,xhr:o})(e);};}try{if("function"==typeof l)return l.apply(this,arguments)}catch(e){return console.error("XHR send error:",e),i.apply(this,arguments)}};}},t.isInterceptorRegistered=false,t}(nt),Rt=new Et;function St(e){var t,r="";return e instanceof Request?(r=e.url,t=new URL(e.url)):0===(r=e.toString()).indexOf("http://")||0===r.indexOf("https://")?t=new URL(r):0===r.indexOf("//")?t=new URL("".concat(window.location.protocol).concat(r)):(t=new URL(window.location.href)).pathname=r,{url:t,originUrl:r}}var Tt=function(){function e(){this.contexts=new Map,this.requestCounter=0;}return e.prototype.setContext=function(e,t){this.contexts.set(e,t),this.cleanupExpiredContexts();},e.prototype.getContext=function(e){return this.contexts.get(e)},e.prototype.removeContext=function(e){this.contexts.delete(e);},e.prototype.generateRequestId=function(){return this.requestCounter++,"fetch_".concat(Date.now(),"_").concat(this.requestCounter)},e.prototype.findContextByUrl=function(e,t){ void 0===t&&(t=5e3);for(var r,n=Date.now(),o=1/0,i=Array.from(this.contexts.values()),a=0;a<i.length;a++){var c=i[a],s=n-c.startTime;s<=t&&c.url===e&&s<o&&(r=c,o=s);}return r},e.prototype.cleanupExpiredContexts=function(){for(var e=Date.now(),t=Array.from(this.contexts.entries()),r=0;r<t.length;r++){var n=t[r],o=n[0];e-n[1].startTime>3e4&&this.contexts.delete(o);}},e.prototype.getContextCount=function(){return this.contexts.size},e.prototype.clear=function(){this.contexts.clear(),this.requestCounter=0;},e}(),Ot=new Tt,kt=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t;}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t;}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n);}}(),It=function(){return It=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},It.apply(this,arguments)},xt=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,[])).next());}))},Pt=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}},_t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return kt(t,e),t.prototype.handleWeblogError=function(e,t){if(!e.includes("//cbasspider.10jqka.com.cn"))return t;return It(It({},t),{group:"weblog",service:"weblog",subGroup:"weblog"})},t.prototype.shouldReportRequest=function(e){return !(null==e?void 0:e.ok)&&(0===e.status||e.status>=400)},t.prototype.handleError=function(e){var r=this;if(window.fetch)if(t.isInterceptorRegistered)console.warn("[SkyWalking] FetchErrors interceptor already registered, skipping duplicate registration");else {t.isInterceptorRegistered=true;var n=window.fetch;window.fetch=function(t,o){return xt(r,void 0,void 0,(function(){var r,i,u,l,f,p,h,d,v,y,g,m,w,b,E,R,S,T,O,k,I,x,P,_,C;return Pt(this,(function(L){switch(L.label){case 0:r={},L.label=1;case 1:if(L.trys.push([1,5,,10]),t instanceof Request)return [2,n(t,o)];if(i=St(t),b=i.url,u=i.originUrl,l=function(e,t,r){var n;if((null===(n=r.noTraceUrls)||void 0===n?void 0:n.length)&&r.noTraceUrls.some((function(e){return "string"==typeof e?e===t:e instanceof RegExp&&e.test(t)})))return {shouldSkip:true,isSDKInternal:false,isAPMApi:false,reason:"url in noTraceUrls list"};var o=[s.ERROR,s.ERRORS,s.PERF,s.SEGMENTS].indexOf(e.pathname)>-1;return o&&!r.traceSDKInternal?{shouldSkip:true,isSDKInternal:true,isAPMApi:false,reason:"SDK internal request"}:e.href.includes(r.collector)?{shouldSkip:true,isSDKInternal:false,isAPMApi:true,reason:"APM API request"}:{shouldSkip:false,isSDKInternal:o,isAPMApi:false}}(b,u,{noTraceUrls:e.noTraceUrls,collector:e.collector,traceSDKInternal:e.traceSDKInternal}),l.shouldSkip)return [2,n(t,o)];if(Ue(e)&&(f=(null==o?void 0:o.method)||"GET",r.reqMethod=f,o&&(r.reqHeaders=Ne(o.headers),r.reqBody=je(o.body,e.maxRequestBodySize,null===(P=e.hooks)||void 0===P?void 0:P.requestParamsHook)),"GET"===f))try{(p=new URL(b,window.location.origin)).search?(h={},p.searchParams.forEach((function(e,t){h[t]=e;})),Object.keys(h).length>0&&(r.reqQuery=h)):null===(C=null===(_=t.toString())||void 0===_?void 0:_.split("?")[1])||void 0===C||C.split("&").forEach((function(e){var t=e.split("="),n=t[0],o=t[1];r.reqQuery||(r.reqQuery={}),r.reqQuery[n]=o;}));}catch(e){}return [4,n(t,o)];case 2:return d=L.sent(),this.shouldReportRequest(d)?(v="",S="Interface response is normal",y=d.status,R=d.url||b.href,0===y?(v="net::CORS_ERROR (possible causes: CORS, network failure, timeout)",S="CORS Error URL: ".concat(R)):y>=400&&(v="net::REQUEST_ERROR(status: ".concat(y,")"),S="Request failed with status code ".concat(y,", URL: ").concat(R)),g=It({category:a.FETCH_ERROR,grade:c.ERROR,errorUrl:d.url||b.href,message:H(e,S),stack:v,reqErrType:"error"},r),e.noErrorPaths&&e.noErrorPaths.length>0&&e.noErrorPaths.some((function(e){return "string"==typeof e?g.errorUrl.indexOf(e)>-1:e instanceof RegExp&&e.test(g.errorUrl)}))?(console.log("The Fetch error was filtered out by noErrorPaths: ".concat(g.errorUrl)),[2,d.clone()]):[4,q(e,g)]):[3,4];case 3:if(!L.sent())return [2,d.clone()];k=A(e,[]),k=this.handleWeblogError(g.errorUrl,k),this.logInfo=It(It({},k),g);try{(null==(I=Ot.findContextByUrl(b.href))?void 0:I.traceId)?this.logInfo.traceId=I.traceId:(m=sessionStorage.getItem("current-sw-traceId"))&&(this.logInfo.traceId=m);}catch(e){console.warn("Failed to get traceId from context:",e);}this.traceInfo(e.sendErrorTime),L.label=4;case 4:return [2,d.clone()];case 5:w=L.sent(),L.label=6;case 6:if(L.trys.push([6,8,,9]),b=St(t).url,E=w instanceof Error?w.message:"Unknown fetch error",R=b.href,S="Fetch exception: ".concat(E,", URL: ").concat(R),T=w instanceof Error?w.stack||w.toString():"net::ERR_FETCH_EXCEPTION",O={category:a.FETCH_ERROR,grade:c.ERROR,errorUrl:R,message:H(e,S),stack:T,reqErrType:"exception"},e.noErrorPaths&&e.noErrorPaths.length>0&&e.noErrorPaths.some((function(e){return "string"==typeof e?O.errorUrl.indexOf(e)>-1:e instanceof RegExp&&e.test(O.errorUrl)})))throw console.log("The Fetch error was filtered out by noErrorPaths:: ".concat(O.errorUrl)),w;return [4,q(e,O)];case 7:if(L.sent()){k=A(e,[]),k=this.handleWeblogError(O.errorUrl,k),this.logInfo=It(It({},k),O);try{(null==(I=Ot.findContextByUrl(b.href))?void 0:I.traceId)&&(this.logInfo.traceId=I.traceId);}catch(e){}this.traceInfo(e.sendErrorTime);}return [3,9];case 8:return x=L.sent(),console.warn("Failed to report fetch error:",x),[3,9];case 9:throw w;case 10:return [2]}}))}))};}},t.isInterceptorRegistered=false,t}(nt),Ct=new _t,Lt=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t;}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t;}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n);}}(),At=function(){return At=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},At.apply(this,arguments)},Ht=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,[])).next());}))},qt=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}},Mt=function(e,t,r){for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))},Dt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Lt(t,e),t.prototype.handleErrors=function(e){var t=this;window.addEventListener("error",(function(r){return Ht(t,void 0,void 0,(function(){var t,n,o,i,s,u,l,f,p,h;return qt(this,(function(d){switch(d.label){case 0:if(!r)return [2];d.label=1;case 1:return d.trys.push([1,3,,4]),t=r.target||r.srcElement,t instanceof HTMLScriptElement||t instanceof HTMLLinkElement||t instanceof HTMLImageElement?(n=t.src||t.href||"",o=[location.href,"".concat(location.origin).concat(location.pathname)],!n||o.includes(n)?[2]:(i=[],(i=["stat.10jqka.com.cn","jjstat.10jqka.com.cn","razor.10jqka.com.cn"]).push("/favicon.ico"),Mt(Mt([],i,true),e.noErrorPaths).some((function(e){return n.indexOf(e)>-1}))?[2]:(s="load ".concat(t.tagName," resource error"),s=H(e,s),u="load ".concat(n," resource error"),/[\?|\&]callback/.test(n)&&(l=(null===(h=null==r?void 0:r.error)||void 0===h?void 0:h.stack)||"no stack information",u="JSONP request failed, stack: ".concat(l)),f={category:a.RESOURCE_ERROR,grade:"IMG"===t.tagName?c.WARNING:c.ERROR,errorUrl:n,message:s,stack:u},[4,q(e,f)]))):[2];case 2:return d.sent()?(p=A(e,[]),this.logInfo=At(At({},p),f),this.traceInfo(e.sendErrorTime),[3,4]):[2];case 3:throw d.sent();case 4:return [2]}}))}))}),true);},t}(nt),jt=new Dt,Nt=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t;}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t;}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n);}}(),Ut=function(){return Ut=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ut.apply(this,arguments)},Ft=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,[])).next());}))},Gt=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}},Wt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Nt(t,e),t.prototype.handleErrors=function(e,t){var r=this;if(!t)return console.warn("Vue handle errors set failed.(SkyWalking)");t.config.errorHandler=function(t,n,o){return Ft(r,void 0,void 0,(function(){var r,n,i;return Gt(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),r=H(e,r=o),n={category:a.VUE_ERROR,grade:c.ERROR,errorUrl:location.href,message:r,stack:t.stack},[4,q(e,n)];case 1:return s.sent()?(i=A(e,[]),this.logInfo=Ut(Ut({},i),n),this.traceInfo(e.sendErrorTime),[3,3]):[2];case 2:throw s.sent();case 3:return [2]}}))}))};},t}(nt),Vt=new Wt,Bt=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t;}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t;}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n);}}(),Qt=function(){return Qt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Qt.apply(this,arguments)},Kt=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,[])).next());}))},Jt=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}},Xt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Bt(t,e),t.prototype.handleErrors=function(e,t){return Kt(this,void 0,void 0,(function(){var r,n,o,i,s,u,l;return Jt(this,(function(f){switch(f.label){case 0:return t=t||{name:"",message:"",stack:""},r=e.category,n=e.grade,o=e.level,i=e.content,s=e.timeout,u={category:r||a.JS_ERROR,grade:n||c.ERROR,errorUrl:t.name||location.href,message:t.message,stack:t.stack},"number"==typeof o&&(u.level=o),i&&(u.content=i),[4,q(e,u)];case 1:return f.sent()?(l=A(e,[]),this.logInfo=Qt(Qt({},l),u),this.traceInfo(s||e.sendErrorTime),[2]):[2]}}))}))},t}(nt),zt=new Xt,Yt=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t;}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t;}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n);}}(),Zt=function(){return Zt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Zt.apply(this,arguments)},$t=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.isLockMonitor=false,t.whiteScreenDetectionCount=0,t.maxDetectionCount=5,t.detectionInterval=500,t}return Yt(t,e),t.prototype.report=function(e,t){var r={message:"检测出白屏,检测方式为: ".concat(t),grade:c.ERROR,category:a.WHITE_SCREEN_ERROR,errorUrl:location.href,whiteScreen:t},n=A(e,[]);this.logInfo=Zt(Zt({},n),r);this.traceInfo(10),"timeout"===t&&Me.recordPerf({options:Zt(Zt(Zt({},e),this.logInfo),{sendPerfTime:10}),uniqueId:n.uniqueId});},t.prototype.checkWhiteScreen=function(){var e,t,r=false,n=document.querySelector("#app")||document.querySelector("#root");if(n)(n.innerHTML?n.innerHTML.replace(/<!---->/g,"").trim():"").length||(r=true);else if(!(null===(e=document.querySelector("body"))||void 0===e?void 0:e.innerText)){r=true;for(var o=document.querySelectorAll("body > div"),i=o.length,a=0;a<i;a++)if(null===(t=o[a])||void 0===t?void 0:t.innerHTML){r=false;break}}return r},t.prototype.monitorWhiteScreenTimeout=function(e){this.isLockMonitor||(this.isLockMonitor=true,this.checkWhiteScreen()&&this.report(e,"timeout"));},t.prototype.monitorWhiteScreenLoad=function(e){var t=this;this.isLockMonitor||(this.checkWhiteScreen()?(this.whiteScreenDetectionCount++,console.log("load: detected white screen for the ".concat(this.whiteScreenDetectionCount,"th time")),this.whiteScreenDetectionCount>=this.maxDetectionCount?(console.log("load: detected white screen ".concat(this.maxDetectionCount," times, confirmed as white screen")),this.isLockMonitor=true,this.report(e,"load")):setTimeout((function(){t.monitorWhiteScreenLoad(e);}),this.detectionInterval)):(this.whiteScreenDetectionCount=0,this.isLockMonitor=true));},t.prototype.handleWhiteScreen=function(e){var t=this;false!==e.whiteScreen&&(setTimeout((function(){t.monitorWhiteScreenTimeout(e);}),e.whiteScreenTimeout||2500),window.addEventListener("load",(function(){setTimeout((function(){t.whiteScreenDetectionCount=0,t.monitorWhiteScreenLoad(e);}),100);})));},t}(nt),er=new $t,tr=function(){return tr=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},tr.apply(this,arguments)},rr=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e));}catch(e){i(e);}}function c(e){try{s(n.throw(e));}catch(e){i(e);}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t);}))).then(a,c);}s((n=n.apply(e,[])).next());}))},nr=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a);}catch(e){c=[6,e],n=0;}finally{r=o=0;}if(5&c[0])throw c[1];return {value:c[0]?c[1]:void 0,done:true}}([c,s])}}},or=new(function(){function t(){this.minSendErrorTime=3e3,this.registered=false,this.reportHRT=false,this.customOptions={collector:"//apm.hexin.cn/skywalking-web",group:"unknown",subGroup:"unknown",rate:1e-4,jsErrors:true,apiErrors:true,resourceErrors:true,autoTracePerf:true,useFmp:false,enableSPA:false,traceSDKInternal:false,perfEntries:false,detailMode:true,noErrorPaths:[],maxReqCostTime:1e4,whiteScreen:true,whiteScreenTimeout:2500,slowInteraction:{enable:false,threshold:200,reportInterval:3e4}};}return t.prototype.register=function(t){"weblog"!==t.service&&(this.registered||(this.registered=true,console.time("register finished"),this._authConfig(t,"register"),this._catchErrors(this.customOptions),this.customOptions.enableSPA||this.customOptions.rate&&e()<this.customOptions.rate&&(this.customOptions.rate=1,this._performance()),function(e){var t,r=this,n=[],o=(null===(t=e.hooks)||void 0===t?void 0:t.reportHook)||e.reportHook;e.noTrace||We(e,n),window.onbeforeunload=function(t){n.length&&new k("SEGMENTS",e.collector,o).send(n);},setInterval((function(){return Ve(r,void 0,void 0,(function(){return Be(this,(function(t){switch(t.label){case 0:return n.length?[4,new k("SEGMENTS",e.collector,o).send(n)]:[2];case 1:return t.sent(),n=[],[2]}}))}))}),e.sendSegmentsTime||12e4);}(this.customOptions),er.handleWhiteScreen(this.customOptions),this._initSlowInteraction(),console.timeEnd("register finished")));},t.prototype.setPerformance=function(e,t){var r=this._authConfig(e,"performance");r.autoTracePerf||(r.autoTracePerf=true),1!==r.rate&&(r.rate=1),this._performance(r,t);},t.prototype.setHRT=function(e,t){if(void 0===e&&(e={}),!this.reportHRT){this.reportHRT=true;var r=this._authConfig(e,"performance");r.autoTracePerf||(r.autoTracePerf=true),1!==r.rate&&(r.rate=1);var n,o,a,c,s,u,l=(n=Date.now(),o=i(performance.now()),a={HRT:o},c=window.__FRONTEND_BRIDGE__||{},s=c.webviewLaunchTime,u=c.webviewType,s&&"preload"!==u&&(a.NHRT=i(n-s),a.NRT=i(n-s-o)),a),f=t?tr(tr({},l),t):l;this._performance(r,f);}},t.prototype._catchErrors=function(e){var t=this._getHandleOpts(e);e.jsErrors&&(ut.handleErrors(t),vt.handleErrors(t),e.vue&&Vt.handleErrors(t,e.vue)),e.apiErrors&&(Rt.handleError(t),Ct.handleError(t)),e.resourceErrors&&jt.handleErrors(t);},t.prototype._performance=function(t,r){var n=t||this.customOptions;if(n.autoTracePerf){var o=n.rate;o&&e()>o||("complete"===document.readyState?Me.recordPerf({options:n,customPerf:r}):window.addEventListener("load",(function(){return Me.recordPerf({options:n,customPerf:r})}),false),n.enableSPA&&window.addEventListener("hashchange",(function(){return Me.recordPerf({options:n,customPerf:r})}),false));}},t.prototype._initSlowInteraction=function(){var e=this.customOptions;e.autoTracePerf&&e.slowInteraction.enable&&function(e,t,r){ void 0===e&&(e=200),void 0===t&&(t=3e4),Ye&&Ye.stop(),(Ye=new ze(e,t)).start(r);}(e.slowInteraction.threshold,e.slowInteraction.reportInterval,e);},t.prototype._authConfig=function(e,t){var r,n,o,i=e.collector,a=e.service,c=e.serviceVersion,s=e.group,u=e.subGroup,l=e.sendErrorTime;if(i){e.collector=i&&i.replace(/\/+$/,"");}if(c&&(e.serviceVersion=function(e){return !e||e.indexOf("offline")>-1?e:"".concat(e).concat(window._offlinePkg?".hxapp":"")}(c)),a){var f=a.split("::"),p=f.length;!s&&p>1&&f[0]&&(e.group=f[0]),!u&&p>2&&f[1]&&(e.subGroup=f[1]),e.service=f.pop();}"object"!=typeof e.hooks&&(e.hooks=tr({},(null===(r=this.customOptions)||void 0===r?void 0:r.hooks)||{})),(null===(n=e.hooks)||void 0===n?void 0:n.reportHook)&&e.reportHook&&(e.hooks.reportHook=e.reportHook),(null===(o=e.hooks)||void 0===o?void 0:o.filterHook)&&e.filterHook&&(e.hooks.filterHook=e.filterHook),l&&l<this.minSendErrorTime&&(l=this.minSendErrorTime);var h=tr(tr({},this.customOptions),e);return "register"===t&&(this.customOptions=h),h},t.prototype._getHandleOpts=function(e){var t=tr(tr({},e),{collector:e.collector,service:e.service,serviceVersion:e.serviceVersion,group:e.group,subGroup:e.subGroup,pagePath:e.pagePath,sendErrorTime:e.sendErrorTime,sendPerfTime:e.sendPerfTime,extraMsg:e.extraMsg,category:e.category,noErrorPaths:e.noErrorPaths,hooks:e.hooks||{},grade:e.grade,level:e.level,content:e.content,maxReqCostTime:e.maxReqCostTime,timeout:e.timeout,pageKey:e.pageKey});return e.pageKey&&(t.pageKey=e.pageKey),t},t.prototype.reportFrameErrors=function(e,t){return rr(this,void 0,void 0,(function(){var r,n,o;return nr(this,(function(i){switch(i.label){case 0:return (null==(r=e.pagePath)?void 0:r.includes("/weblog/weblog.js"))?[2]:(n=this._authConfig(e,"report"),o=this._getHandleOpts(tr({},n)),[4,zt.handleErrors(o,t)]);case 1:return i.sent(),[2]}}))}))},t}());window.ClientMonitor=or;}},n={};function o(e){var t=n[e];if(void 0!==t){if(void 0!==t.error)throw t.error;return t.exports}var i=n[e]={exports:{}};try{var a={id:e,module:i,factory:r[e],require:o};o.i.forEach((function(e){e(a);})),i=a.module,a.factory.call(i.exports,i,i.exports,a.require);}catch(e){throw i.error=e,e}return i.exports}o.m=r,o.c=n,o.i=[],o.hu=function(e){return e+"."+o.h()+".hot-update.js"},o.hmrF=function(){return "main."+o.h()+".hot-update.json"},o.h=function(){return "c9af4ce59e7569c4242c"},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e={},t="skywalking-client-js:",o.l=function(r,n,i,a){if(e[r])e[r].push(n);else {var c,s;if(void 0!==i)for(var u=document.getElementsByTagName("script"),l=0;l<u.length;l++){var f=u[l];if(f.getAttribute("src")==r||f.getAttribute("data-webpack")==t+i){c=f;break}}c||(s=true,(c=document.createElement("script")).charset="utf-8",c.timeout=120,o.nc&&c.setAttribute("nonce",o.nc),c.setAttribute("data-webpack",t+i),c.src=r),e[r]=[n];var p=function(t,n){c.onerror=c.onload=null,clearTimeout(h);var o=e[r];if(delete e[r],c.parentNode&&c.parentNode.removeChild(c),o&&o.forEach((function(e){return e(n)})),t)return t(n)},h=setTimeout(p.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=p.bind(null,c.onerror),c.onload=p.bind(null,c.onload),s&&document.head.appendChild(c);}},function(){var e,t,r,n={},i=o.c,a=[],c=[],s="idle",u=0,l=[];function f(e){s=e;for(var t=[],r=0;r<c.length;r++)t[r]=c[r].call(null,e);return Promise.all(t).then((function(){}))}function p(){0==--u&&f("ready").then((function(){if(0===u){var e=l;l=[];for(var t=0;t<e.length;t++)e[t]();}}));}function h(e){if("idle"!==s)throw new Error("check() is only allowed in idle status");return f("check").then(o.hmrM).then((function(r){return r?f("prepare").then((function(){var n=[];return t=[],Promise.all(Object.keys(o.hmrC).reduce((function(e,i){return o.hmrC[i](r.c,r.r,r.m,e,t,n),e}),[])).then((function(){return t=function(){return e?v(e):f("ready").then((function(){return n}))},0===u?t():new Promise((function(e){l.push((function(){e(t());}));}));var t;}))})):f(y()?"ready":"idle").then((function(){return null}))}))}function d(e){return "ready"!==s?Promise.resolve().then((function(){throw new Error("apply() is only allowed in ready status (state: "+s+")")})):v(e)}function v(e){e=e||{},y();var n=t.map((function(t){return t(e)}));t=void 0;var o=n.map((function(e){return e.error})).filter(Boolean);if(o.length>0)return f("abort").then((function(){throw o[0]}));var i=f("dispose");n.forEach((function(e){e.dispose&&e.dispose();}));var a,c=f("apply"),s=function(e){a||(a=e);},u=[];return n.forEach((function(e){if(e.apply){var t=e.apply(s);if(t)for(var r=0;r<t.length;r++)u.push(t[r]);}})),Promise.all([i,c]).then((function(){return a?f("fail").then((function(){throw a})):r?v(e).then((function(e){return u.forEach((function(t){e.indexOf(t)<0&&e.push(t);})),e})):f("idle").then((function(){return u}))}))}function y(){if(r)return t||(t=[]),Object.keys(o.hmrI).forEach((function(e){r.forEach((function(r){o.hmrI[e](r,t);}));})),r=void 0,true}o.hmrD=n,o.i.push((function(l){var v,y,g,m,w=l.module,b=function(t,r){var n=i[r];if(!n)return t;var o=function(o){if(n.hot.active){if(i[o]){var c=i[o].parents;-1===c.indexOf(r)&&c.push(r);}else a=[r],e=o;-1===n.children.indexOf(o)&&n.children.push(o);}else console.warn("[HMR] unexpected require("+o+") from disposed module "+r),a=[];return t(o)},c=function(e){return {configurable:true,enumerable:true,get:function(){return t[e]},set:function(r){t[e]=r;}}};for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&"e"!==l&&Object.defineProperty(o,l,c(l));return o.e=function(e,r){return function(e){switch(s){case "ready":f("prepare");case "prepare":return u++,e.then(p,p),e;default:return e}}(t.e(e,r))},o}(l.require,l.id);w.hot=(v=l.id,y=w,m={_acceptedDependencies:{},_acceptedErrorHandlers:{},_declinedDependencies:{},_selfAccepted:false,_selfDeclined:false,_selfInvalidated:false,_disposeHandlers:[],_main:g=e!==v,_requireSelf:function(){a=y.parents.slice(),e=g?void 0:v,o(v);},active:true,accept:function(e,t,r){if(void 0===e)m._selfAccepted=true;else if("function"==typeof e)m._selfAccepted=e;else if("object"==typeof e&&null!==e)for(var n=0;n<e.length;n++)m._acceptedDependencies[e[n]]=t||function(){},m._acceptedErrorHandlers[e[n]]=r;else m._acceptedDependencies[e]=t||function(){},m._acceptedErrorHandlers[e]=r;},decline:function(e){if(void 0===e)m._selfDeclined=true;else if("object"==typeof e&&null!==e)for(var t=0;t<e.length;t++)m._declinedDependencies[e[t]]=true;else m._declinedDependencies[e]=true;},dispose:function(e){m._disposeHandlers.push(e);},addDisposeHandler:function(e){m._disposeHandlers.push(e);},removeDisposeHandler:function(e){var t=m._disposeHandlers.indexOf(e);t>=0&&m._disposeHandlers.splice(t,1);},invalidate:function(){switch(this._selfInvalidated=true,s){case "idle":t=[],Object.keys(o.hmrI).forEach((function(e){o.hmrI[e](v,t);})),f("ready");break;case "ready":Object.keys(o.hmrI).forEach((function(e){o.hmrI[e](v,t);}));break;case "prepare":case "check":case "dispose":case "apply":(r=r||[]).push(v);}},check:h,apply:d,status:function(e){if(!e)return s;c.push(e);},addStatusHandler:function(e){c.push(e);},removeStatusHandler:function(e){var t=c.indexOf(e);t>=0&&c.splice(t,1);},data:n[v]},e=void 0,m),w.parents=a,w.children=[],a=[],l.require=b;})),o.hmrC={},o.hmrI={};}(),o.p="/",function(){var e,t,r,n,i,a=o.hmrS_jsonp=o.hmrS_jsonp||{792:0},c={};function s(t,r){return e=r,new Promise((function(e,r){c[t]=e;var n=o.p+o.hu(t),i=new Error;o.l(n,(function(e){if(c[t]){c[t]=void 0;var n=e&&("load"===e.type?"missing":e.type),o=e&&e.target&&e.target.src;i.message="Loading hot update chunk "+t+" failed.\n("+n+": "+o+")",i.name="ChunkLoadError",i.type=n,i.request=o,r(i);}}));}))}function u(e){function c(e){for(var t=[e],r={},n=t.map((function(e){return {chain:[e],id:e}}));n.length>0;){var i=n.pop(),a=i.id,c=i.chain,u=o.c[a];if(u&&(!u.hot._selfAccepted||u.hot._selfInvalidated)){if(u.hot._selfDeclined)return {type:"self-declined",chain:c,moduleId:a};if(u.hot._main)return {type:"unaccepted",chain:c,moduleId:a};for(var l=0;l<u.parents.length;l++){var f=u.parents[l],p=o.c[f];if(p){if(p.hot._declinedDependencies[a])return {type:"declined",chain:c.concat([f]),moduleId:a,parentId:f};-1===t.indexOf(f)&&(p.hot._acceptedDependencies[a]?(r[f]||(r[f]=[]),s(r[f],[a])):(delete r[f],t.push(f),n.push({chain:c.concat([f]),id:f})));}}}}return {type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:r}}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];-1===e.indexOf(n)&&e.push(n);}}o.f&&delete o.f.jsonpHmr,t=void 0;var u={},l=[],f={},p=function(e){console.warn("[HMR] unexpected require("+e.id+") to disposed module");};for(var h in r)if(o.o(r,h)){var d,v=r[h],y=false,g=false,m=false,w="";switch((d=v?c(h):{type:"disposed",moduleId:h}).chain&&(w="\nUpdate propagation: "+d.chain.join(" -> ")),d.type){case "self-declined":e.onDeclined&&e.onDeclined(d),e.ignoreDeclined||(y=new Error("Aborted because of self decline: "+d.moduleId+w));break;case "declined":e.onDeclined&&e.onDeclined(d),e.ignoreDeclined||(y=new Error("Aborted because of declined dependency: "+d.moduleId+" in "+d.parentId+w));break;case "unaccepted":e.onUnaccepted&&e.onUnaccepted(d),e.ignoreUnaccepted||(y=new Error("Aborted because "+h+" is not accepted"+w));break;case "accepted":e.onAccepted&&e.onAccepted(d),g=true;break;case "disposed":e.onDisposed&&e.onDisposed(d),m=true;break;default:throw new Error("Unexception type "+d.type)}if(y)return {error:y};if(g)for(h in f[h]=v,s(l,d.outdatedModules),d.outdatedDependencies)o.o(d.outdatedDependencies,h)&&(u[h]||(u[h]=[]),s(u[h],d.outdatedDependencies[h]));m&&(s(l,[d.moduleId]),f[h]=p);}r=void 0;for(var b,E=[],R=0;R<l.length;R++){var S=l[R],T=o.c[S];T&&(T.hot._selfAccepted||T.hot._main)&&f[S]!==p&&!T.hot._selfInvalidated&&E.push({module:S,require:T.hot._requireSelf,errorHandler:T.hot._selfAccepted});}return {dispose:function(){var e;n.forEach((function(e){delete a[e];})),n=void 0;for(var t,r=l.slice();r.length>0;){var i=r.pop(),c=o.c[i];if(c){var s={},f=c.hot._disposeHandlers;for(R=0;R<f.length;R++)f[R].call(null,s);for(o.hmrD[i]=s,c.hot.active=false,delete o.c[i],delete u[i],R=0;R<c.children.length;R++){var p=o.c[c.children[R]];p&&((e=p.parents.indexOf(i))>=0&&p.parents.splice(e,1));}}}for(var h in u)if(o.o(u,h)&&(c=o.c[h]))for(b=u[h],R=0;R<b.length;R++)t=b[R],(e=c.children.indexOf(t))>=0&&c.children.splice(e,1);},apply:function(t){for(var r in f)o.o(f,r)&&(o.m[r]=f[r]);for(var n=0;n<i.length;n++)i[n](o);for(var a in u)if(o.o(u,a)){var c=o.c[a];if(c){b=u[a];for(var s=[],p=[],h=[],d=0;d<b.length;d++){var v=b[d],y=c.hot._acceptedDependencies[v],g=c.hot._acceptedErrorHandlers[v];if(y){if(-1!==s.indexOf(y))continue;s.push(y),p.push(g),h.push(v);}}for(var m=0;m<s.length;m++)try{s[m].call(null,b);}catch(r){if("function"==typeof p[m])try{p[m](r,{moduleId:a,dependencyId:h[m]});}catch(n){e.onErrored&&e.onErrored({type:"accept-error-handler-errored",moduleId:a,dependencyId:h[m],error:n,originalError:r}),e.ignoreErrored||(t(n),t(r));}else e.onErrored&&e.onErrored({type:"accept-errored",moduleId:a,dependencyId:h[m],error:r}),e.ignoreErrored||t(r);}}}for(var w=0;w<E.length;w++){var R=E[w],S=R.module;try{R.require(S);}catch(r){if("function"==typeof R.errorHandler)try{R.errorHandler(r,{moduleId:S,module:o.c[S]});}catch(n){e.onErrored&&e.onErrored({type:"self-accept-error-handler-errored",moduleId:S,error:n,originalError:r}),e.ignoreErrored||(t(n),t(r));}else e.onErrored&&e.onErrored({type:"self-accept-errored",moduleId:S,error:r}),e.ignoreErrored||t(r);}}return l}}}self.webpackHotUpdateskywalking_client_js=function(t,n,a){for(var s in n)o.o(n,s)&&(r[s]=n[s],e&&e.push(s));a&&i.push(a),c[t]&&(c[t](),c[t]=void 0);},o.hmrI.jsonp=function(e,t){r||(r={},i=[],n=[],t.push(u)),o.o(r,e)||(r[e]=o.m[e]);},o.hmrC.jsonp=function(e,c,l,f,p,h){p.push(u),t={},n=c,r=l.reduce((function(e,t){return e[t]=false,e}),{}),i=[],e.forEach((function(e){o.o(a,e)&&void 0!==a[e]?(f.push(s(e,h)),t[e]=true):t[e]=false;})),o.f&&(o.f.jsonpHmr=function(e,r){t&&o.o(t,e)&&!t[e]&&(r.push(s(e)),t[e]=true);});},o.hmrM=function(){if("undefined"==typeof fetch)throw new Error("No browser support: need fetch API");return fetch(o.p+o.hmrF()).then((function(e){if(404!==e.status){if(!e.ok)throw new Error("Failed to fetch update manifest "+e.statusText);return e.json()}}))};}();o("./src/index.ts");}();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Stable identifier used by the LiveAvatar SDK plugin host. */
|
|
24
|
+
const SKYWALKING_PLUGIN_ID = "liveavatar.skywalking";
|
|
25
|
+
const AVSYNC_ALERTS_CONTRIBUTION_ID = "liveavatar.skywalking.avsync-alerts";
|
|
26
|
+
const OPERATIONAL_LOGS_CONTRIBUTION_ID = "liveavatar.skywalking.operational-logs";
|
|
27
|
+
const ALERT_LOG_DURATION_MS = 30000;
|
|
28
|
+
const TELEMETRY_PAGE_SIZE = 1000;
|
|
29
|
+
/**
|
|
30
|
+
* The platform limits the complete top-level `content` value of one error
|
|
31
|
+
* record to 32 KiB. Keep a margin for platform serialization differences.
|
|
32
|
+
*/
|
|
33
|
+
const EVIDENCE_CONTENT_BYTE_LIMIT = 28 * 1024;
|
|
34
|
+
const FRAME_METADATA_MAX_ASSOCIATION_AGE_MS = 150;
|
|
35
|
+
const TIME_SYNC_BUCKET_MS = 1000;
|
|
36
|
+
const SKYWALKING_SERVICE = "yy-tx::liveavatar-js-sdk";
|
|
37
|
+
const DOMESTIC_COLLECTOR = "https://apm.hexin.cn/skywalking-web";
|
|
38
|
+
const OVERSEAS_COLLECTOR = "https://apm.ainvest.com/skywalking-web";
|
|
39
|
+
const REGISTRATION_STATE_KEY = Symbol.for("liveavatar.skywalking.registration-state");
|
|
40
|
+
/**
|
|
41
|
+
* Reports LiveAvatar A/V-sync incident lifecycle events through the bundled or
|
|
42
|
+
* externally provided SkyWalking client.
|
|
43
|
+
*/
|
|
44
|
+
class SkyWalkingPlugin {
|
|
45
|
+
constructor(config = {}) {
|
|
46
|
+
this.id = SKYWALKING_PLUGIN_ID;
|
|
47
|
+
/** SDK Plugin API v1 is the registrar-based public plugin contract. */
|
|
48
|
+
this.apiVersion = 1;
|
|
49
|
+
this._nextInstallationGeneration = 0;
|
|
50
|
+
this._skyWalkingConfig = { ...config };
|
|
51
|
+
}
|
|
52
|
+
setup(registrar) {
|
|
53
|
+
this._deactivateInstallation();
|
|
54
|
+
registerSkyWalking(this._skyWalkingConfig);
|
|
55
|
+
const diagnostics = registrar.consume(liveavatarJsSdk.SDK_AVSYNC_DIAGNOSTICS_V1);
|
|
56
|
+
const installation = {
|
|
57
|
+
generation: ++this._nextInstallationGeneration,
|
|
58
|
+
diagnostics,
|
|
59
|
+
abortController: new AbortController(),
|
|
60
|
+
alertReportStates: new Map(),
|
|
61
|
+
active: true,
|
|
62
|
+
};
|
|
63
|
+
this._installation = installation;
|
|
64
|
+
try {
|
|
65
|
+
registrar.observe(liveavatarJsSdk.SDK_AVSYNC_ALERTS_V1, {
|
|
66
|
+
id: AVSYNC_ALERTS_CONTRIBUTION_ID,
|
|
67
|
+
handler: (alert, context) => this._handleAlertNotification(installation, alert, context.signal),
|
|
68
|
+
});
|
|
69
|
+
registrar.observe(liveavatarJsSdk.SDK_OPERATIONAL_LOGS_V1, {
|
|
70
|
+
id: OPERATIONAL_LOGS_CONTRIBUTION_ID,
|
|
71
|
+
handler: (record, context) => this._handleOperationalLog(installation, record, context.signal),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
this._deactivateInstallation();
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
dispose() {
|
|
80
|
+
this._deactivateInstallation();
|
|
81
|
+
}
|
|
82
|
+
_handleAlertNotification(installation, alert, signal) {
|
|
83
|
+
if (!this._isInvocationActive(installation, signal)) {
|
|
84
|
+
return Promise.resolve();
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
if (alert.phase === "raised") {
|
|
88
|
+
const state = installation.alertReportStates.get(alert.alertId) ?? {
|
|
89
|
+
tail: Promise.resolve(),
|
|
90
|
+
lastSuccessfulToWallClockMs: undefined,
|
|
91
|
+
closing: false,
|
|
92
|
+
};
|
|
93
|
+
if (state.closing)
|
|
94
|
+
return Promise.resolve();
|
|
95
|
+
installation.alertReportStates.set(alert.alertId, state);
|
|
96
|
+
return this._enqueue(state, () => this._runObserverTask(installation, signal, "A/V Sync alert", () => this._reportActiveAlert(installation, alert, state, signal)));
|
|
97
|
+
}
|
|
98
|
+
const state = installation.alertReportStates.get(alert.alertId);
|
|
99
|
+
if (state === undefined || state.closing)
|
|
100
|
+
return Promise.resolve();
|
|
101
|
+
if (alert.phase === "updated") {
|
|
102
|
+
return this._enqueue(state, () => this._runObserverTask(installation, signal, "A/V Sync alert update", () => this._reportActiveAlert(installation, alert, state, signal)));
|
|
103
|
+
}
|
|
104
|
+
state.closing = true;
|
|
105
|
+
const recoveredAtWallClockMs = Date.now();
|
|
106
|
+
const report = this._enqueue(state, () => this._runObserverTask(installation, signal, "A/V Sync recovery", () => this._reportRecovery(installation, alert.alertId, recoveredAtWallClockMs, signal)));
|
|
107
|
+
const removeState = () => {
|
|
108
|
+
if (installation.alertReportStates.get(alert.alertId) === state) {
|
|
109
|
+
installation.alertReportStates.delete(alert.alertId);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
void report.then(removeState, removeState);
|
|
113
|
+
return report;
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
this._warnInvocationFailure(installation, signal, "Failed to handle an A/V Sync alert", error, { alert: toJsonSafeAlert(alert) });
|
|
117
|
+
return Promise.resolve();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
_handleOperationalLog(installation, record, signal) {
|
|
121
|
+
if (!this._isInvocationActive(installation, signal) ||
|
|
122
|
+
record.level !== "error" ||
|
|
123
|
+
record.event !== "sdk.error") {
|
|
124
|
+
return Promise.resolve();
|
|
125
|
+
}
|
|
126
|
+
return this._runObserverTask(installation, signal, "SDK error log", () => this._reportSdkError(installation, record, signal));
|
|
127
|
+
}
|
|
128
|
+
_enqueue(state, task) {
|
|
129
|
+
const queued = state.tail.then(task, task);
|
|
130
|
+
state.tail = queued.catch(() => undefined);
|
|
131
|
+
return queued;
|
|
132
|
+
}
|
|
133
|
+
async _reportActiveAlert(installation, alert, state, signal) {
|
|
134
|
+
const isActive = () => this._isInvocationActive(installation, signal);
|
|
135
|
+
if (!isActive())
|
|
136
|
+
return;
|
|
137
|
+
const clientMonitor = getClientMonitor();
|
|
138
|
+
if (clientMonitor === undefined) {
|
|
139
|
+
this._warnInvocation(installation, signal, "ClientMonitor.reportFrameErrors is unavailable", {
|
|
140
|
+
pluginId: this.id,
|
|
141
|
+
alert: toJsonSafeAlert(alert),
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const retrievedAtWallClockMs = Date.now();
|
|
146
|
+
const query = await createEvidenceQuery(alert.phase, state.lastSuccessfulToWallClockMs, [signal, installation.abortController.signal]);
|
|
147
|
+
if (!isActive() || query === undefined)
|
|
148
|
+
return;
|
|
149
|
+
const collection = await collectTelemetry(installation.diagnostics, alert, retrievedAtWallClockMs, query, isActive, (message, error) => this._warnInvocationFailure(installation, signal, message, error, {
|
|
150
|
+
alert: toJsonSafeAlert(alert),
|
|
151
|
+
}));
|
|
152
|
+
if (!isActive() || collection === undefined)
|
|
153
|
+
return;
|
|
154
|
+
const evidenceId = createEvidenceId();
|
|
155
|
+
const chunks = createLogChunkPayloads(evidenceId, alert.alertId, collection.evidence.sessionId, collectPreparedCompactLogs(collection.evidence));
|
|
156
|
+
const payload = createSummaryPayload(evidenceId, toJsonSafeAlert(alert), collection.evidence, chunks.length);
|
|
157
|
+
if (!isActive())
|
|
158
|
+
return;
|
|
159
|
+
try {
|
|
160
|
+
await Promise.resolve(clientMonitor.reportFrameErrors({
|
|
161
|
+
category: "avsync",
|
|
162
|
+
grade: "Warning",
|
|
163
|
+
content: payload,
|
|
164
|
+
}, {
|
|
165
|
+
// The bundled SkyWalking script uses this as errorUrl. An empty
|
|
166
|
+
// name lets it fall back to the browser page URL.
|
|
167
|
+
name: "",
|
|
168
|
+
message: `[LiveAvatar A/V Sync] ${alert.finding}: ${alert.message}`,
|
|
169
|
+
stack: "",
|
|
170
|
+
}));
|
|
171
|
+
for (const chunk of chunks) {
|
|
172
|
+
if (!isActive())
|
|
173
|
+
return;
|
|
174
|
+
await Promise.resolve(clientMonitor.reportFrameErrors({
|
|
175
|
+
category: "avsync",
|
|
176
|
+
grade: "Info",
|
|
177
|
+
content: chunk,
|
|
178
|
+
}, {
|
|
179
|
+
name: "",
|
|
180
|
+
message: `[LiveAvatar A/V Sync] evidence chunk ${chunk.chunk.index + 1}/${chunk.chunk.total}`,
|
|
181
|
+
stack: "",
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
this._warnInvocationFailure(installation, signal, "Failed to report an A/V Sync alert to SkyWalking", error, { alert: toJsonSafeAlert(alert) });
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (!isActive())
|
|
190
|
+
return;
|
|
191
|
+
if (collection.evidence.window.complete &&
|
|
192
|
+
collection.requestedToWallClockMs !== null) {
|
|
193
|
+
state.lastSuccessfulToWallClockMs = collection.requestedToWallClockMs;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async _reportRecovery(installation, alertId, recoveredAtWallClockMs, signal) {
|
|
197
|
+
if (!this._isInvocationActive(installation, signal))
|
|
198
|
+
return;
|
|
199
|
+
const clientMonitor = getClientMonitor();
|
|
200
|
+
if (clientMonitor === undefined) {
|
|
201
|
+
this._warnInvocation(installation, signal, "ClientMonitor.reportFrameErrors is unavailable", {
|
|
202
|
+
pluginId: this.id,
|
|
203
|
+
alertId,
|
|
204
|
+
recoveredAtWallClockMs,
|
|
205
|
+
});
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (!this._isInvocationActive(installation, signal))
|
|
209
|
+
return;
|
|
210
|
+
try {
|
|
211
|
+
await Promise.resolve(clientMonitor.reportFrameErrors({
|
|
212
|
+
category: "avsync",
|
|
213
|
+
grade: "Recovered",
|
|
214
|
+
content: { alertId, recoveredAtWallClockMs },
|
|
215
|
+
}, {
|
|
216
|
+
name: "",
|
|
217
|
+
message: "[LiveAvatar A/V Sync] alert recovered",
|
|
218
|
+
stack: "",
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
this._warnInvocationFailure(installation, signal, "Failed to report an A/V Sync recovery to SkyWalking", error, { alertId, recoveredAtWallClockMs });
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (!this._isInvocationActive(installation, signal))
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
async _reportSdkError(installation, record, signal) {
|
|
229
|
+
if (!this._isInvocationActive(installation, signal))
|
|
230
|
+
return;
|
|
231
|
+
const code = stringOr(record.attributes?.code, "SDK_ERROR");
|
|
232
|
+
const clientMonitor = getClientMonitor();
|
|
233
|
+
if (clientMonitor === undefined) {
|
|
234
|
+
this._warnInvocation(installation, signal, "ClientMonitor.reportFrameErrors is unavailable", {
|
|
235
|
+
pluginId: this.id,
|
|
236
|
+
sdkError: { code },
|
|
237
|
+
});
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const payload = {
|
|
241
|
+
schemaVersion: 2,
|
|
242
|
+
kind: "liveavatar.sdk.error",
|
|
243
|
+
sdkVersion: liveavatarJsSdk.VERSION,
|
|
244
|
+
error: stringifyJson({
|
|
245
|
+
code,
|
|
246
|
+
eventId: record.eventId,
|
|
247
|
+
sequence: record.sequence,
|
|
248
|
+
occurredAtMs: record.occurredAtMs,
|
|
249
|
+
category: record.category,
|
|
250
|
+
event: record.event,
|
|
251
|
+
clientInstanceId: record.clientInstanceId,
|
|
252
|
+
...(record.sessionId === undefined
|
|
253
|
+
? {}
|
|
254
|
+
: { sessionId: record.sessionId }),
|
|
255
|
+
}),
|
|
256
|
+
};
|
|
257
|
+
if (!this._isInvocationActive(installation, signal))
|
|
258
|
+
return;
|
|
259
|
+
try {
|
|
260
|
+
await Promise.resolve(clientMonitor.reportFrameErrors({
|
|
261
|
+
category: "unknown",
|
|
262
|
+
grade: "Error",
|
|
263
|
+
content: payload,
|
|
264
|
+
}, {
|
|
265
|
+
name: "",
|
|
266
|
+
message: `[LiveAvatar SDK] ${code}`,
|
|
267
|
+
stack: "",
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
this._warnInvocationFailure(installation, signal, "Failed to report an SDK error to SkyWalking", error, { eventId: record.eventId, code });
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (!this._isInvocationActive(installation, signal))
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
_deactivateInstallation() {
|
|
278
|
+
const installation = this._installation;
|
|
279
|
+
if (installation === undefined)
|
|
280
|
+
return;
|
|
281
|
+
installation.active = false;
|
|
282
|
+
installation.abortController.abort();
|
|
283
|
+
installation.alertReportStates.clear();
|
|
284
|
+
if (this._installation === installation)
|
|
285
|
+
this._installation = undefined;
|
|
286
|
+
}
|
|
287
|
+
_isInvocationActive(installation, signal) {
|
|
288
|
+
return (this._installation === installation &&
|
|
289
|
+
installation.active &&
|
|
290
|
+
!installation.abortController.signal.aborted &&
|
|
291
|
+
!signal.aborted);
|
|
292
|
+
}
|
|
293
|
+
async _runObserverTask(installation, signal, description, task) {
|
|
294
|
+
try {
|
|
295
|
+
await task();
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
this._warnInvocationFailure(installation, signal, `Failed to handle ${description}`, error);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
_warnInvocationFailure(installation, signal, message, error, details = {}) {
|
|
302
|
+
this._warnInvocation(installation, signal, message, { ...details, error });
|
|
303
|
+
}
|
|
304
|
+
_warnInvocation(installation, signal, message, details) {
|
|
305
|
+
if (!this._isInvocationActive(installation, signal))
|
|
306
|
+
return;
|
|
307
|
+
try {
|
|
308
|
+
console.warn(`[LiveAvatar SkyWalking plugin] ${message}`, details);
|
|
309
|
+
}
|
|
310
|
+
catch {
|
|
311
|
+
// Observability warnings must never fault a detached SDK contribution.
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
/** Creates a fresh plugin instance suitable for `createClient({ plugins })`. */
|
|
316
|
+
function createSkyWalkingPlugin(config = {}) {
|
|
317
|
+
return new SkyWalkingPlugin(config);
|
|
318
|
+
}
|
|
319
|
+
async function collectTelemetry(diagnostics, alert, retrievedAtWallClockMs, query, shouldContinue, onDiagnosticFailure) {
|
|
320
|
+
if (!shouldContinue())
|
|
321
|
+
return undefined;
|
|
322
|
+
let firstPage;
|
|
323
|
+
let analysis = null;
|
|
324
|
+
let analysisUnavailable = false;
|
|
325
|
+
let telemetryResult;
|
|
326
|
+
let analysisResult;
|
|
327
|
+
try {
|
|
328
|
+
[telemetryResult, analysisResult] = await Promise.allSettled([
|
|
329
|
+
diagnostics.getAvSyncRawTelemetry({
|
|
330
|
+
range: query.range,
|
|
331
|
+
pageSize: TELEMETRY_PAGE_SIZE,
|
|
332
|
+
includeSummary: true,
|
|
333
|
+
}),
|
|
334
|
+
diagnostics.getAvSyncAnalysis({ range: query.range }),
|
|
335
|
+
]);
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
if (!shouldContinue())
|
|
339
|
+
return undefined;
|
|
340
|
+
onDiagnosticFailure("Failed to query A/V Sync telemetry", error);
|
|
341
|
+
return {
|
|
342
|
+
evidence: unavailableEvidence(retrievedAtWallClockMs, query, "initial-query-failed", alert),
|
|
343
|
+
requestedToWallClockMs: null,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
if (!shouldContinue())
|
|
347
|
+
return undefined;
|
|
348
|
+
if (telemetryResult.status === "rejected") {
|
|
349
|
+
onDiagnosticFailure("Failed to query A/V Sync telemetry", telemetryResult.reason);
|
|
350
|
+
return {
|
|
351
|
+
evidence: unavailableEvidence(retrievedAtWallClockMs, query, "initial-query-failed", alert),
|
|
352
|
+
requestedToWallClockMs: null,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
firstPage = telemetryResult.value;
|
|
356
|
+
if (analysisResult.status === "fulfilled") {
|
|
357
|
+
analysis = analysisResult.value;
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
analysisUnavailable = true;
|
|
361
|
+
onDiagnosticFailure("Failed to query A/V Sync analysis", analysisResult.reason);
|
|
362
|
+
}
|
|
363
|
+
if (!shouldContinue())
|
|
364
|
+
return undefined;
|
|
365
|
+
const firstPageEvidence = evidenceFromFirstPage(firstPage, query);
|
|
366
|
+
if (firstPage.sessionId !== alert.sessionId) {
|
|
367
|
+
return {
|
|
368
|
+
evidence: {
|
|
369
|
+
...firstPageEvidence,
|
|
370
|
+
window: {
|
|
371
|
+
...firstPageEvidence.window,
|
|
372
|
+
complete: false,
|
|
373
|
+
unavailableReason: "session-mismatch",
|
|
374
|
+
},
|
|
375
|
+
triage: createTriage(alert, null, ["session-mismatch"]),
|
|
376
|
+
},
|
|
377
|
+
requestedToWallClockMs: firstPage.page.requestedToWallClockMs,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
const logs = [...firstPage.avSyncLogs];
|
|
381
|
+
let page = firstPage.page;
|
|
382
|
+
let truncated = page.truncated;
|
|
383
|
+
const seenCursors = new Set();
|
|
384
|
+
while (page.hasMore) {
|
|
385
|
+
if (!shouldContinue())
|
|
386
|
+
return undefined;
|
|
387
|
+
const cursor = page.nextCursor;
|
|
388
|
+
if (cursor === null || seenCursors.has(cursor)) {
|
|
389
|
+
return {
|
|
390
|
+
evidence: compactEvidence(firstPageEvidence, logs, truncated, "cursor-did-not-advance", alert, analysis, analysisUnavailable, firstPage),
|
|
391
|
+
requestedToWallClockMs: firstPage.page.requestedToWallClockMs,
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
seenCursors.add(cursor);
|
|
395
|
+
let continuation;
|
|
396
|
+
try {
|
|
397
|
+
continuation = await diagnostics.getAvSyncRawTelemetry({
|
|
398
|
+
cursor,
|
|
399
|
+
pageSize: TELEMETRY_PAGE_SIZE,
|
|
400
|
+
includeSummary: false,
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
catch (error) {
|
|
404
|
+
if (!shouldContinue())
|
|
405
|
+
return undefined;
|
|
406
|
+
onDiagnosticFailure("Failed to query A/V Sync telemetry continuation", error);
|
|
407
|
+
return {
|
|
408
|
+
evidence: compactEvidence(firstPageEvidence, logs, truncated, "continuation-query-failed", alert, analysis, analysisUnavailable, firstPage),
|
|
409
|
+
requestedToWallClockMs: firstPage.page.requestedToWallClockMs,
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
if (!shouldContinue())
|
|
413
|
+
return undefined;
|
|
414
|
+
if (continuation.sessionId !== alert.sessionId) {
|
|
415
|
+
return {
|
|
416
|
+
evidence: compactEvidence(firstPageEvidence, logs, truncated, "session-mismatch", alert, analysis, analysisUnavailable, firstPage),
|
|
417
|
+
requestedToWallClockMs: firstPage.page.requestedToWallClockMs,
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
logs.push(...continuation.avSyncLogs);
|
|
421
|
+
page = continuation.page;
|
|
422
|
+
truncated = truncated || page.truncated;
|
|
423
|
+
}
|
|
424
|
+
if (!shouldContinue())
|
|
425
|
+
return undefined;
|
|
426
|
+
return {
|
|
427
|
+
evidence: compactEvidence(firstPageEvidence, logs, truncated, undefined, alert, analysis, analysisUnavailable, firstPage, true),
|
|
428
|
+
requestedToWallClockMs: firstPage.page.requestedToWallClockMs,
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
function evidenceFromFirstPage(telemetry, query) {
|
|
432
|
+
return {
|
|
433
|
+
evidenceSchemaVersion: 2,
|
|
434
|
+
sessionId: telemetry.sessionId ?? null,
|
|
435
|
+
window: {
|
|
436
|
+
mode: query.mode,
|
|
437
|
+
requestedFromWallClockMs: telemetry.page.requestedFromWallClockMs,
|
|
438
|
+
requestedToWallClockMs: telemetry.page.requestedToWallClockMs,
|
|
439
|
+
availableFromWallClockMs: telemetry.page.availableFromWallClockMs,
|
|
440
|
+
availableToWallClockMs: telemetry.page.availableToWallClockMs,
|
|
441
|
+
complete: false,
|
|
442
|
+
truncated: telemetry.page.truncated,
|
|
443
|
+
},
|
|
444
|
+
retention: compactRetention(telemetry.avSyncLogRetention),
|
|
445
|
+
triage: null,
|
|
446
|
+
logChunkCount: 0,
|
|
447
|
+
logRecordCount: 0,
|
|
448
|
+
detail: emptyDetail(),
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function unavailableEvidence(_retrievedAtWallClockMs, query, unavailableReason, alert) {
|
|
452
|
+
return {
|
|
453
|
+
evidenceSchemaVersion: 2,
|
|
454
|
+
retention: null,
|
|
455
|
+
sessionId: null,
|
|
456
|
+
window: {
|
|
457
|
+
mode: query.mode,
|
|
458
|
+
requestedFromWallClockMs: null,
|
|
459
|
+
requestedToWallClockMs: null,
|
|
460
|
+
availableFromWallClockMs: null,
|
|
461
|
+
availableToWallClockMs: null,
|
|
462
|
+
complete: false,
|
|
463
|
+
truncated: false,
|
|
464
|
+
unavailableReason,
|
|
465
|
+
},
|
|
466
|
+
triage: createTriage(alert, null, [unavailableReason]),
|
|
467
|
+
logChunkCount: 0,
|
|
468
|
+
logRecordCount: 0,
|
|
469
|
+
detail: emptyDetail(),
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
async function createEvidenceQuery(phase, lastSuccessfulToWallClockMs, signals) {
|
|
473
|
+
if (isAnySignalAborted(signals))
|
|
474
|
+
return undefined;
|
|
475
|
+
if (phase === "raised" || lastSuccessfulToWallClockMs === undefined) {
|
|
476
|
+
return {
|
|
477
|
+
mode: "recent",
|
|
478
|
+
range: { kind: "recent", durationMs: ALERT_LOG_DURATION_MS },
|
|
479
|
+
requestedDurationMs: ALERT_LOG_DURATION_MS,
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
let now = Date.now();
|
|
483
|
+
const nextFromMs = lastSuccessfulToWallClockMs + 1;
|
|
484
|
+
if (now < nextFromMs) {
|
|
485
|
+
await waitForWallClock(nextFromMs, signals);
|
|
486
|
+
if (isAnySignalAborted(signals))
|
|
487
|
+
return undefined;
|
|
488
|
+
now = Date.now();
|
|
489
|
+
}
|
|
490
|
+
const fromMs = Math.max(nextFromMs, now - ALERT_LOG_DURATION_MS);
|
|
491
|
+
const toMs = Math.max(fromMs, now);
|
|
492
|
+
return {
|
|
493
|
+
mode: "wall-clock",
|
|
494
|
+
range: { kind: "wall-clock", fromMs, toMs },
|
|
495
|
+
requestedDurationMs: toMs - fromMs,
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
function waitForWallClock(targetMs, signals) {
|
|
499
|
+
if (isAnySignalAborted(signals))
|
|
500
|
+
return Promise.resolve();
|
|
501
|
+
return new Promise((resolve) => {
|
|
502
|
+
let settled = false;
|
|
503
|
+
let timeout;
|
|
504
|
+
const finish = () => {
|
|
505
|
+
if (settled)
|
|
506
|
+
return;
|
|
507
|
+
settled = true;
|
|
508
|
+
if (timeout !== undefined)
|
|
509
|
+
clearTimeout(timeout);
|
|
510
|
+
for (const signal of signals) {
|
|
511
|
+
signal.removeEventListener("abort", finish);
|
|
512
|
+
}
|
|
513
|
+
resolve();
|
|
514
|
+
};
|
|
515
|
+
timeout = setTimeout(finish, Math.max(1, targetMs - Date.now()));
|
|
516
|
+
for (const signal of signals)
|
|
517
|
+
signal.addEventListener("abort", finish);
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
function isAnySignalAborted(signals) {
|
|
521
|
+
return signals.some((signal) => signal.aborted);
|
|
522
|
+
}
|
|
523
|
+
function compactEvidence(firstPageEvidence, logs, truncated, unavailableReason, alert, analysis, analysisUnavailable, telemetry, complete = false) {
|
|
524
|
+
const compacted = compactLogs(logs, telemetry);
|
|
525
|
+
return {
|
|
526
|
+
...firstPageEvidence,
|
|
527
|
+
window: {
|
|
528
|
+
...firstPageEvidence.window,
|
|
529
|
+
complete,
|
|
530
|
+
truncated,
|
|
531
|
+
...(unavailableReason === undefined ? {} : { unavailableReason }),
|
|
532
|
+
},
|
|
533
|
+
triage: createTriage(alert, analysis, analysisUnavailable ? ["analysis-query-failed"] : []),
|
|
534
|
+
...chunkCompactLogs(compacted.logs, compacted.detail),
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
function compactRetention(retention) {
|
|
538
|
+
if (retention === null)
|
|
539
|
+
return null;
|
|
540
|
+
return {
|
|
541
|
+
storageWriteFailed: retention.storageWriteFailed,
|
|
542
|
+
droppedSegmentCount: retention.droppedSegmentCount,
|
|
543
|
+
droppedLogCount: retention.droppedLogCount,
|
|
544
|
+
oldestSegmentAtMs: retention.oldestSegmentAtMs,
|
|
545
|
+
newestSegmentAtMs: retention.newestSegmentAtMs,
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
function createTriage(alert, analysis, limitations) {
|
|
549
|
+
const usableAnalysis = analysis !== null &&
|
|
550
|
+
analysis.layers !== null &&
|
|
551
|
+
typeof analysis.layers === "object" &&
|
|
552
|
+
Array.isArray(analysis.participants) &&
|
|
553
|
+
typeof analysis.finding === "string";
|
|
554
|
+
return {
|
|
555
|
+
trigger: {
|
|
556
|
+
finding: alert.finding,
|
|
557
|
+
status: alert.status,
|
|
558
|
+
confidence: alert.confidence,
|
|
559
|
+
capturedAtMs: alert.capturedAtMs,
|
|
560
|
+
},
|
|
561
|
+
evaluation: !usableAnalysis || analysis === null
|
|
562
|
+
? null
|
|
563
|
+
: {
|
|
564
|
+
finding: analysis.finding,
|
|
565
|
+
status: analysis.status,
|
|
566
|
+
confidence: analysis.confidence,
|
|
567
|
+
},
|
|
568
|
+
layers: !usableAnalysis || analysis === null
|
|
569
|
+
? null
|
|
570
|
+
: Object.fromEntries(Object.entries(analysis.layers).map(([name, layer]) => [
|
|
571
|
+
name,
|
|
572
|
+
{
|
|
573
|
+
status: layer.status,
|
|
574
|
+
finding: layer.finding,
|
|
575
|
+
confidence: layer.confidence,
|
|
576
|
+
},
|
|
577
|
+
])),
|
|
578
|
+
participants: (!usableAnalysis || analysis === null ? [] : analysis.participants).map((participant) => ({
|
|
579
|
+
participantId: participant.participantId,
|
|
580
|
+
status: participant.status,
|
|
581
|
+
finding: participant.finding,
|
|
582
|
+
confidence: participant.confidence,
|
|
583
|
+
audioTrackId: participant.audioTrackId,
|
|
584
|
+
videoTrackId: participant.videoTrackId,
|
|
585
|
+
metrics: participant.metrics,
|
|
586
|
+
})) ?? [],
|
|
587
|
+
limitations: [
|
|
588
|
+
...new Set([
|
|
589
|
+
...(!usableAnalysis || analysis === null ? [] : analysis.limitations),
|
|
590
|
+
...limitations,
|
|
591
|
+
...(!usableAnalysis && analysis !== null ? ["analysis-invalid"] : []),
|
|
592
|
+
]),
|
|
593
|
+
],
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
function emptyDetail() {
|
|
597
|
+
return {
|
|
598
|
+
projectionVersion: 2,
|
|
599
|
+
sourceRecordCount: 0,
|
|
600
|
+
reportedRecordCount: 0,
|
|
601
|
+
timeSyncInputCount: 0,
|
|
602
|
+
timeSyncReportedCount: 0,
|
|
603
|
+
framePresentationReportedCount: 0,
|
|
604
|
+
verifiedMetadataTimestampCount: 0,
|
|
605
|
+
omittedSetupLifecycleCount: 0,
|
|
606
|
+
oversizeFallbackRecordCount: 0,
|
|
607
|
+
contentByteLimit: EVIDENCE_CONTENT_BYTE_LIMIT,
|
|
608
|
+
chunks: [],
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
function compactLogs(logs, telemetry) {
|
|
612
|
+
const compacted = [];
|
|
613
|
+
const detail = emptyDetail();
|
|
614
|
+
detail.sourceRecordCount = logs.length;
|
|
615
|
+
const timeSyncBuckets = new Map();
|
|
616
|
+
for (const log of logs) {
|
|
617
|
+
if (log.eventName === "time-sync-updated") {
|
|
618
|
+
detail.timeSyncInputCount += 1;
|
|
619
|
+
const correlation = toRecord(log.correlation);
|
|
620
|
+
const key = [
|
|
621
|
+
correlation.participantId ?? "",
|
|
622
|
+
correlation.trackId ?? "",
|
|
623
|
+
correlation.mediaKind ?? "",
|
|
624
|
+
Math.floor(log.wallClockMs / TIME_SYNC_BUCKET_MS),
|
|
625
|
+
].join("|");
|
|
626
|
+
timeSyncBuckets.set(key, log);
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
const compact = compactSourceLog(log);
|
|
630
|
+
if (compact !== null)
|
|
631
|
+
compacted.push(compact);
|
|
632
|
+
else if (log.logType === "lifecycle")
|
|
633
|
+
detail.omittedSetupLifecycleCount += 1;
|
|
634
|
+
}
|
|
635
|
+
const timeSync = [...timeSyncBuckets.values()]
|
|
636
|
+
.sort(compareSourceLogs)
|
|
637
|
+
.map(compactTimeSyncLog);
|
|
638
|
+
detail.timeSyncReportedCount = timeSync.length;
|
|
639
|
+
compacted.push(...timeSync);
|
|
640
|
+
compacted.push(...compactMediaTimeline(telemetry.mediaTimeline));
|
|
641
|
+
compacted.push(...compactDiagnoses(telemetry.diagnosis));
|
|
642
|
+
const presentations = compactVideoFrames(telemetry.videoFrames);
|
|
643
|
+
detail.framePresentationReportedCount = presentations.logs.length;
|
|
644
|
+
detail.verifiedMetadataTimestampCount = presentations.verifiedCount;
|
|
645
|
+
compacted.push(...presentations.logs);
|
|
646
|
+
compacted.sort(compareCompactLogs);
|
|
647
|
+
detail.reportedRecordCount = compacted.length;
|
|
648
|
+
return { logs: compacted, detail };
|
|
649
|
+
}
|
|
650
|
+
function compactMediaTimeline(value) {
|
|
651
|
+
const buckets = new Map();
|
|
652
|
+
for (const item of value) {
|
|
653
|
+
const record = toRecord(item);
|
|
654
|
+
const participantId = stringOr(record.participantId, "");
|
|
655
|
+
const videoTrackId = stringOr(record.videoTrackId, "");
|
|
656
|
+
const wallClock = numberOr(record.wallClock, 0);
|
|
657
|
+
buckets.set(`${participantId}|${videoTrackId}|${Math.floor(wallClock / TIME_SYNC_BUCKET_MS)}`, record);
|
|
658
|
+
}
|
|
659
|
+
return [...buckets.values()].map((record) => ({
|
|
660
|
+
q: numberOr(record.seq, 0),
|
|
661
|
+
t: numberOr(record.wallClock, 0),
|
|
662
|
+
o: numberOr(record.perfNow, 0),
|
|
663
|
+
y: "timeline",
|
|
664
|
+
e: "relative-drift",
|
|
665
|
+
c: removeUndefined({
|
|
666
|
+
participantId: record.participantId,
|
|
667
|
+
audioTrackId: record.audioTrackId,
|
|
668
|
+
videoTrackId: record.videoTrackId,
|
|
669
|
+
}),
|
|
670
|
+
d: pick(record, [
|
|
671
|
+
"normalizationStatus",
|
|
672
|
+
"normalizationGeneration",
|
|
673
|
+
"normalizationResetReason",
|
|
674
|
+
"pairingCoverage",
|
|
675
|
+
"validPairCount",
|
|
676
|
+
"relativeWindowSpanMs",
|
|
677
|
+
"relativeDriftMs",
|
|
678
|
+
"relativeDriftAvgMs",
|
|
679
|
+
"relativeDriftJitterMs",
|
|
680
|
+
"relativeDriftSlopeMsPerMinute",
|
|
681
|
+
"videoFrameId",
|
|
682
|
+
]),
|
|
683
|
+
}));
|
|
684
|
+
}
|
|
685
|
+
function compactDiagnoses(value) {
|
|
686
|
+
return value.map((item) => {
|
|
687
|
+
const record = toRecord(item);
|
|
688
|
+
return {
|
|
689
|
+
q: numberOr(record.seq, 0),
|
|
690
|
+
t: numberOr(record.wallClock, 0),
|
|
691
|
+
o: numberOr(record.perfNow, 0),
|
|
692
|
+
y: "diagnosis",
|
|
693
|
+
e: stringOr(record.status, "unknown"),
|
|
694
|
+
d: pick(record, [
|
|
695
|
+
"suspectedNode",
|
|
696
|
+
"responsibility",
|
|
697
|
+
"confidence",
|
|
698
|
+
"receiverIncident",
|
|
699
|
+
"normalizationStatus",
|
|
700
|
+
"normalizationGeneration",
|
|
701
|
+
"normalizationResetReason",
|
|
702
|
+
"pairingCoverage",
|
|
703
|
+
"relativeDriftMs",
|
|
704
|
+
"relativeDriftAvgMs",
|
|
705
|
+
"relativeDriftJitterMs",
|
|
706
|
+
"relativeDriftSlopeMsPerMinute",
|
|
707
|
+
"videoCaptureToDisplayRelativeMs",
|
|
708
|
+
]),
|
|
709
|
+
};
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
function compactSourceLog(log) {
|
|
713
|
+
if (log.eventName === "remote-media-capture-completed") {
|
|
714
|
+
const data = toRecord(log.data);
|
|
715
|
+
return compactLog(log, "capture", "completed", {
|
|
716
|
+
id: data.captureId,
|
|
717
|
+
status: data.captureStatus,
|
|
718
|
+
mode: data.captureMode,
|
|
719
|
+
durationMs: data.captureDurationMs,
|
|
720
|
+
pairCount: data.pairCount,
|
|
721
|
+
unpairedChannelCount: data.unpairedChannelCount,
|
|
722
|
+
channelGroupCount: data.channelGroupCount,
|
|
723
|
+
playback: compactPlayback(data.playback),
|
|
724
|
+
timeSync: compactTimeSyncSummary(data.timeSync),
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
if (log.eventName === "receiver-stats-sampled") {
|
|
728
|
+
const data = toRecord(log.data);
|
|
729
|
+
return compactLog(log, "receiver", "sampled", compactReceiverData(data));
|
|
730
|
+
}
|
|
731
|
+
if (log.eventName === "video-pipeline-stalled") {
|
|
732
|
+
return compactLog(log, "incident", "video-pipeline-stalled", toRecord(log.data));
|
|
733
|
+
}
|
|
734
|
+
if (log.logType === "connection") {
|
|
735
|
+
return compactLog(log, "connection", log.eventName, toRecord(log.data));
|
|
736
|
+
}
|
|
737
|
+
if (log.logType === "lifecycle" && isCausalLifecycleEvent(log.eventName)) {
|
|
738
|
+
return compactLog(log, "lifecycle", log.eventName, compactLifecycleDetails(toRecord(log.data)));
|
|
739
|
+
}
|
|
740
|
+
return null;
|
|
741
|
+
}
|
|
742
|
+
function compactTimeSyncLog(log) {
|
|
743
|
+
const data = toRecord(log.data);
|
|
744
|
+
return compactLog(log, "time-sync", "updated", {
|
|
745
|
+
receiverTimestampMs: data.receiverTimestampMs,
|
|
746
|
+
frameId: data.frameId,
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
function compactLog(log, type, event, data) {
|
|
750
|
+
return {
|
|
751
|
+
q: log.sequence,
|
|
752
|
+
t: log.wallClockMs,
|
|
753
|
+
o: log.observedAtMs,
|
|
754
|
+
y: type,
|
|
755
|
+
e: event,
|
|
756
|
+
...(Object.keys(compactCorrelation(toRecord(log.correlation))).length === 0
|
|
757
|
+
? {}
|
|
758
|
+
: { c: compactCorrelation(toRecord(log.correlation)) }),
|
|
759
|
+
...(data === undefined || Object.keys(data).length === 0
|
|
760
|
+
? {}
|
|
761
|
+
: { d: data }),
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function compactCorrelation(correlation) {
|
|
765
|
+
return pick(correlation, [
|
|
766
|
+
"participantId",
|
|
767
|
+
"trackId",
|
|
768
|
+
"mediaKind",
|
|
769
|
+
"pairId",
|
|
770
|
+
"streamId",
|
|
771
|
+
"playbackTargetId",
|
|
772
|
+
"captureId",
|
|
773
|
+
]);
|
|
774
|
+
}
|
|
775
|
+
function compactReceiverData(data) {
|
|
776
|
+
return removeUndefined({
|
|
777
|
+
source: data.statsSource,
|
|
778
|
+
error: data.statsError,
|
|
779
|
+
delta: compactReceiverDelta(toRecord(data.delta)),
|
|
780
|
+
transport: compactTransport(toRecord(data.transport)),
|
|
781
|
+
computed: compactReceiverComputed(toRecord(data.computed)),
|
|
782
|
+
frameMetadata: compactFrameMetadata(toRecord(data.frameMetadata)),
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
function compactReceiverDelta(data) {
|
|
786
|
+
return pick(data, [
|
|
787
|
+
"intervalMs",
|
|
788
|
+
"packetsReceived",
|
|
789
|
+
"packetsLost",
|
|
790
|
+
"concealedSamples",
|
|
791
|
+
"concealmentEvents",
|
|
792
|
+
"framesReceived",
|
|
793
|
+
"framesDecoded",
|
|
794
|
+
"framesDropped",
|
|
795
|
+
"nackCount",
|
|
796
|
+
"pliCount",
|
|
797
|
+
"firCount",
|
|
798
|
+
"freezeCount",
|
|
799
|
+
"framesDecodedPerSecond",
|
|
800
|
+
]);
|
|
801
|
+
}
|
|
802
|
+
function compactReceiverComputed(data) {
|
|
803
|
+
return pick(data, [
|
|
804
|
+
"packetLossRate",
|
|
805
|
+
"jitterMs",
|
|
806
|
+
"audioConcealedSamplesPerSecond",
|
|
807
|
+
"audioConcealmentEventsPerSecond",
|
|
808
|
+
"videoDecodedFramesPerSecond",
|
|
809
|
+
"videoDroppedFramesPerSecond",
|
|
810
|
+
"videoDecodeRatio",
|
|
811
|
+
]);
|
|
812
|
+
}
|
|
813
|
+
function compactTransport(transport) {
|
|
814
|
+
return pick(transport, [
|
|
815
|
+
"iceState",
|
|
816
|
+
"candidatePairState",
|
|
817
|
+
"candidatePairWritable",
|
|
818
|
+
"currentRoundTripTimeSeconds",
|
|
819
|
+
]);
|
|
820
|
+
}
|
|
821
|
+
function compactPlayback(value) {
|
|
822
|
+
return compactLifecycleDetails(toRecord(value));
|
|
823
|
+
}
|
|
824
|
+
function compactTimeSyncSummary(value) {
|
|
825
|
+
const summary = toRecord(value);
|
|
826
|
+
const latest = Array.isArray(summary.latest)
|
|
827
|
+
? summary.latest.map((entry) => pick(toRecord(entry), [
|
|
828
|
+
"trackId",
|
|
829
|
+
"participantId",
|
|
830
|
+
"kind",
|
|
831
|
+
"observedAtMs",
|
|
832
|
+
"receiverTimestampMs",
|
|
833
|
+
"frameId",
|
|
834
|
+
]))
|
|
835
|
+
: [];
|
|
836
|
+
return removeUndefined({ status: summary.status, latest });
|
|
837
|
+
}
|
|
838
|
+
function isCausalLifecycleEvent(eventName) {
|
|
839
|
+
return [
|
|
840
|
+
"track-subscribed",
|
|
841
|
+
"track-validated",
|
|
842
|
+
"pair-bind-started",
|
|
843
|
+
"pair-bind-completed",
|
|
844
|
+
"pair-bind-failed",
|
|
845
|
+
"track-replaced",
|
|
846
|
+
"playback-snapshot",
|
|
847
|
+
"element-waiting",
|
|
848
|
+
"element-stalled",
|
|
849
|
+
"element-recovered",
|
|
850
|
+
"native-playing",
|
|
851
|
+
"video-first-frame-presented",
|
|
852
|
+
"element-error",
|
|
853
|
+
].includes(eventName);
|
|
854
|
+
}
|
|
855
|
+
function compactLifecycleDetails(details) {
|
|
856
|
+
return pick(details, [
|
|
857
|
+
"requiredMediaKinds",
|
|
858
|
+
"attachedMediaKind",
|
|
859
|
+
"attachedKinds",
|
|
860
|
+
"bindingGeneration",
|
|
861
|
+
"targetId",
|
|
862
|
+
"elementTag",
|
|
863
|
+
"elementRole",
|
|
864
|
+
"elementBindingId",
|
|
865
|
+
"elementBound",
|
|
866
|
+
"srcObjectType",
|
|
867
|
+
"streamBindingState",
|
|
868
|
+
"streamId",
|
|
869
|
+
"streamTrackCount",
|
|
870
|
+
"streamTrackKinds",
|
|
871
|
+
"activeAudioTrackId",
|
|
872
|
+
"activeAudioParticipantId",
|
|
873
|
+
"activeVideoTrackId",
|
|
874
|
+
"activeVideoParticipantId",
|
|
875
|
+
"readyState",
|
|
876
|
+
"networkState",
|
|
877
|
+
"paused",
|
|
878
|
+
"currentTime",
|
|
879
|
+
"playbackRate",
|
|
880
|
+
"width",
|
|
881
|
+
"height",
|
|
882
|
+
"videoWidth",
|
|
883
|
+
"videoHeight",
|
|
884
|
+
"eventSemantic",
|
|
885
|
+
"pairReady",
|
|
886
|
+
"pendingPairCommit",
|
|
887
|
+
"source",
|
|
888
|
+
"presentationObservedAtMs",
|
|
889
|
+
"presentedFrames",
|
|
890
|
+
"videoCurrentTime",
|
|
891
|
+
"videoReadyState",
|
|
892
|
+
"videoPaused",
|
|
893
|
+
"videoPlaybackRate",
|
|
894
|
+
"errorCode",
|
|
895
|
+
"errorMessage",
|
|
896
|
+
]);
|
|
897
|
+
}
|
|
898
|
+
function compactFrameMetadata(metadata) {
|
|
899
|
+
if (Object.keys(metadata).length === 0)
|
|
900
|
+
return null;
|
|
901
|
+
const lookup = toRecord(metadata.captureLookup);
|
|
902
|
+
const item = toRecord(lookup.metadata);
|
|
903
|
+
const verifiedTimestamp = verifiedCaptureTimestamp(lookup, item);
|
|
904
|
+
return removeUndefined({
|
|
905
|
+
analysisEnabled: metadata.analysisEnabled,
|
|
906
|
+
workerConfigured: metadata.workerConfigured,
|
|
907
|
+
featureStatus: metadata.featureStatus,
|
|
908
|
+
lookupStatus: lookup.status,
|
|
909
|
+
associationAgeMs: lookup.associationAgeMs,
|
|
910
|
+
frameId: item.frameId,
|
|
911
|
+
userTimestamp: item.userTimestamp,
|
|
912
|
+
userDataByteLength: item.userDataByteLength,
|
|
913
|
+
userDataIsTruncated: item.userDataIsTruncated,
|
|
914
|
+
timestampEncoding: verifiedTimestamp === null ? undefined : "ascii-decimal-unix-us",
|
|
915
|
+
timestampVerified: verifiedTimestamp !== null,
|
|
916
|
+
videoCaptureTimestampUs: verifiedTimestamp,
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
function verifiedCaptureTimestamp(lookup, metadata) {
|
|
920
|
+
if (lookup.status !== "available" ||
|
|
921
|
+
metadata.userDataIsTruncated === true ||
|
|
922
|
+
typeof lookup.rtpTimestamp !== "number" ||
|
|
923
|
+
typeof metadata.frameId !== "number" ||
|
|
924
|
+
typeof lookup.associationAgeMs !== "number" ||
|
|
925
|
+
lookup.associationAgeMs > FRAME_METADATA_MAX_ASSOCIATION_AGE_MS) {
|
|
926
|
+
return null;
|
|
927
|
+
}
|
|
928
|
+
return decodeAsciiDecimalBase64(typeof metadata.userDataBase64 === "string"
|
|
929
|
+
? metadata.userDataBase64
|
|
930
|
+
: null);
|
|
931
|
+
}
|
|
932
|
+
function compactVideoFrames(videoFrames) {
|
|
933
|
+
const buckets = new Map();
|
|
934
|
+
for (const frame of videoFrames) {
|
|
935
|
+
if (frame.videoCaptureTimestampUs === null &&
|
|
936
|
+
frame.videoCaptureToDisplayRelativeMs === null) {
|
|
937
|
+
continue;
|
|
938
|
+
}
|
|
939
|
+
buckets.set(`${frame.trackId}|${Math.floor(frame.wallClock / TIME_SYNC_BUCKET_MS)}`, frame);
|
|
940
|
+
}
|
|
941
|
+
let verifiedCount = 0;
|
|
942
|
+
const logs = [...buckets.values()].map((frame) => {
|
|
943
|
+
if (frame.videoCaptureTimestampUs !== null)
|
|
944
|
+
verifiedCount += 1;
|
|
945
|
+
return {
|
|
946
|
+
q: frame.seq,
|
|
947
|
+
t: frame.wallClock,
|
|
948
|
+
o: frame.perfNow,
|
|
949
|
+
y: "frame-presentation",
|
|
950
|
+
e: "presented",
|
|
951
|
+
c: { trackId: frame.trackId, mediaKind: "video" },
|
|
952
|
+
d: removeUndefined({
|
|
953
|
+
presentedFrames: frame.presentedFrames,
|
|
954
|
+
associationAgeMs: frame.metadataAssociationAgeMs,
|
|
955
|
+
timestampEncoding: frame.videoCaptureTimestampUs === null
|
|
956
|
+
? undefined
|
|
957
|
+
: "ascii-decimal-unix-us",
|
|
958
|
+
timestampVerified: frame.videoCaptureTimestampUs !== null,
|
|
959
|
+
videoCaptureTimestampUs: frame.videoCaptureTimestampUs,
|
|
960
|
+
videoCaptureToDisplayRelativeMs: frame.videoCaptureToDisplayRelativeMs,
|
|
961
|
+
}),
|
|
962
|
+
};
|
|
963
|
+
});
|
|
964
|
+
return { logs, verifiedCount };
|
|
965
|
+
}
|
|
966
|
+
function chunkCompactLogs(logs, detail) {
|
|
967
|
+
const chunks = [];
|
|
968
|
+
let current = [];
|
|
969
|
+
for (const log of logs) {
|
|
970
|
+
if (utf8JsonByteLength([log]) > EVIDENCE_CONTENT_BYTE_LIMIT) {
|
|
971
|
+
detail.oversizeFallbackRecordCount += 1;
|
|
972
|
+
const fallback = {
|
|
973
|
+
q: log.q,
|
|
974
|
+
t: log.t,
|
|
975
|
+
o: log.o,
|
|
976
|
+
y: log.y,
|
|
977
|
+
e: log.e,
|
|
978
|
+
...(log.c === undefined ? {} : { c: log.c }),
|
|
979
|
+
d: {
|
|
980
|
+
projection: "oversize-fallback",
|
|
981
|
+
projectedByteLength: utf8JsonByteLength(log),
|
|
982
|
+
},
|
|
983
|
+
};
|
|
984
|
+
current = appendCompactLog(chunks, current, fallback);
|
|
985
|
+
continue;
|
|
986
|
+
}
|
|
987
|
+
current = appendCompactLog(chunks, current, log);
|
|
988
|
+
}
|
|
989
|
+
if (current.length > 0)
|
|
990
|
+
chunks.push(current);
|
|
991
|
+
const manifest = chunks.map((chunk, index) => ({
|
|
992
|
+
index,
|
|
993
|
+
byteLength: utf8JsonByteLength(chunk),
|
|
994
|
+
recordCount: chunk.length,
|
|
995
|
+
firstSequence: chunk[0]?.q ?? null,
|
|
996
|
+
lastSequence: chunk[chunk.length - 1]?.q ?? null,
|
|
997
|
+
}));
|
|
998
|
+
const finalDetail = {
|
|
999
|
+
...detail,
|
|
1000
|
+
reportedRecordCount: chunks.reduce((count, chunk) => count + chunk.length, 0),
|
|
1001
|
+
chunks: manifest,
|
|
1002
|
+
};
|
|
1003
|
+
const result = {
|
|
1004
|
+
logChunkCount: chunks.length,
|
|
1005
|
+
logRecordCount: chunks.reduce((count, chunk) => count + chunk.length, 0),
|
|
1006
|
+
detail: finalDetail,
|
|
1007
|
+
};
|
|
1008
|
+
if (chunks[0] !== undefined)
|
|
1009
|
+
result.logs = chunks[0];
|
|
1010
|
+
for (let index = 1; index < chunks.length; index += 1) {
|
|
1011
|
+
const chunk = chunks[index];
|
|
1012
|
+
if (chunk !== undefined)
|
|
1013
|
+
result[`logs_${index}`] = chunk;
|
|
1014
|
+
}
|
|
1015
|
+
return result;
|
|
1016
|
+
}
|
|
1017
|
+
function appendCompactLog(chunks, current, log) {
|
|
1018
|
+
const candidate = [...current, log];
|
|
1019
|
+
if (current.length > 0 &&
|
|
1020
|
+
utf8JsonByteLength(candidate) > EVIDENCE_CONTENT_BYTE_LIMIT) {
|
|
1021
|
+
chunks.push(current);
|
|
1022
|
+
return [log];
|
|
1023
|
+
}
|
|
1024
|
+
return candidate;
|
|
1025
|
+
}
|
|
1026
|
+
function createEvidenceId() {
|
|
1027
|
+
return `avse_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1028
|
+
}
|
|
1029
|
+
function collectPreparedCompactLogs(evidence) {
|
|
1030
|
+
const logs = [];
|
|
1031
|
+
for (const chunk of evidence.detail.chunks ?? []) {
|
|
1032
|
+
const value = chunk.index === 0
|
|
1033
|
+
? evidence.logs
|
|
1034
|
+
: evidence[`logs_${chunk.index}`];
|
|
1035
|
+
if (value !== undefined)
|
|
1036
|
+
logs.push(...value);
|
|
1037
|
+
}
|
|
1038
|
+
return logs;
|
|
1039
|
+
}
|
|
1040
|
+
function createLogChunkPayloads(evidenceId, alertId, sessionId, logs) {
|
|
1041
|
+
const safeLogs = logs.map((log) => fitsInLogChunk(log, evidenceId, alertId, sessionId, logs.length)
|
|
1042
|
+
? log
|
|
1043
|
+
: fallbackCompactLog(log));
|
|
1044
|
+
const chunks = [];
|
|
1045
|
+
let current = [];
|
|
1046
|
+
const maximumTotal = Math.max(1, safeLogs.length);
|
|
1047
|
+
for (const log of safeLogs) {
|
|
1048
|
+
const candidate = [...current, log];
|
|
1049
|
+
if (current.length > 0 &&
|
|
1050
|
+
!logChunkFits(candidate, evidenceId, alertId, sessionId, safeLogs.length, maximumTotal)) {
|
|
1051
|
+
chunks.push(current);
|
|
1052
|
+
current = [log];
|
|
1053
|
+
}
|
|
1054
|
+
else {
|
|
1055
|
+
current = candidate;
|
|
1056
|
+
}
|
|
1057
|
+
if (!logChunkFits(current, evidenceId, alertId, sessionId, safeLogs.length, maximumTotal)) {
|
|
1058
|
+
throw new Error("A/V Sync log fallback exceeds the platform content limit");
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
if (current.length > 0)
|
|
1062
|
+
chunks.push(current);
|
|
1063
|
+
return chunks.map((chunk, index) => createLogChunkPayload(evidenceId, alertId, sessionId, chunk, index, chunks.length));
|
|
1064
|
+
}
|
|
1065
|
+
function fitsInLogChunk(log, evidenceId, alertId, sessionId, total) {
|
|
1066
|
+
return logChunkFits([log], evidenceId, alertId, sessionId, total, total);
|
|
1067
|
+
}
|
|
1068
|
+
function logChunkFits(logs, evidenceId, alertId, sessionId, index, total) {
|
|
1069
|
+
return (utf8JsonByteLength(createLogChunkPayload(evidenceId, alertId, sessionId, logs, index, total)) <= EVIDENCE_CONTENT_BYTE_LIMIT);
|
|
1070
|
+
}
|
|
1071
|
+
function fallbackCompactLog(log) {
|
|
1072
|
+
return {
|
|
1073
|
+
q: log.q,
|
|
1074
|
+
t: log.t,
|
|
1075
|
+
o: log.o,
|
|
1076
|
+
y: log.y,
|
|
1077
|
+
e: log.e,
|
|
1078
|
+
d: {
|
|
1079
|
+
projection: "oversize-fallback",
|
|
1080
|
+
projectedByteLength: utf8JsonByteLength(log),
|
|
1081
|
+
},
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
function createLogChunkPayload(evidenceId, alertId, sessionId, logs, index, total) {
|
|
1085
|
+
return {
|
|
1086
|
+
schemaVersion: 1,
|
|
1087
|
+
kind: "liveavatar.avsync.alert-evidence",
|
|
1088
|
+
sdkVersion: liveavatarJsSdk.VERSION,
|
|
1089
|
+
recordType: "log-chunk",
|
|
1090
|
+
evidenceId,
|
|
1091
|
+
alertId,
|
|
1092
|
+
sessionId,
|
|
1093
|
+
chunk: {
|
|
1094
|
+
index,
|
|
1095
|
+
total,
|
|
1096
|
+
byteLength: utf8JsonByteLength(logs),
|
|
1097
|
+
recordCount: logs.length,
|
|
1098
|
+
firstSequence: logs[0]?.q ?? null,
|
|
1099
|
+
lastSequence: logs[logs.length - 1]?.q ?? null,
|
|
1100
|
+
logs,
|
|
1101
|
+
},
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
function createSummaryPayload(evidenceId, alert, evidence, logChunkCount) {
|
|
1105
|
+
const summaryEvidence = withoutPreparedLogs(evidence, logChunkCount);
|
|
1106
|
+
const payload = {
|
|
1107
|
+
schemaVersion: 1,
|
|
1108
|
+
kind: "liveavatar.avsync.alert-evidence",
|
|
1109
|
+
sdkVersion: liveavatarJsSdk.VERSION,
|
|
1110
|
+
recordType: "summary",
|
|
1111
|
+
evidenceId,
|
|
1112
|
+
alert,
|
|
1113
|
+
evidence: summaryEvidence,
|
|
1114
|
+
};
|
|
1115
|
+
if (utf8JsonByteLength(payload) <= EVIDENCE_CONTENT_BYTE_LIMIT)
|
|
1116
|
+
return payload;
|
|
1117
|
+
const compactPayload = {
|
|
1118
|
+
...payload,
|
|
1119
|
+
summaryTruncated: true,
|
|
1120
|
+
alert: compactAlertForSummary(alert),
|
|
1121
|
+
evidence: {
|
|
1122
|
+
...summaryEvidence,
|
|
1123
|
+
retention: null,
|
|
1124
|
+
triage: {
|
|
1125
|
+
trigger: summaryEvidence.triage?.trigger ?? {
|
|
1126
|
+
finding: alert.finding,
|
|
1127
|
+
status: alert.status,
|
|
1128
|
+
confidence: alert.confidence,
|
|
1129
|
+
capturedAtMs: alert.capturedAtMs,
|
|
1130
|
+
},
|
|
1131
|
+
evaluation: null,
|
|
1132
|
+
layers: null,
|
|
1133
|
+
participants: [],
|
|
1134
|
+
limitations: ["summary-truncated"],
|
|
1135
|
+
},
|
|
1136
|
+
detail: {
|
|
1137
|
+
projectionVersion: summaryEvidence.detail.projectionVersion,
|
|
1138
|
+
sourceRecordCount: summaryEvidence.detail.sourceRecordCount,
|
|
1139
|
+
reportedRecordCount: summaryEvidence.logRecordCount,
|
|
1140
|
+
timeSyncInputCount: 0,
|
|
1141
|
+
timeSyncReportedCount: 0,
|
|
1142
|
+
framePresentationReportedCount: 0,
|
|
1143
|
+
verifiedMetadataTimestampCount: 0,
|
|
1144
|
+
omittedSetupLifecycleCount: 0,
|
|
1145
|
+
oversizeFallbackRecordCount: summaryEvidence.detail.oversizeFallbackRecordCount,
|
|
1146
|
+
contentByteLimit: EVIDENCE_CONTENT_BYTE_LIMIT,
|
|
1147
|
+
},
|
|
1148
|
+
},
|
|
1149
|
+
};
|
|
1150
|
+
if (utf8JsonByteLength(compactPayload) <= EVIDENCE_CONTENT_BYTE_LIMIT)
|
|
1151
|
+
return compactPayload;
|
|
1152
|
+
throw new Error("A/V Sync summary exceeds the platform content limit");
|
|
1153
|
+
}
|
|
1154
|
+
function compactAlertForSummary(alert) {
|
|
1155
|
+
return {
|
|
1156
|
+
...alert,
|
|
1157
|
+
participantIds: alert.participantIds.slice(0, 32),
|
|
1158
|
+
message: truncateUtf8String(alert.message, 1024),
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
function truncateUtf8String(value, byteLimit) {
|
|
1162
|
+
if (new TextEncoder().encode(value).byteLength <= byteLimit)
|
|
1163
|
+
return value;
|
|
1164
|
+
let end = value.length;
|
|
1165
|
+
while (end > 0) {
|
|
1166
|
+
const candidate = `${value.slice(0, end)}…`;
|
|
1167
|
+
if (new TextEncoder().encode(candidate).byteLength <= byteLimit)
|
|
1168
|
+
return candidate;
|
|
1169
|
+
end -= 1;
|
|
1170
|
+
}
|
|
1171
|
+
return "";
|
|
1172
|
+
}
|
|
1173
|
+
function withoutPreparedLogs(evidence, logChunkCount) {
|
|
1174
|
+
const { logs: _logs, detail, ...rest } = evidence;
|
|
1175
|
+
const { chunks: _chunks, ...summaryDetail } = detail;
|
|
1176
|
+
const summary = Object.fromEntries(Object.entries(rest).filter(([key]) => !/^logs_\d+$/.test(key)));
|
|
1177
|
+
return {
|
|
1178
|
+
...summary,
|
|
1179
|
+
logChunkCount,
|
|
1180
|
+
detail: summaryDetail,
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
function decodeAsciiDecimalBase64(value) {
|
|
1184
|
+
if (value === null)
|
|
1185
|
+
return null;
|
|
1186
|
+
try {
|
|
1187
|
+
const decoded = atob(value);
|
|
1188
|
+
if (!/^\d{16}$/.test(decoded))
|
|
1189
|
+
return null;
|
|
1190
|
+
const parsed = Number(decoded);
|
|
1191
|
+
return Number.isSafeInteger(parsed) ? decoded : null;
|
|
1192
|
+
}
|
|
1193
|
+
catch {
|
|
1194
|
+
return null;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
function utf8JsonByteLength(value) {
|
|
1198
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
1199
|
+
}
|
|
1200
|
+
function toRecord(value) {
|
|
1201
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
1202
|
+
? value
|
|
1203
|
+
: {};
|
|
1204
|
+
}
|
|
1205
|
+
function pick(source, keys) {
|
|
1206
|
+
const result = {};
|
|
1207
|
+
for (const key of keys) {
|
|
1208
|
+
if (source[key] !== undefined && source[key] !== null)
|
|
1209
|
+
result[key] = source[key];
|
|
1210
|
+
}
|
|
1211
|
+
return result;
|
|
1212
|
+
}
|
|
1213
|
+
function removeUndefined(value) {
|
|
1214
|
+
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined));
|
|
1215
|
+
}
|
|
1216
|
+
function numberOr(value, fallback) {
|
|
1217
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
1218
|
+
}
|
|
1219
|
+
function stringOr(value, fallback) {
|
|
1220
|
+
return typeof value === "string" ? value : fallback;
|
|
1221
|
+
}
|
|
1222
|
+
function compareSourceLogs(left, right) {
|
|
1223
|
+
return left.sequence - right.sequence;
|
|
1224
|
+
}
|
|
1225
|
+
function compareCompactLogs(left, right) {
|
|
1226
|
+
return left.q - right.q || left.o - right.o;
|
|
1227
|
+
}
|
|
1228
|
+
function toJsonSafeAlert(alert) {
|
|
1229
|
+
return {
|
|
1230
|
+
...alert,
|
|
1231
|
+
sessionId: alert.sessionId ?? null,
|
|
1232
|
+
participantIds: [...alert.participantIds],
|
|
1233
|
+
features: { ...alert.features },
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
function stringifyJson(value) {
|
|
1237
|
+
const serialized = JSON.stringify(value);
|
|
1238
|
+
if (serialized === undefined) {
|
|
1239
|
+
throw new Error("LiveAvatar SkyWalking payload serialization failed");
|
|
1240
|
+
}
|
|
1241
|
+
return serialized;
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* Loads the bundled browser client when needed and registers it exactly once.
|
|
1245
|
+
* An application-provided `window.ClientMonitor` is treated as already
|
|
1246
|
+
* registered and is never overwritten or registered again.
|
|
1247
|
+
*/
|
|
1248
|
+
function registerSkyWalking(config = {}) {
|
|
1249
|
+
if (typeof window === "undefined") {
|
|
1250
|
+
warnOnce("register-unavailable", "[LiveAvatar SkyWalking plugin] SkyWalking registration requires a browser window");
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
const normalized = normalizeSkyWalkingConfig(config);
|
|
1254
|
+
const state = getRegistrationState();
|
|
1255
|
+
if (state !== undefined) {
|
|
1256
|
+
if (state.source === "embedded" &&
|
|
1257
|
+
state.config !== undefined &&
|
|
1258
|
+
!sameConfig(state.config, normalized)) {
|
|
1259
|
+
console.warn("[LiveAvatar SkyWalking plugin] SkyWalking is already registered; retaining the first configuration", { firstConfig: state.config, ignoredConfig: normalized });
|
|
1260
|
+
}
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
if (getGlobalClientMonitor() !== undefined) {
|
|
1264
|
+
setRegistrationState({ source: "external" });
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
try {
|
|
1268
|
+
installEmbeddedSkyWalkingClient();
|
|
1269
|
+
const clientMonitor = getGlobalClientMonitor();
|
|
1270
|
+
if (clientMonitor === undefined ||
|
|
1271
|
+
typeof clientMonitor.register !== "function") {
|
|
1272
|
+
console.warn("[LiveAvatar SkyWalking plugin] The embedded SkyWalking client did not expose ClientMonitor.register");
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
clientMonitor.register(normalized);
|
|
1276
|
+
setRegistrationState({ source: "embedded", config: normalized });
|
|
1277
|
+
}
|
|
1278
|
+
catch (error) {
|
|
1279
|
+
console.warn("[LiveAvatar SkyWalking plugin] Failed to load or register the embedded SkyWalking client", { error });
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
/** Triggers a SkyWalking performance report through an already registered client. */
|
|
1283
|
+
function setSkyWalkingPerformance(config = {}, customMetrics) {
|
|
1284
|
+
const clientMonitor = getClientMonitor();
|
|
1285
|
+
if (clientMonitor === undefined ||
|
|
1286
|
+
typeof clientMonitor.setPerformance !== "function") {
|
|
1287
|
+
warnOnce("set-performance-unavailable", "[LiveAvatar SkyWalking plugin] ClientMonitor.setPerformance is unavailable; register SkyWalking first");
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
clientMonitor.setPerformance(normalizeSkyWalkingConfig(config), customMetrics);
|
|
1291
|
+
}
|
|
1292
|
+
/** Triggers a SkyWalking HRT report through an already registered client. */
|
|
1293
|
+
function setSkyWalkingHRT(config = {}, customMetrics) {
|
|
1294
|
+
const clientMonitor = getClientMonitor();
|
|
1295
|
+
if (clientMonitor === undefined ||
|
|
1296
|
+
typeof clientMonitor.setHRT !== "function") {
|
|
1297
|
+
warnOnce("set-hrt-unavailable", "[LiveAvatar SkyWalking plugin] ClientMonitor.setHRT is unavailable; register SkyWalking first");
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
clientMonitor.setHRT(normalizeSkyWalkingConfig(config), customMetrics);
|
|
1301
|
+
}
|
|
1302
|
+
/** Reports a frame error through an already registered SkyWalking client. */
|
|
1303
|
+
async function reportSkyWalkingFrameErrors(config, error) {
|
|
1304
|
+
const clientMonitor = getClientMonitor();
|
|
1305
|
+
if (clientMonitor === undefined) {
|
|
1306
|
+
warnOnce("report-frame-errors-unavailable", "[LiveAvatar SkyWalking plugin] ClientMonitor.reportFrameErrors is unavailable; register SkyWalking first");
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
await Promise.resolve(clientMonitor.reportFrameErrors(config, error));
|
|
1310
|
+
}
|
|
1311
|
+
function normalizeSkyWalkingConfig(config) {
|
|
1312
|
+
return {
|
|
1313
|
+
collector: config.collector ??
|
|
1314
|
+
(config.isOverseas ? OVERSEAS_COLLECTOR : DOMESTIC_COLLECTOR),
|
|
1315
|
+
service: SKYWALKING_SERVICE,
|
|
1316
|
+
jsErrors: config.jsErrors ?? false,
|
|
1317
|
+
apiErrors: config.apiErrors ?? false,
|
|
1318
|
+
resourceErrors: config.resourceErrors ?? false,
|
|
1319
|
+
autoTracePerf: config.autoTracePerf ?? false,
|
|
1320
|
+
useFmp: config.useFmp ?? false,
|
|
1321
|
+
detailMode: config.detailMode ?? false,
|
|
1322
|
+
perfEntries: config.perfEntries ?? false,
|
|
1323
|
+
rate: config.rate ?? 0.6,
|
|
1324
|
+
enableSPA: config.enableSPA ?? false,
|
|
1325
|
+
vue: config.vue ?? false,
|
|
1326
|
+
traceSDKInternal: config.traceSDKInternal ?? false,
|
|
1327
|
+
noTrace: config.noTrace ?? false,
|
|
1328
|
+
noTraceUrls: config.noTraceUrls === undefined ? null : [...(config.noTraceUrls ?? [])],
|
|
1329
|
+
noErrorPaths: [...(config.noErrorPaths ?? [])],
|
|
1330
|
+
sendErrorTime: config.sendErrorTime ?? 60000,
|
|
1331
|
+
sendSegmentsTime: config.sendSegmentsTime ?? 300000,
|
|
1332
|
+
sendPerfTime: config.sendPerfTime ?? 6000,
|
|
1333
|
+
extraMsg: config.extraMsg,
|
|
1334
|
+
hooks: { ...config.hooks },
|
|
1335
|
+
pagePath: config.pagePath ?? "",
|
|
1336
|
+
serviceVersion: config.serviceVersion ?? "",
|
|
1337
|
+
pageKey: config.pageKey ?? "",
|
|
1338
|
+
group: config.group ?? "unknown",
|
|
1339
|
+
subGroup: config.subGroup ?? "unknown",
|
|
1340
|
+
whiteScreen: config.whiteScreen ?? false,
|
|
1341
|
+
whiteScreenTimeout: config.whiteScreenTimeout ?? 2500,
|
|
1342
|
+
maxReqCostTime: config.maxReqCostTime ?? 10000,
|
|
1343
|
+
collectRequestParams: config.collectRequestParams ?? false,
|
|
1344
|
+
maxRequestBodySize: config.maxRequestBodySize ?? 10240,
|
|
1345
|
+
slowInteraction: {
|
|
1346
|
+
enable: config.slowInteraction?.enable ?? false,
|
|
1347
|
+
threshold: config.slowInteraction?.threshold ?? 200,
|
|
1348
|
+
reportInterval: config.slowInteraction?.reportInterval ?? 30000,
|
|
1349
|
+
},
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
function getClientMonitor() {
|
|
1353
|
+
const candidate = getGlobalClientMonitor();
|
|
1354
|
+
return typeof candidate?.reportFrameErrors === "function"
|
|
1355
|
+
? candidate
|
|
1356
|
+
: undefined;
|
|
1357
|
+
}
|
|
1358
|
+
function getGlobalClientMonitor() {
|
|
1359
|
+
if (typeof window === "undefined")
|
|
1360
|
+
return undefined;
|
|
1361
|
+
const candidate = window
|
|
1362
|
+
.ClientMonitor;
|
|
1363
|
+
return candidate !== null && typeof candidate === "object"
|
|
1364
|
+
? candidate
|
|
1365
|
+
: undefined;
|
|
1366
|
+
}
|
|
1367
|
+
function getRegistrationState() {
|
|
1368
|
+
if (typeof window === "undefined")
|
|
1369
|
+
return undefined;
|
|
1370
|
+
return window[REGISTRATION_STATE_KEY];
|
|
1371
|
+
}
|
|
1372
|
+
function setRegistrationState(state) {
|
|
1373
|
+
window[REGISTRATION_STATE_KEY] = state;
|
|
1374
|
+
}
|
|
1375
|
+
function warnOnce(key, message) {
|
|
1376
|
+
if (typeof window === "undefined") {
|
|
1377
|
+
console.warn(message);
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
const warningKey = Symbol.for(`liveavatar.skywalking.warning.${key}`);
|
|
1381
|
+
const target = window;
|
|
1382
|
+
if (target[warningKey])
|
|
1383
|
+
return;
|
|
1384
|
+
target[warningKey] = true;
|
|
1385
|
+
console.warn(message);
|
|
1386
|
+
}
|
|
1387
|
+
function sameConfig(left, right) {
|
|
1388
|
+
return stableConfigValue(left) === stableConfigValue(right);
|
|
1389
|
+
}
|
|
1390
|
+
function stableConfigValue(value) {
|
|
1391
|
+
if (typeof value === "function")
|
|
1392
|
+
return `function:${String(value)}`;
|
|
1393
|
+
if (value instanceof RegExp)
|
|
1394
|
+
return `regexp:${value.source}/${value.flags}`;
|
|
1395
|
+
if (Array.isArray(value))
|
|
1396
|
+
return `[${value.map(stableConfigValue).join(",")}]`;
|
|
1397
|
+
if (value !== null && typeof value === "object") {
|
|
1398
|
+
const record = value;
|
|
1399
|
+
return `{${Object.keys(record)
|
|
1400
|
+
.sort()
|
|
1401
|
+
.map((key) => `${key}:${stableConfigValue(record[key])}`)
|
|
1402
|
+
.join(",")}}`;
|
|
1403
|
+
}
|
|
1404
|
+
return JSON.stringify(value);
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
exports.SKYWALKING_PLUGIN_ID = SKYWALKING_PLUGIN_ID;
|
|
1408
|
+
exports.createSkyWalkingPlugin = createSkyWalkingPlugin;
|
|
1409
|
+
exports.registerSkyWalking = registerSkyWalking;
|
|
1410
|
+
exports.reportSkyWalkingFrameErrors = reportSkyWalkingFrameErrors;
|
|
1411
|
+
exports.setSkyWalkingHRT = setSkyWalkingHRT;
|
|
1412
|
+
exports.setSkyWalkingPerformance = setSkyWalkingPerformance;
|
|
1413
|
+
|
|
1414
|
+
}));
|