@sanseng/liveavatar-js-sdk-skywalking 1.0.1 → 1.1.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/README.md +51 -8
- package/README.zh-CN.md +102 -0
- package/dist/index.cjs.js +798 -1198
- package/dist/index.d.ts +139 -165
- package/dist/index.esm.js +799 -1199
- package/dist/index.umd.js +798 -1198
- package/package.json +5 -5
package/dist/index.cjs.js
CHANGED
|
@@ -18,35 +18,474 @@ SkyWalking js-sdk
|
|
|
18
18
|
!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");}();
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const EMPTY = {};
|
|
22
|
+
const PHASE = { phase: "string" };
|
|
23
|
+
const CONFIG = { source: "string", willRetry: "boolean" };
|
|
24
|
+
const TEXT_LENGTH = { textLength: "number" };
|
|
25
|
+
// Public v2 event/data allowlist. Correlation and operation use their own
|
|
26
|
+
// common public contracts; a module alone never makes an event reportable.
|
|
27
|
+
const TIMELINE_FIELDS = {
|
|
28
|
+
"operation.started": EMPTY,
|
|
29
|
+
"operation.finished": EMPTY,
|
|
30
|
+
"protocol.received": { protocolEvent: "string" },
|
|
31
|
+
"protocol.failed": { protocolEvent: "string" },
|
|
32
|
+
"client.created": EMPTY,
|
|
33
|
+
"client.disposed": EMPTY,
|
|
34
|
+
"monitoring.session.started": { startReason: "string" },
|
|
35
|
+
"monitoring.session.ended": { endReason: "string", cleanupOutcome: "string" },
|
|
36
|
+
"config.fetch.started": CONFIG,
|
|
37
|
+
"config.fetch.completed": CONFIG,
|
|
38
|
+
"config.fetch.failed": CONFIG,
|
|
39
|
+
"connect.started": PHASE,
|
|
40
|
+
"connect.completed": PHASE,
|
|
41
|
+
"connect.failed": PHASE,
|
|
42
|
+
"disconnect.started": PHASE,
|
|
43
|
+
"disconnect.completed": PHASE,
|
|
44
|
+
"disconnect.failed": PHASE,
|
|
45
|
+
"reconnect.started": PHASE,
|
|
46
|
+
"reconnect.completed": PHASE,
|
|
47
|
+
"reconnect.failed": PHASE,
|
|
48
|
+
"livekit.connected": EMPTY,
|
|
49
|
+
"livekit.disconnected": { hasReason: "boolean" },
|
|
50
|
+
"http.connected": EMPTY,
|
|
51
|
+
"http.disconnected": { hasReason: "boolean" },
|
|
52
|
+
"rtc.state-changed": {
|
|
53
|
+
phase: "string",
|
|
54
|
+
roomExists: "boolean",
|
|
55
|
+
roomState: "string",
|
|
56
|
+
hasConnected: "boolean",
|
|
57
|
+
},
|
|
58
|
+
"connection.quality-changed": { quality: "string", isLocal: "boolean" },
|
|
59
|
+
"video.track-added": EMPTY,
|
|
60
|
+
"video.track-removed": EMPTY,
|
|
61
|
+
"audio.track-added": EMPTY,
|
|
62
|
+
"audio.track-removed": EMPTY,
|
|
63
|
+
"audio.capture-started": EMPTY,
|
|
64
|
+
"audio.capture-stopped": EMPTY,
|
|
65
|
+
"camera.started": EMPTY,
|
|
66
|
+
"camera.stopped": EMPTY,
|
|
67
|
+
"question.sent": TEXT_LENGTH,
|
|
68
|
+
"answer.waiting": EMPTY,
|
|
69
|
+
"answer.first-chunk": { deltaLength: "number", textLength: "number" },
|
|
70
|
+
"answer.completed": TEXT_LENGTH,
|
|
71
|
+
"asr.final": TEXT_LENGTH,
|
|
72
|
+
"server.message": { textLength: "number", type: "string" },
|
|
73
|
+
"avsync.session.started": { startedAtMs: "number" },
|
|
74
|
+
"avsync.session.ended": { endedAtMs: "number", reason: "string" },
|
|
75
|
+
};
|
|
76
|
+
function sourceCorrelation(source) {
|
|
77
|
+
return project(source, {
|
|
78
|
+
clientInstanceId: "string",
|
|
79
|
+
monitoringSessionId: "string",
|
|
80
|
+
serverSessionId: "string",
|
|
81
|
+
avsyncSessionId: "string",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function operationalSource(record) {
|
|
85
|
+
return {
|
|
86
|
+
sourceSchema: "sdk.log",
|
|
87
|
+
sourceSchemaVersion: 2,
|
|
88
|
+
...sourceCorrelation(record),
|
|
89
|
+
clientInstanceId: record.clientInstanceId,
|
|
90
|
+
eventId: record.eventId,
|
|
91
|
+
streamId: record.streamId,
|
|
92
|
+
sequence: record.sequence,
|
|
93
|
+
occurredAtMs: record.occurredAtMs,
|
|
94
|
+
...project(record, { observedAtMs: "number", clockId: "string" }),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** Copy only the public v2 envelope and documented diagnostic fields. */
|
|
98
|
+
function projectRecord(record) {
|
|
99
|
+
const correlation = project(record.correlation, {
|
|
100
|
+
questionId: "string",
|
|
101
|
+
attemptId: "number",
|
|
102
|
+
configRoundId: "number",
|
|
103
|
+
attempt: "number",
|
|
104
|
+
alertId: "string",
|
|
105
|
+
participantId: "string",
|
|
106
|
+
trackId: "string",
|
|
107
|
+
mediaKind: "string",
|
|
108
|
+
pairId: "string",
|
|
109
|
+
trackKey: "string",
|
|
110
|
+
streamId: "string",
|
|
111
|
+
playbackTargetId: "string",
|
|
112
|
+
captureId: "string",
|
|
113
|
+
relatedOperationId: "string",
|
|
114
|
+
}, true);
|
|
115
|
+
const snapshot = project(record.snapshot, {
|
|
116
|
+
sdkState: "string",
|
|
117
|
+
httpConnected: "boolean",
|
|
118
|
+
rtcConnected: "boolean",
|
|
119
|
+
hasVideoTrack: "boolean",
|
|
120
|
+
roomExists: "boolean",
|
|
121
|
+
roomState: "string",
|
|
122
|
+
hasConnected: "boolean",
|
|
123
|
+
});
|
|
124
|
+
const disconnect = project(object$1(record.snapshot).lastDisconnect, {
|
|
125
|
+
occurredAtMs: "number",
|
|
126
|
+
reasonCode: "number",
|
|
127
|
+
reasonName: "string",
|
|
128
|
+
clientInitiated: "boolean",
|
|
129
|
+
});
|
|
130
|
+
if (Object.keys(disconnect).length)
|
|
131
|
+
snapshot.lastDisconnect = disconnect;
|
|
132
|
+
const error = record.error && {
|
|
133
|
+
failureId: record.error.failureId,
|
|
134
|
+
code: record.error.code,
|
|
135
|
+
reasonCategory: record.error.reasonCategory,
|
|
136
|
+
...project(record.error, { reason: "string" }),
|
|
137
|
+
...(record.error.evidence
|
|
138
|
+
? {
|
|
139
|
+
evidence: {
|
|
140
|
+
...project(record.error.evidence, {
|
|
141
|
+
name: "string",
|
|
142
|
+
httpStatus: "number",
|
|
143
|
+
connectionErrorReason: "number",
|
|
144
|
+
connectionErrorReasonName: "string",
|
|
145
|
+
}),
|
|
146
|
+
...(["string", "number"].includes(typeof record.error.evidence.backendCode)
|
|
147
|
+
? { backendCode: record.error.evidence.backendCode }
|
|
148
|
+
: {}),
|
|
149
|
+
},
|
|
150
|
+
}
|
|
151
|
+
: {}),
|
|
152
|
+
};
|
|
153
|
+
return {
|
|
154
|
+
schema: "sdk.log",
|
|
155
|
+
schemaVersion: 2,
|
|
156
|
+
eventId: record.eventId,
|
|
157
|
+
streamId: record.streamId,
|
|
158
|
+
sequence: record.sequence,
|
|
159
|
+
occurredAtMs: record.occurredAtMs,
|
|
160
|
+
...project(record, { observedAtMs: "number", clockId: "string" }),
|
|
161
|
+
...sourceCorrelation(record),
|
|
162
|
+
clientInstanceId: record.clientInstanceId,
|
|
163
|
+
level: record.level,
|
|
164
|
+
module: record.module,
|
|
165
|
+
event: record.event,
|
|
166
|
+
trigger: { kind: record.trigger.kind, entry: record.trigger.entry },
|
|
167
|
+
...(record.operation
|
|
168
|
+
? {
|
|
169
|
+
operation: {
|
|
170
|
+
operationId: record.operation.operationId,
|
|
171
|
+
rootOperationId: record.operation.rootOperationId,
|
|
172
|
+
name: record.operation.name,
|
|
173
|
+
phase: record.operation.phase,
|
|
174
|
+
...project(record.operation, {
|
|
175
|
+
parentOperationId: "string",
|
|
176
|
+
relatedOperationId: "string",
|
|
177
|
+
}),
|
|
178
|
+
...(record.operation.outcome
|
|
179
|
+
? { outcome: record.operation.outcome }
|
|
180
|
+
: {}),
|
|
181
|
+
},
|
|
182
|
+
}
|
|
183
|
+
: {}),
|
|
184
|
+
...(record.failureRef
|
|
185
|
+
? {
|
|
186
|
+
failureRef: {
|
|
187
|
+
failureId: record.failureRef.failureId,
|
|
188
|
+
eventId: record.failureRef.eventId,
|
|
189
|
+
},
|
|
190
|
+
}
|
|
191
|
+
: {}),
|
|
192
|
+
...(error ? { error } : {}),
|
|
193
|
+
...(Object.keys(correlation).length ? { correlation } : {}),
|
|
194
|
+
...(Object.keys(snapshot).length ? { snapshot } : {}),
|
|
195
|
+
...(record.data ? { data: eventData(record) } : {}),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function eventData(record) {
|
|
199
|
+
const fields = Object.prototype.hasOwnProperty.call(TIMELINE_FIELDS, record.event)
|
|
200
|
+
? TIMELINE_FIELDS[record.event]
|
|
201
|
+
: EMPTY;
|
|
202
|
+
const data = project(record.data, fields);
|
|
203
|
+
if (record.event === "rtc.state-changed") {
|
|
204
|
+
const disconnect = project(object$1(record.data).lastDisconnect, {
|
|
205
|
+
occurredAtMs: "number",
|
|
206
|
+
reasonCode: "number",
|
|
207
|
+
reasonName: "string",
|
|
208
|
+
clientInitiated: "boolean",
|
|
209
|
+
});
|
|
210
|
+
if (Object.keys(disconnect).length)
|
|
211
|
+
data.lastDisconnect = disconnect;
|
|
212
|
+
}
|
|
213
|
+
if (record.event === "avsync.alert")
|
|
214
|
+
return project(record.data, {
|
|
215
|
+
phase: "string",
|
|
216
|
+
finding: "string",
|
|
217
|
+
confidence: "string",
|
|
218
|
+
status: "string",
|
|
219
|
+
capturedAtMs: "number",
|
|
220
|
+
});
|
|
221
|
+
if (record.event === "performance.first-frame") {
|
|
222
|
+
Object.assign(data, project(record.data, {
|
|
223
|
+
outcome: "string",
|
|
224
|
+
renderMode: "string",
|
|
225
|
+
timeoutAfterRtcMs: "number",
|
|
226
|
+
}));
|
|
227
|
+
data.nodes = project(object$1(record.data).nodes, {
|
|
228
|
+
configReadyMs: "number",
|
|
229
|
+
rtcConnectedMs: "number",
|
|
230
|
+
videoTrackAddedMs: "number",
|
|
231
|
+
videoMetadataMs: "number",
|
|
232
|
+
firstFrameMs: "number",
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return data;
|
|
236
|
+
}
|
|
237
|
+
function toTimeline(record) {
|
|
238
|
+
if (!Object.prototype.hasOwnProperty.call(TIMELINE_FIELDS, record.event))
|
|
239
|
+
return undefined;
|
|
240
|
+
const copy = projectRecord(record);
|
|
241
|
+
return {
|
|
242
|
+
kind: "liveavatar.session.timeline",
|
|
243
|
+
schemaVersion: 4,
|
|
244
|
+
...operationalSource(copy),
|
|
245
|
+
level: copy.level,
|
|
246
|
+
module: copy.module,
|
|
247
|
+
event: copy.event,
|
|
248
|
+
trigger: copy.trigger,
|
|
249
|
+
...(copy.operation ? { operation: copy.operation } : {}),
|
|
250
|
+
...(copy.failureRef ? { failureRef: copy.failureRef } : {}),
|
|
251
|
+
...(copy.snapshot ? { snapshot: copy.snapshot } : {}),
|
|
252
|
+
...(copy.correlation ? { correlation: copy.correlation } : {}),
|
|
253
|
+
...(copy.data && Object.keys(copy.data).length ? { data: copy.data } : {}),
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
function object$1(value) {
|
|
257
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
258
|
+
? value
|
|
259
|
+
: {};
|
|
260
|
+
}
|
|
261
|
+
function project(value, fields, nullable = false) {
|
|
262
|
+
const input = object$1(value);
|
|
263
|
+
const result = {};
|
|
264
|
+
for (const [key, type] of Object.entries(fields)) {
|
|
265
|
+
const entry = input[key];
|
|
266
|
+
if (entry === null && nullable)
|
|
267
|
+
result[key] = null;
|
|
268
|
+
else if (type === "string" && typeof entry === "string")
|
|
269
|
+
result[key] = entry;
|
|
270
|
+
else if (type === "boolean" && typeof entry === "boolean")
|
|
271
|
+
result[key] = entry;
|
|
272
|
+
else if (type === "number" &&
|
|
273
|
+
typeof entry === "number" &&
|
|
274
|
+
Number.isFinite(entry))
|
|
275
|
+
result[key] = entry;
|
|
276
|
+
}
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Complete content, including its envelope and JSON escapes, must fit this limit. */
|
|
281
|
+
const EVIDENCE_CONTENT_BYTE_LIMIT = 28 * 1024;
|
|
282
|
+
function utf8ByteLength(value) {
|
|
283
|
+
return new TextEncoder().encode(value).byteLength;
|
|
284
|
+
}
|
|
285
|
+
/** Content is level one; containers at level three become lossless JSON text. */
|
|
286
|
+
function serializeEvidenceContent(value, depth = 1) {
|
|
287
|
+
if (value === null || typeof value !== "object")
|
|
288
|
+
return value;
|
|
289
|
+
if (depth >= 3)
|
|
290
|
+
return JSON.stringify(value);
|
|
291
|
+
if (Array.isArray(value))
|
|
292
|
+
return value.map((entry) => serializeEvidenceContent(entry, depth + 1));
|
|
293
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
|
|
294
|
+
key,
|
|
295
|
+
serializeEvidenceContent(entry, depth + 1),
|
|
296
|
+
]));
|
|
297
|
+
}
|
|
298
|
+
function assertContentFits(content) {
|
|
299
|
+
if (utf8ByteLength(JSON.stringify(content)) > EVIDENCE_CONTENT_BYTE_LIMIT)
|
|
300
|
+
throw new Error("A/V Sync content exceeds the 28 KiB limit");
|
|
301
|
+
}
|
|
302
|
+
function pageReasons(page) {
|
|
303
|
+
const reasons = [];
|
|
304
|
+
if (!page.enabled)
|
|
305
|
+
reasons.push("diagnostics-disabled");
|
|
306
|
+
if (page.page.truncated)
|
|
307
|
+
reasons.push("source-truncated");
|
|
308
|
+
if (!page.retention.storageAvailable)
|
|
309
|
+
reasons.push("storage-unavailable");
|
|
310
|
+
if (page.retention.storageWriteFailed)
|
|
311
|
+
reasons.push("storage-write-failed");
|
|
312
|
+
if (page.retention.droppedLogCount > 0 ||
|
|
313
|
+
page.retention.droppedSegmentCount > 0)
|
|
314
|
+
reasons.push("retention-dropped");
|
|
315
|
+
if (page.page.availableFromWallClockMs === null ||
|
|
316
|
+
page.page.availableToWallClockMs === null)
|
|
317
|
+
reasons.push("window-unavailable");
|
|
318
|
+
else if (page.page.availableFromWallClockMs > page.page.requestedFromWallClockMs)
|
|
319
|
+
reasons.push("window-start-uncovered");
|
|
320
|
+
return reasons;
|
|
321
|
+
}
|
|
322
|
+
function ownsPage(alert, page) {
|
|
323
|
+
// Missing optional SDK identities are not filled from the latest session.
|
|
324
|
+
return (page.avsyncSessionId === alert.avsyncSessionId &&
|
|
325
|
+
(page.clientInstanceId === undefined ||
|
|
326
|
+
page.clientInstanceId === alert.clientInstanceId) &&
|
|
327
|
+
(page.monitoringSessionId === undefined ||
|
|
328
|
+
page.monitoringSessionId === alert.monitoringSessionId) &&
|
|
329
|
+
page.records.every((record) => record.clientInstanceId === alert.clientInstanceId &&
|
|
330
|
+
record.avsyncSessionId === alert.avsyncSessionId &&
|
|
331
|
+
(record.monitoringSessionId === undefined ||
|
|
332
|
+
record.monitoringSessionId === alert.monitoringSessionId)));
|
|
333
|
+
}
|
|
334
|
+
async function collectEvidence(diagnostics, alert, range, isActive) {
|
|
335
|
+
const pages = [];
|
|
336
|
+
const reasons = new Set();
|
|
337
|
+
const cursors = new Set();
|
|
338
|
+
let cursor;
|
|
339
|
+
let queryComplete = false;
|
|
340
|
+
const retrievedAtWallClockMs = Date.now();
|
|
341
|
+
while (isActive()) {
|
|
342
|
+
let page;
|
|
343
|
+
try {
|
|
344
|
+
const result = await diagnostics.getAvSyncLogEvidence(cursor === undefined
|
|
345
|
+
? { range, pageSize: 1000, includeSummary: true }
|
|
346
|
+
: { cursor, pageSize: 1000, includeSummary: false });
|
|
347
|
+
if (!isActive())
|
|
348
|
+
return undefined;
|
|
349
|
+
// Own the snapshot even when the transport implementation reuses objects.
|
|
350
|
+
page = JSON.parse(JSON.stringify(result));
|
|
351
|
+
}
|
|
352
|
+
catch {
|
|
353
|
+
if (!isActive())
|
|
354
|
+
return undefined;
|
|
355
|
+
reasons.add(pages.length ? "continuation-query-failed" : "initial-query-failed");
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
pages.push(page);
|
|
359
|
+
for (const reason of pageReasons(page))
|
|
360
|
+
reasons.add(reason);
|
|
361
|
+
if (!ownsPage(alert, page)) {
|
|
362
|
+
reasons.add("session-mismatch");
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
const first = pages[0];
|
|
366
|
+
if (page.page.requestedFromWallClockMs !==
|
|
367
|
+
first.page.requestedFromWallClockMs ||
|
|
368
|
+
page.page.requestedToWallClockMs !== first.page.requestedToWallClockMs) {
|
|
369
|
+
reasons.add("window-mismatch");
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
if (!page.page.hasMore) {
|
|
373
|
+
queryComplete = true;
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
const next = page.page.nextCursor;
|
|
377
|
+
if (!next || cursors.has(next)) {
|
|
378
|
+
reasons.add("cursor-did-not-advance");
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
cursors.add(next);
|
|
382
|
+
cursor = next;
|
|
383
|
+
}
|
|
384
|
+
if (!isActive())
|
|
385
|
+
return undefined;
|
|
386
|
+
if (pages.reduce((count, page) => count + page.records.length, 0) === 0)
|
|
387
|
+
reasons.add("empty-window");
|
|
388
|
+
return {
|
|
389
|
+
schema: "liveavatar.avsync.evidence",
|
|
390
|
+
schemaVersion: 4,
|
|
391
|
+
alert,
|
|
392
|
+
query: { range, retrievedAtWallClockMs, complete: queryComplete },
|
|
393
|
+
pages,
|
|
394
|
+
completeness: {
|
|
395
|
+
complete: queryComplete && reasons.size === 0,
|
|
396
|
+
reasons: [...reasons],
|
|
397
|
+
},
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
/** Lossless framing of the whole evidence document, including oversized metadata. */
|
|
401
|
+
function createEvidencePayloads(evidenceId, evidence) {
|
|
402
|
+
const source = operationalSource(evidence.alert);
|
|
403
|
+
const alertId = evidence.alert.correlation?.alertId;
|
|
404
|
+
if (!alertId)
|
|
405
|
+
throw new Error("A/V alert is missing its source alertId");
|
|
406
|
+
const document = JSON.stringify(evidence);
|
|
407
|
+
const base = {
|
|
408
|
+
...source,
|
|
409
|
+
kind: "liveavatar.avsync.alert-evidence",
|
|
410
|
+
schemaVersion: 4,
|
|
411
|
+
evidenceId,
|
|
412
|
+
alertId,
|
|
413
|
+
};
|
|
414
|
+
const chunkPayload = (data, index, total) => ({
|
|
415
|
+
...base,
|
|
416
|
+
recordType: "log-chunk",
|
|
417
|
+
chunk: { index, total, byteLength: utf8ByteLength(data), data },
|
|
418
|
+
});
|
|
419
|
+
// A fragment contains at least one UTF-16 code unit, so document.length bounds
|
|
420
|
+
// both index and total. Use that conservative envelope during packing.
|
|
421
|
+
const maximumTotal = Math.max(1, document.length);
|
|
422
|
+
const parts = [];
|
|
423
|
+
let start = 0;
|
|
424
|
+
while (start < document.length) {
|
|
425
|
+
let low = start;
|
|
426
|
+
let high = Math.min(document.length, start + EVIDENCE_CONTENT_BYTE_LIMIT);
|
|
427
|
+
while (low < high) {
|
|
428
|
+
const end = Math.ceil((low + high) / 2);
|
|
429
|
+
if (utf8ByteLength(JSON.stringify(chunkPayload(document.slice(start, end), maximumTotal, maximumTotal))) <= EVIDENCE_CONTENT_BYTE_LIMIT)
|
|
430
|
+
low = end;
|
|
431
|
+
else
|
|
432
|
+
high = end - 1;
|
|
433
|
+
}
|
|
434
|
+
// Move left if the fitted UTF-16 slice cuts a surrogate pair.
|
|
435
|
+
if (low < document.length &&
|
|
436
|
+
low > start &&
|
|
437
|
+
/[\uD800-\uDBFF]/.test(document[low - 1]) &&
|
|
438
|
+
/[\uDC00-\uDFFF]/.test(document[low]))
|
|
439
|
+
low--;
|
|
440
|
+
if (low === start)
|
|
441
|
+
throw new Error("A/V evidence envelope leaves no room for a fragment");
|
|
442
|
+
parts.push(document.slice(start, low));
|
|
443
|
+
start = low;
|
|
444
|
+
}
|
|
445
|
+
const chunks = parts.map((data, index) => chunkPayload(data, index, parts.length));
|
|
446
|
+
const summary = serializeEvidenceContent({
|
|
447
|
+
...base,
|
|
448
|
+
recordType: "summary",
|
|
449
|
+
evidence: {
|
|
450
|
+
complete: evidence.completeness.complete,
|
|
451
|
+
reasons: evidence.completeness.reasons,
|
|
452
|
+
logChunkCount: chunks.length,
|
|
453
|
+
logRecordCount: evidence.pages.reduce((count, page) => count + page.records.length, 0),
|
|
454
|
+
byteLength: utf8ByteLength(document),
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
assertContentFits(summary);
|
|
458
|
+
for (const chunk of chunks)
|
|
459
|
+
assertContentFits(chunk);
|
|
460
|
+
return { summary, chunks };
|
|
461
|
+
}
|
|
462
|
+
|
|
22
463
|
const SKYWALKING_PLUGIN_ID = "liveavatar.skywalking";
|
|
23
|
-
const AVSYNC_ALERTS_CONTRIBUTION_ID = "liveavatar.skywalking.avsync-alerts";
|
|
24
464
|
const OPERATIONAL_LOGS_CONTRIBUTION_ID = "liveavatar.skywalking.operational-logs";
|
|
25
|
-
const ALERT_LOG_DURATION_MS = 30000;
|
|
26
|
-
const TELEMETRY_PAGE_SIZE = 1000;
|
|
27
|
-
/**
|
|
28
|
-
* The platform limits the complete top-level `content` value of one error
|
|
29
|
-
* record to 32 KiB. Keep a margin for platform serialization differences.
|
|
30
|
-
*/
|
|
31
|
-
const EVIDENCE_CONTENT_BYTE_LIMIT = 28 * 1024;
|
|
32
|
-
const FRAME_METADATA_MAX_ASSOCIATION_AGE_MS = 150;
|
|
33
|
-
const TIME_SYNC_BUCKET_MS = 1000;
|
|
34
465
|
const SKYWALKING_SERVICE = "yy-tx::liveavatar-js-sdk";
|
|
35
466
|
const DOMESTIC_COLLECTOR = "https://apm.hexin.cn/skywalking-web";
|
|
36
|
-
const OVERSEAS_COLLECTOR = "https://
|
|
467
|
+
const OVERSEAS_COLLECTOR = "https://ai.dreamfaceapp.com/skywalking-web";
|
|
37
468
|
const REGISTRATION_STATE_KEY = Symbol.for("liveavatar.skywalking.registration-state");
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*/
|
|
469
|
+
const MAX_PENDING_ALERTS = 1000;
|
|
470
|
+
const DEFAULT_PLAYBACK_STATUS_INTERVAL_MS = 5000;
|
|
471
|
+
/** Consumes SDK facts and samples playback through the public Plugin API v1. */
|
|
42
472
|
class SkyWalkingPlugin {
|
|
43
473
|
constructor(config = {}) {
|
|
44
474
|
this.id = SKYWALKING_PLUGIN_ID;
|
|
45
|
-
/** SDK Plugin API v1 is the registrar-based public plugin contract. */
|
|
46
475
|
this.apiVersion = 1;
|
|
47
|
-
this.
|
|
476
|
+
this.terminalObserverDelivery = "sync-before-dispose";
|
|
48
477
|
this._skyWalkingConfig = { ...config };
|
|
49
478
|
this._reporting = normalizeReportingConfig(config.reporting);
|
|
479
|
+
const interval = config.playbackStatusIntervalMs;
|
|
480
|
+
this._playbackStatusIntervalMs =
|
|
481
|
+
typeof interval === "number" &&
|
|
482
|
+
Number.isInteger(interval) &&
|
|
483
|
+
interval > 0 &&
|
|
484
|
+
interval <= 2147483647
|
|
485
|
+
? interval
|
|
486
|
+
: DEFAULT_PLAYBACK_STATUS_INTERVAL_MS;
|
|
487
|
+
if (interval !== undefined && interval !== this._playbackStatusIntervalMs)
|
|
488
|
+
this._warn("Invalid playbackStatusIntervalMs; using 5000 ms");
|
|
50
489
|
}
|
|
51
490
|
setup(registrar) {
|
|
52
491
|
this._deactivateInstallation();
|
|
@@ -54,26 +493,45 @@ class SkyWalkingPlugin {
|
|
|
54
493
|
return;
|
|
55
494
|
registerSkyWalking(this._skyWalkingConfig);
|
|
56
495
|
const installation = {
|
|
57
|
-
|
|
496
|
+
active: true,
|
|
58
497
|
abortController: new AbortController(),
|
|
498
|
+
retiredPlaybackOwners: new Set(),
|
|
499
|
+
playbackSequences: new Map(),
|
|
59
500
|
alertReportStates: new Map(),
|
|
60
|
-
|
|
501
|
+
pending: [],
|
|
502
|
+
draining: false,
|
|
61
503
|
};
|
|
62
504
|
this._installation = installation;
|
|
63
505
|
try {
|
|
64
|
-
if (this._reporting.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
handler: (record, context) => this._handleOperationalLog(installation, record, context.signal),
|
|
75
|
-
});
|
|
506
|
+
if (this._reporting.playbackStatus) {
|
|
507
|
+
try {
|
|
508
|
+
const service = registrar.consume(liveavatarJsSdk.SDK_AVSYNC_DIAGNOSTICS_V1);
|
|
509
|
+
if (typeof service?.getPlaybackStatus !== "function")
|
|
510
|
+
throw new Error("getPlaybackStatus is unavailable");
|
|
511
|
+
installation.playbackService = service;
|
|
512
|
+
}
|
|
513
|
+
catch (error) {
|
|
514
|
+
this._warn("Playback status service unavailable; sampling disabled", error);
|
|
515
|
+
}
|
|
76
516
|
}
|
|
517
|
+
if (this._reporting.avSync)
|
|
518
|
+
installation.diagnostics = registrar.consume(liveavatarJsSdk.SDK_AVSYNC_DIAGNOSTICS_V2);
|
|
519
|
+
registrar.observe(liveavatarJsSdk.SDK_OPERATIONAL_LOGS_V2, {
|
|
520
|
+
id: OPERATIONAL_LOGS_CONTRIBUTION_ID,
|
|
521
|
+
handler: (record, context) => {
|
|
522
|
+
if (!this._isActive(installation, context.signal))
|
|
523
|
+
return;
|
|
524
|
+
this._handlePlaybackLifecycle(installation, record);
|
|
525
|
+
if (record.event === "avsync.alert") {
|
|
526
|
+
if (this._reporting.avSync)
|
|
527
|
+
this._queueAlert(installation, record, context.signal);
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
// These async methods call ClientMonitor synchronously before their first
|
|
531
|
+
// await, preserving the SDK's terminal handoff during dispose.
|
|
532
|
+
return this._handleOperationalLog(installation, record, context.signal)?.then(() => undefined);
|
|
533
|
+
},
|
|
534
|
+
});
|
|
77
535
|
}
|
|
78
536
|
catch (error) {
|
|
79
537
|
this._deactivateInstallation();
|
|
@@ -83,1215 +541,364 @@ class SkyWalkingPlugin {
|
|
|
83
541
|
dispose() {
|
|
84
542
|
this._deactivateInstallation();
|
|
85
543
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return Promise.resolve();
|
|
99
|
-
installation.alertReportStates.set(alert.alertId, state);
|
|
100
|
-
return this._enqueue(state, () => this._runObserverTask(installation, signal, "A/V Sync alert", () => this._reportActiveAlert(installation, alert, state, signal)));
|
|
101
|
-
}
|
|
102
|
-
const state = installation.alertReportStates.get(alert.alertId);
|
|
103
|
-
if (state === undefined || state.closing)
|
|
104
|
-
return Promise.resolve();
|
|
105
|
-
if (alert.phase === "updated") {
|
|
106
|
-
return this._enqueue(state, () => this._runObserverTask(installation, signal, "A/V Sync alert update", () => this._reportActiveAlert(installation, alert, state, signal)));
|
|
107
|
-
}
|
|
108
|
-
state.closing = true;
|
|
109
|
-
const recoveredAtWallClockMs = Date.now();
|
|
110
|
-
const report = this._enqueue(state, () => this._runObserverTask(installation, signal, "A/V Sync recovery", () => this._reportRecovery(installation, alert.alertId, recoveredAtWallClockMs, signal)));
|
|
111
|
-
const removeState = () => {
|
|
112
|
-
if (installation.alertReportStates.get(alert.alertId) === state) {
|
|
113
|
-
installation.alertReportStates.delete(alert.alertId);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
void report.then(removeState, removeState);
|
|
117
|
-
return report;
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
this._warnInvocationFailure(installation, signal, "Failed to handle an A/V Sync alert", error, { alert: toJsonSafeAlert(alert) });
|
|
121
|
-
return Promise.resolve();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
_handleOperationalLog(installation, record, signal) {
|
|
125
|
-
if (!this._isInvocationActive(installation, signal))
|
|
126
|
-
return Promise.resolve();
|
|
127
|
-
if (this._reporting.sdkError &&
|
|
128
|
-
record.level === "error" &&
|
|
129
|
-
record.event === "sdk.error") {
|
|
130
|
-
return this._runObserverTask(installation, signal, "SDK error log", () => this._reportSdkError(installation, record, signal));
|
|
131
|
-
}
|
|
132
|
-
if (this._reporting.firstFrame &&
|
|
133
|
-
record.category === "media" &&
|
|
134
|
-
record.event === "performance.first-frame") {
|
|
135
|
-
return this._runObserverTask(installation, signal, "first-frame log", () => this._reportFirstFrameLog(installation, record, signal));
|
|
136
|
-
}
|
|
137
|
-
return Promise.resolve();
|
|
138
|
-
}
|
|
139
|
-
_enqueue(state, task) {
|
|
140
|
-
const queued = state.tail.then(task, task);
|
|
141
|
-
state.tail = queued.catch(() => undefined);
|
|
142
|
-
return queued;
|
|
544
|
+
_deactivateInstallation() {
|
|
545
|
+
const installation = this._installation;
|
|
546
|
+
if (!installation)
|
|
547
|
+
return;
|
|
548
|
+
installation.active = false;
|
|
549
|
+
this._stopPlayback(installation);
|
|
550
|
+
installation.abortController.abort();
|
|
551
|
+
installation.pending.length = 0;
|
|
552
|
+
installation.alertReportStates.clear();
|
|
553
|
+
installation.retiredPlaybackOwners.clear();
|
|
554
|
+
installation.playbackSequences.clear();
|
|
555
|
+
this._installation = undefined;
|
|
143
556
|
}
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
if (!
|
|
557
|
+
_stopPlayback(installation) {
|
|
558
|
+
const sampling = installation.playback;
|
|
559
|
+
if (!sampling)
|
|
147
560
|
return;
|
|
148
|
-
|
|
149
|
-
if (
|
|
561
|
+
sampling.abortController.abort();
|
|
562
|
+
if (sampling.timer !== undefined)
|
|
563
|
+
clearInterval(sampling.timer);
|
|
564
|
+
installation.playback = undefined;
|
|
565
|
+
}
|
|
566
|
+
_handlePlaybackLifecycle(installation, record) {
|
|
567
|
+
if (!installation.playbackService)
|
|
150
568
|
return;
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
569
|
+
const event = record.event;
|
|
570
|
+
const starts = [
|
|
571
|
+
"connect.completed",
|
|
572
|
+
"reconnect.completed",
|
|
573
|
+
"livekit.connected",
|
|
574
|
+
].includes(event) ||
|
|
575
|
+
(event === "rtc.state-changed" &&
|
|
576
|
+
record.data?.roomState === "connected" &&
|
|
577
|
+
["connected", "state-changed"].includes(String(record.data?.phase)));
|
|
578
|
+
const stops = [
|
|
579
|
+
"connect.failed",
|
|
580
|
+
"reconnect.started",
|
|
581
|
+
"reconnect.failed",
|
|
582
|
+
"disconnect.completed",
|
|
583
|
+
"monitoring.session.ended",
|
|
584
|
+
"client.disposed",
|
|
585
|
+
"livekit.disconnected",
|
|
586
|
+
].includes(event) ||
|
|
587
|
+
(event === "rtc.state-changed" &&
|
|
588
|
+
["disconnected", "reconnecting", "connecting"].includes(String(record.data?.roomState)));
|
|
589
|
+
if (!starts &&
|
|
590
|
+
!stops &&
|
|
591
|
+
event !== "monitoring.session.started" &&
|
|
592
|
+
event !== "avsync.session.started")
|
|
157
593
|
return;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
594
|
+
const owner = JSON.stringify([
|
|
595
|
+
record.clientInstanceId,
|
|
596
|
+
record.monitoringSessionId,
|
|
597
|
+
]);
|
|
598
|
+
if (installation.retiredPlaybackOwners.has(owner))
|
|
162
599
|
return;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
600
|
+
// Lifecycle facts share SDK-owned streams. Ignore delayed older facts, without
|
|
601
|
+
// comparing sequence numbers from different streams or monitoring sessions.
|
|
602
|
+
const stream = JSON.stringify([owner, record.streamId]);
|
|
603
|
+
const previous = installation.playbackSequences.get(stream);
|
|
604
|
+
if (previous !== undefined && record.sequence <= previous)
|
|
167
605
|
return;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (!isActive())
|
|
606
|
+
installation.playbackSequences.set(stream, record.sequence);
|
|
607
|
+
if (event === "client.disposed") {
|
|
608
|
+
this._stopPlayback(installation);
|
|
172
609
|
return;
|
|
173
|
-
try {
|
|
174
|
-
await Promise.resolve(clientMonitor.reportFrameErrors({
|
|
175
|
-
category: "avsync",
|
|
176
|
-
grade: "Warning",
|
|
177
|
-
content: payload,
|
|
178
|
-
}, {
|
|
179
|
-
// The bundled SkyWalking script uses this as errorUrl. An empty
|
|
180
|
-
// name lets it fall back to the browser page URL.
|
|
181
|
-
name: "",
|
|
182
|
-
message: `[LiveAvatar A/V Sync] ${alert.finding}: ${alert.message}`,
|
|
183
|
-
stack: "",
|
|
184
|
-
}));
|
|
185
|
-
for (const chunk of chunks) {
|
|
186
|
-
if (!isActive())
|
|
187
|
-
return;
|
|
188
|
-
await Promise.resolve(clientMonitor.reportFrameErrors({
|
|
189
|
-
category: "avsync",
|
|
190
|
-
grade: "Info",
|
|
191
|
-
content: chunk,
|
|
192
|
-
}, {
|
|
193
|
-
name: "",
|
|
194
|
-
message: `[LiveAvatar A/V Sync] evidence chunk ${chunk.chunk.index + 1}/${chunk.chunk.total}`,
|
|
195
|
-
stack: "",
|
|
196
|
-
}));
|
|
197
|
-
}
|
|
198
610
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
collection.requestedToWallClockMs !== null) {
|
|
207
|
-
state.lastSuccessfulToWallClockMs = collection.requestedToWallClockMs;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
async _reportRecovery(installation, alertId, recoveredAtWallClockMs, signal) {
|
|
211
|
-
if (!this._isInvocationActive(installation, signal))
|
|
212
|
-
return;
|
|
213
|
-
const clientMonitor = getClientMonitor();
|
|
214
|
-
if (clientMonitor === undefined) {
|
|
215
|
-
this._warnInvocation(installation, signal, "ClientMonitor.reportFrameErrors is unavailable", {
|
|
216
|
-
pluginId: this.id,
|
|
217
|
-
alertId,
|
|
218
|
-
recoveredAtWallClockMs,
|
|
219
|
-
});
|
|
220
|
-
return;
|
|
611
|
+
if (installation.playbackOwner !== owner) {
|
|
612
|
+
if (!starts && event !== "monitoring.session.started")
|
|
613
|
+
return;
|
|
614
|
+
if (installation.playbackOwner !== undefined)
|
|
615
|
+
installation.retiredPlaybackOwners.add(installation.playbackOwner);
|
|
616
|
+
this._stopPlayback(installation);
|
|
617
|
+
installation.playbackOwner = owner;
|
|
221
618
|
}
|
|
222
|
-
if (
|
|
619
|
+
if (stops) {
|
|
620
|
+
this._stopPlayback(installation);
|
|
621
|
+
if (event === "monitoring.session.ended")
|
|
622
|
+
installation.retiredPlaybackOwners.add(owner);
|
|
223
623
|
return;
|
|
224
|
-
try {
|
|
225
|
-
await Promise.resolve(clientMonitor.reportFrameErrors({
|
|
226
|
-
category: "avsync",
|
|
227
|
-
grade: "Recovered",
|
|
228
|
-
content: { alertId, recoveredAtWallClockMs },
|
|
229
|
-
}, {
|
|
230
|
-
name: "",
|
|
231
|
-
message: "[LiveAvatar A/V Sync] alert recovered",
|
|
232
|
-
stack: "",
|
|
233
|
-
}));
|
|
234
624
|
}
|
|
235
|
-
|
|
236
|
-
|
|
625
|
+
const identities = {
|
|
626
|
+
...sourceCorrelation(record),
|
|
627
|
+
clientInstanceId: record.clientInstanceId,
|
|
628
|
+
};
|
|
629
|
+
if (installation.playback) {
|
|
630
|
+
const updated = {
|
|
631
|
+
...installation.playback.owner,
|
|
632
|
+
...identities,
|
|
633
|
+
};
|
|
634
|
+
const changed = ["serverSessionId", "avsyncSessionId"];
|
|
635
|
+
if (!changed.some((key) => updated[key] !== installation.playback.owner[key])) {
|
|
636
|
+
installation.playback.owner = updated;
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
// A changed diagnostic segment also invalidates a pending sample.
|
|
640
|
+
this._stopPlayback(installation);
|
|
641
|
+
this._startPlayback(installation, updated);
|
|
237
642
|
return;
|
|
238
643
|
}
|
|
239
|
-
if (!
|
|
644
|
+
if (!starts)
|
|
240
645
|
return;
|
|
646
|
+
this._startPlayback(installation, identities);
|
|
241
647
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (clientMonitor === undefined) {
|
|
248
|
-
this._warnInvocation(installation, signal, "ClientMonitor.reportFrameErrors is unavailable", {
|
|
249
|
-
pluginId: this.id,
|
|
250
|
-
sdkError: { code },
|
|
251
|
-
});
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
const payload = {
|
|
255
|
-
schemaVersion: 2,
|
|
256
|
-
kind: "liveavatar.sdk.error",
|
|
257
|
-
sdkVersion: liveavatarJsSdk.VERSION,
|
|
258
|
-
error: stringifyJson({
|
|
259
|
-
code,
|
|
260
|
-
eventId: record.eventId,
|
|
261
|
-
sequence: record.sequence,
|
|
262
|
-
occurredAtMs: record.occurredAtMs,
|
|
263
|
-
category: record.category,
|
|
264
|
-
event: record.event,
|
|
265
|
-
clientInstanceId: record.clientInstanceId,
|
|
266
|
-
...(record.sessionId === undefined
|
|
267
|
-
? {}
|
|
268
|
-
: { sessionId: record.sessionId }),
|
|
269
|
-
}),
|
|
648
|
+
_startPlayback(installation, owner) {
|
|
649
|
+
const sampling = {
|
|
650
|
+
owner,
|
|
651
|
+
abortController: new AbortController(),
|
|
652
|
+
busy: false,
|
|
270
653
|
};
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
grade: "Error",
|
|
277
|
-
content: payload,
|
|
278
|
-
}, {
|
|
279
|
-
name: "",
|
|
280
|
-
message: `[LiveAvatar SDK] ${code}`,
|
|
281
|
-
stack: "",
|
|
282
|
-
}));
|
|
283
|
-
}
|
|
284
|
-
catch (error) {
|
|
285
|
-
this._warnInvocationFailure(installation, signal, "Failed to report an SDK error to SkyWalking", error, { eventId: record.eventId, code });
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
if (!this._isInvocationActive(installation, signal))
|
|
289
|
-
return;
|
|
654
|
+
installation.playback = sampling;
|
|
655
|
+
sampling.timer = setInterval(() => {
|
|
656
|
+
void this._samplePlayback(installation, sampling);
|
|
657
|
+
}, this._playbackStatusIntervalMs);
|
|
658
|
+
void this._samplePlayback(installation, sampling);
|
|
290
659
|
}
|
|
291
|
-
async
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (
|
|
296
|
-
this._warnInvocation(installation, signal, "Skipped invalid first-frame Operational Log", { eventId: record.eventId });
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
const clientMonitor = getClientMonitor();
|
|
300
|
-
if (clientMonitor === undefined) {
|
|
301
|
-
this._warnInvocation(installation, signal, "ClientMonitor.reportFrameErrors is unavailable", {
|
|
302
|
-
pluginId: this.id,
|
|
303
|
-
attemptId: payload.attemptId,
|
|
304
|
-
outcome: payload.outcome,
|
|
305
|
-
});
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
if (!this._isInvocationActive(installation, signal))
|
|
660
|
+
async _samplePlayback(installation, sampling) {
|
|
661
|
+
const signal = sampling.abortController.signal;
|
|
662
|
+
const active = () => installation.playback === sampling &&
|
|
663
|
+
this._isActive(installation, signal);
|
|
664
|
+
if (sampling.busy || !active())
|
|
309
665
|
return;
|
|
666
|
+
sampling.busy = true;
|
|
667
|
+
// Capture ownership before the asynchronous query; never attribute its result
|
|
668
|
+
// using a later connection or diagnostic session.
|
|
669
|
+
const owner = { ...sampling.owner };
|
|
310
670
|
try {
|
|
311
|
-
await
|
|
671
|
+
const status = await installation.playbackService.getPlaybackStatus();
|
|
672
|
+
if (!active())
|
|
673
|
+
return;
|
|
674
|
+
if (!status.connection.rtc.connected) {
|
|
675
|
+
this._stopPlayback(installation);
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
const payload = {
|
|
679
|
+
schemaVersion: 4,
|
|
680
|
+
kind: "liveavatar.playback.status",
|
|
681
|
+
...owner,
|
|
682
|
+
occurredAtMs: Date.now(),
|
|
683
|
+
playback: {
|
|
684
|
+
sampledAtMs: status.sampledAtMs,
|
|
685
|
+
connection: JSON.stringify(status.connection),
|
|
686
|
+
ice: JSON.stringify(status.ice),
|
|
687
|
+
output: status.output === null ? null : JSON.stringify(status.output),
|
|
688
|
+
tracks: JSON.stringify(status.tracks),
|
|
689
|
+
quality: status.quality,
|
|
690
|
+
qualityReasons: JSON.stringify(status.qualityReasons),
|
|
691
|
+
presentationSamplingEnabled: status.presentationSamplingEnabled,
|
|
692
|
+
},
|
|
693
|
+
};
|
|
694
|
+
if (utf8ByteLength(JSON.stringify(payload)) > 28 * 1024)
|
|
695
|
+
throw new Error("Playback status content exceeds the 28 KiB limit");
|
|
696
|
+
await this._report(installation, signal, {
|
|
312
697
|
category: "media",
|
|
313
|
-
grade:
|
|
314
|
-
content: payload,
|
|
315
|
-
// The bundled client batches error records. Its public timeout
|
|
316
|
-
// option bypasses the default delay for these terminal events.
|
|
698
|
+
grade: "Info",
|
|
317
699
|
timeout: 1,
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
message: `[LiveAvatar first-frame] ${payload.outcome}`,
|
|
321
|
-
stack: "",
|
|
322
|
-
}));
|
|
700
|
+
content: payload,
|
|
701
|
+
}, "[LiveAvatar playback] status");
|
|
323
702
|
}
|
|
324
703
|
catch (error) {
|
|
325
|
-
|
|
704
|
+
if (active())
|
|
705
|
+
this._warn("Failed to sample playback status", error);
|
|
706
|
+
}
|
|
707
|
+
finally {
|
|
708
|
+
sampling.busy = false;
|
|
326
709
|
}
|
|
327
710
|
}
|
|
328
|
-
|
|
329
|
-
const installation = this._installation;
|
|
330
|
-
if (installation === undefined)
|
|
331
|
-
return;
|
|
332
|
-
installation.active = false;
|
|
333
|
-
installation.abortController.abort();
|
|
334
|
-
installation.alertReportStates.clear();
|
|
335
|
-
if (this._installation === installation)
|
|
336
|
-
this._installation = undefined;
|
|
337
|
-
}
|
|
338
|
-
_isInvocationActive(installation, signal) {
|
|
711
|
+
_isActive(installation, signal) {
|
|
339
712
|
return (this._installation === installation &&
|
|
340
713
|
installation.active &&
|
|
341
714
|
!installation.abortController.signal.aborted &&
|
|
342
715
|
!signal.aborted);
|
|
343
716
|
}
|
|
344
|
-
|
|
345
|
-
try {
|
|
346
|
-
await task();
|
|
347
|
-
}
|
|
348
|
-
catch (error) {
|
|
349
|
-
this._warnInvocationFailure(installation, signal, `Failed to handle ${description}`, error);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
_warnInvocationFailure(installation, signal, message, error, details = {}) {
|
|
353
|
-
this._warnInvocation(installation, signal, message, { ...details, error });
|
|
354
|
-
}
|
|
355
|
-
_warnInvocation(installation, signal, message, details) {
|
|
356
|
-
if (!this._isInvocationActive(installation, signal))
|
|
357
|
-
return;
|
|
717
|
+
_warn(message, error) {
|
|
358
718
|
try {
|
|
359
|
-
console.warn(`[LiveAvatar SkyWalking plugin] ${message}`,
|
|
719
|
+
console.warn(`[LiveAvatar SkyWalking plugin] ${message}`, error);
|
|
360
720
|
}
|
|
361
721
|
catch {
|
|
362
|
-
|
|
722
|
+
/* Diagnostics must not fault the SDK. */
|
|
363
723
|
}
|
|
364
724
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
return undefined;
|
|
373
|
-
let firstPage;
|
|
374
|
-
let analysis = null;
|
|
375
|
-
let analysisUnavailable = false;
|
|
376
|
-
let telemetryResult;
|
|
377
|
-
let analysisResult;
|
|
378
|
-
try {
|
|
379
|
-
[telemetryResult, analysisResult] = await Promise.allSettled([
|
|
380
|
-
diagnostics.getAvSyncRawTelemetry({
|
|
381
|
-
range: query.range,
|
|
382
|
-
pageSize: TELEMETRY_PAGE_SIZE,
|
|
383
|
-
includeSummary: true,
|
|
384
|
-
}),
|
|
385
|
-
diagnostics.getAvSyncAnalysis({ range: query.range }),
|
|
386
|
-
]);
|
|
387
|
-
}
|
|
388
|
-
catch (error) {
|
|
389
|
-
if (!shouldContinue())
|
|
390
|
-
return undefined;
|
|
391
|
-
onDiagnosticFailure("Failed to query A/V Sync telemetry", error);
|
|
392
|
-
return {
|
|
393
|
-
evidence: unavailableEvidence(retrievedAtWallClockMs, query, "initial-query-failed", alert),
|
|
394
|
-
requestedToWallClockMs: null,
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
if (!shouldContinue())
|
|
398
|
-
return undefined;
|
|
399
|
-
if (telemetryResult.status === "rejected") {
|
|
400
|
-
onDiagnosticFailure("Failed to query A/V Sync telemetry", telemetryResult.reason);
|
|
401
|
-
return {
|
|
402
|
-
evidence: unavailableEvidence(retrievedAtWallClockMs, query, "initial-query-failed", alert),
|
|
403
|
-
requestedToWallClockMs: null,
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
firstPage = telemetryResult.value;
|
|
407
|
-
if (analysisResult.status === "fulfilled") {
|
|
408
|
-
analysis = analysisResult.value;
|
|
409
|
-
}
|
|
410
|
-
else {
|
|
411
|
-
analysisUnavailable = true;
|
|
412
|
-
onDiagnosticFailure("Failed to query A/V Sync analysis", analysisResult.reason);
|
|
413
|
-
}
|
|
414
|
-
if (!shouldContinue())
|
|
415
|
-
return undefined;
|
|
416
|
-
const firstPageEvidence = evidenceFromFirstPage(firstPage, query);
|
|
417
|
-
if (firstPage.sessionId !== alert.sessionId) {
|
|
418
|
-
return {
|
|
419
|
-
evidence: {
|
|
420
|
-
...firstPageEvidence,
|
|
421
|
-
window: {
|
|
422
|
-
...firstPageEvidence.window,
|
|
423
|
-
complete: false,
|
|
424
|
-
unavailableReason: "session-mismatch",
|
|
425
|
-
},
|
|
426
|
-
triage: createTriage(alert, null, ["session-mismatch"]),
|
|
427
|
-
},
|
|
428
|
-
requestedToWallClockMs: firstPage.page.requestedToWallClockMs,
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
|
-
const logs = [...firstPage.avSyncLogs];
|
|
432
|
-
let page = firstPage.page;
|
|
433
|
-
let truncated = page.truncated;
|
|
434
|
-
const seenCursors = new Set();
|
|
435
|
-
while (page.hasMore) {
|
|
436
|
-
if (!shouldContinue())
|
|
437
|
-
return undefined;
|
|
438
|
-
const cursor = page.nextCursor;
|
|
439
|
-
if (cursor === null || seenCursors.has(cursor)) {
|
|
440
|
-
return {
|
|
441
|
-
evidence: compactEvidence(firstPageEvidence, logs, truncated, "cursor-did-not-advance", alert, analysis, analysisUnavailable, firstPage),
|
|
442
|
-
requestedToWallClockMs: firstPage.page.requestedToWallClockMs,
|
|
443
|
-
};
|
|
725
|
+
async _report(installation, signal, config, message) {
|
|
726
|
+
if (!this._isActive(installation, signal))
|
|
727
|
+
return false;
|
|
728
|
+
const monitor = getClientMonitor();
|
|
729
|
+
if (!monitor) {
|
|
730
|
+
this._warn("ClientMonitor.reportFrameErrors is unavailable");
|
|
731
|
+
return false;
|
|
444
732
|
}
|
|
445
|
-
seenCursors.add(cursor);
|
|
446
|
-
let continuation;
|
|
447
733
|
try {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
pageSize: TELEMETRY_PAGE_SIZE,
|
|
451
|
-
includeSummary: false,
|
|
452
|
-
});
|
|
734
|
+
await Promise.resolve(monitor.reportFrameErrors({ ...config, serviceVersion: liveavatarJsSdk.VERSION }, { name: "", message, stack: "" }));
|
|
735
|
+
return this._isActive(installation, signal);
|
|
453
736
|
}
|
|
454
737
|
catch (error) {
|
|
455
|
-
if (
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
return {
|
|
459
|
-
evidence: compactEvidence(firstPageEvidence, logs, truncated, "continuation-query-failed", alert, analysis, analysisUnavailable, firstPage),
|
|
460
|
-
requestedToWallClockMs: firstPage.page.requestedToWallClockMs,
|
|
461
|
-
};
|
|
738
|
+
if (this._isActive(installation, signal))
|
|
739
|
+
this._warn("Failed to report to SkyWalking", error);
|
|
740
|
+
return false;
|
|
462
741
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
if (
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
742
|
+
}
|
|
743
|
+
_handleOperationalLog(installation, record, signal) {
|
|
744
|
+
if (record.event === "sdk.failure") {
|
|
745
|
+
if (!this._reporting.sdkError ||
|
|
746
|
+
!record.error ||
|
|
747
|
+
!["warn", "error"].includes(record.level))
|
|
748
|
+
return;
|
|
749
|
+
const payload = {
|
|
750
|
+
...operationalSource(record),
|
|
751
|
+
kind: "liveavatar.sdk.error",
|
|
752
|
+
schemaVersion: 4,
|
|
753
|
+
error: JSON.stringify(projectRecord(record)),
|
|
469
754
|
};
|
|
755
|
+
return this._report(installation, signal, {
|
|
756
|
+
category: record.module,
|
|
757
|
+
grade: record.level === "warn" ? "Warning" : "Error",
|
|
758
|
+
content: payload,
|
|
759
|
+
timeout: 1,
|
|
760
|
+
}, `[LiveAvatar SDK] ${record.error.code}`);
|
|
470
761
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
return {
|
|
478
|
-
evidence: compactEvidence(firstPageEvidence, logs, truncated, undefined, alert, analysis, analysisUnavailable, firstPage, true),
|
|
479
|
-
requestedToWallClockMs: firstPage.page.requestedToWallClockMs,
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
function evidenceFromFirstPage(telemetry, query) {
|
|
483
|
-
return {
|
|
484
|
-
evidenceSchemaVersion: 2,
|
|
485
|
-
sessionId: telemetry.sessionId ?? null,
|
|
486
|
-
window: {
|
|
487
|
-
mode: query.mode,
|
|
488
|
-
requestedFromWallClockMs: telemetry.page.requestedFromWallClockMs,
|
|
489
|
-
requestedToWallClockMs: telemetry.page.requestedToWallClockMs,
|
|
490
|
-
availableFromWallClockMs: telemetry.page.availableFromWallClockMs,
|
|
491
|
-
availableToWallClockMs: telemetry.page.availableToWallClockMs,
|
|
492
|
-
complete: false,
|
|
493
|
-
truncated: telemetry.page.truncated,
|
|
494
|
-
},
|
|
495
|
-
retention: compactRetention(telemetry.avSyncLogRetention),
|
|
496
|
-
triage: null,
|
|
497
|
-
logChunkCount: 0,
|
|
498
|
-
logRecordCount: 0,
|
|
499
|
-
detail: emptyDetail(),
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
function unavailableEvidence(_retrievedAtWallClockMs, query, unavailableReason, alert) {
|
|
503
|
-
return {
|
|
504
|
-
evidenceSchemaVersion: 2,
|
|
505
|
-
retention: null,
|
|
506
|
-
sessionId: null,
|
|
507
|
-
window: {
|
|
508
|
-
mode: query.mode,
|
|
509
|
-
requestedFromWallClockMs: null,
|
|
510
|
-
requestedToWallClockMs: null,
|
|
511
|
-
availableFromWallClockMs: null,
|
|
512
|
-
availableToWallClockMs: null,
|
|
513
|
-
complete: false,
|
|
514
|
-
truncated: false,
|
|
515
|
-
unavailableReason,
|
|
516
|
-
},
|
|
517
|
-
triage: createTriage(alert, null, [unavailableReason]),
|
|
518
|
-
logChunkCount: 0,
|
|
519
|
-
logRecordCount: 0,
|
|
520
|
-
detail: emptyDetail(),
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
async function createEvidenceQuery(phase, lastSuccessfulToWallClockMs, signals) {
|
|
524
|
-
if (isAnySignalAborted(signals))
|
|
525
|
-
return undefined;
|
|
526
|
-
if (phase === "raised" || lastSuccessfulToWallClockMs === undefined) {
|
|
527
|
-
return {
|
|
528
|
-
mode: "recent",
|
|
529
|
-
range: { kind: "recent", durationMs: ALERT_LOG_DURATION_MS },
|
|
530
|
-
requestedDurationMs: ALERT_LOG_DURATION_MS,
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
let now = Date.now();
|
|
534
|
-
const nextFromMs = lastSuccessfulToWallClockMs + 1;
|
|
535
|
-
if (now < nextFromMs) {
|
|
536
|
-
await waitForWallClock(nextFromMs, signals);
|
|
537
|
-
if (isAnySignalAborted(signals))
|
|
538
|
-
return undefined;
|
|
539
|
-
now = Date.now();
|
|
540
|
-
}
|
|
541
|
-
const fromMs = Math.max(nextFromMs, now - ALERT_LOG_DURATION_MS);
|
|
542
|
-
const toMs = Math.max(fromMs, now);
|
|
543
|
-
return {
|
|
544
|
-
mode: "wall-clock",
|
|
545
|
-
range: { kind: "wall-clock", fromMs, toMs },
|
|
546
|
-
requestedDurationMs: toMs - fromMs,
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
|
-
function waitForWallClock(targetMs, signals) {
|
|
550
|
-
if (isAnySignalAborted(signals))
|
|
551
|
-
return Promise.resolve();
|
|
552
|
-
return new Promise((resolve) => {
|
|
553
|
-
let settled = false;
|
|
554
|
-
let timeout;
|
|
555
|
-
const finish = () => {
|
|
556
|
-
if (settled)
|
|
762
|
+
if (record.event === "performance.first-frame") {
|
|
763
|
+
if (!this._reporting.firstFrame)
|
|
764
|
+
return;
|
|
765
|
+
const payload = toSkyWalkingFirstFrameLogPayload(record);
|
|
766
|
+
if (!payload) {
|
|
767
|
+
this._warn("Skipped invalid first-frame Operational Log");
|
|
557
768
|
return;
|
|
558
|
-
settled = true;
|
|
559
|
-
if (timeout !== undefined)
|
|
560
|
-
clearTimeout(timeout);
|
|
561
|
-
for (const signal of signals) {
|
|
562
|
-
signal.removeEventListener("abort", finish);
|
|
563
769
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
}
|
|
571
|
-
function isAnySignalAborted(signals) {
|
|
572
|
-
return signals.some((signal) => signal.aborted);
|
|
573
|
-
}
|
|
574
|
-
function compactEvidence(firstPageEvidence, logs, truncated, unavailableReason, alert, analysis, analysisUnavailable, telemetry, complete = false) {
|
|
575
|
-
const compacted = compactLogs(logs, telemetry);
|
|
576
|
-
return {
|
|
577
|
-
...firstPageEvidence,
|
|
578
|
-
window: {
|
|
579
|
-
...firstPageEvidence.window,
|
|
580
|
-
complete,
|
|
581
|
-
truncated,
|
|
582
|
-
...(unavailableReason === undefined ? {} : { unavailableReason }),
|
|
583
|
-
},
|
|
584
|
-
triage: createTriage(alert, analysis, analysisUnavailable ? ["analysis-query-failed"] : []),
|
|
585
|
-
...chunkCompactLogs(compacted.logs, compacted.detail),
|
|
586
|
-
};
|
|
587
|
-
}
|
|
588
|
-
function compactRetention(retention) {
|
|
589
|
-
if (retention === null)
|
|
590
|
-
return null;
|
|
591
|
-
return {
|
|
592
|
-
storageWriteFailed: retention.storageWriteFailed,
|
|
593
|
-
droppedSegmentCount: retention.droppedSegmentCount,
|
|
594
|
-
droppedLogCount: retention.droppedLogCount,
|
|
595
|
-
oldestSegmentAtMs: retention.oldestSegmentAtMs,
|
|
596
|
-
newestSegmentAtMs: retention.newestSegmentAtMs,
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
function createTriage(alert, analysis, limitations) {
|
|
600
|
-
const usableAnalysis = analysis !== null &&
|
|
601
|
-
analysis.layers !== null &&
|
|
602
|
-
typeof analysis.layers === "object" &&
|
|
603
|
-
Array.isArray(analysis.participants) &&
|
|
604
|
-
typeof analysis.finding === "string";
|
|
605
|
-
return {
|
|
606
|
-
trigger: {
|
|
607
|
-
finding: alert.finding,
|
|
608
|
-
status: alert.status,
|
|
609
|
-
confidence: alert.confidence,
|
|
610
|
-
capturedAtMs: alert.capturedAtMs,
|
|
611
|
-
},
|
|
612
|
-
evaluation: !usableAnalysis || analysis === null
|
|
613
|
-
? null
|
|
614
|
-
: {
|
|
615
|
-
finding: analysis.finding,
|
|
616
|
-
status: analysis.status,
|
|
617
|
-
confidence: analysis.confidence,
|
|
618
|
-
},
|
|
619
|
-
layers: !usableAnalysis || analysis === null
|
|
620
|
-
? null
|
|
621
|
-
: Object.fromEntries(Object.entries(analysis.layers).map(([name, layer]) => [
|
|
622
|
-
name,
|
|
623
|
-
{
|
|
624
|
-
status: layer.status,
|
|
625
|
-
finding: layer.finding,
|
|
626
|
-
confidence: layer.confidence,
|
|
627
|
-
},
|
|
628
|
-
])),
|
|
629
|
-
participants: (!usableAnalysis || analysis === null ? [] : analysis.participants).map((participant) => ({
|
|
630
|
-
participantId: participant.participantId,
|
|
631
|
-
status: participant.status,
|
|
632
|
-
finding: participant.finding,
|
|
633
|
-
confidence: participant.confidence,
|
|
634
|
-
audioTrackId: participant.audioTrackId,
|
|
635
|
-
videoTrackId: participant.videoTrackId,
|
|
636
|
-
metrics: participant.metrics,
|
|
637
|
-
})) ?? [],
|
|
638
|
-
limitations: [
|
|
639
|
-
...new Set([
|
|
640
|
-
...(!usableAnalysis || analysis === null ? [] : analysis.limitations),
|
|
641
|
-
...limitations,
|
|
642
|
-
...(!usableAnalysis && analysis !== null ? ["analysis-invalid"] : []),
|
|
643
|
-
]),
|
|
644
|
-
],
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
function emptyDetail() {
|
|
648
|
-
return {
|
|
649
|
-
projectionVersion: 2,
|
|
650
|
-
sourceRecordCount: 0,
|
|
651
|
-
reportedRecordCount: 0,
|
|
652
|
-
timeSyncInputCount: 0,
|
|
653
|
-
timeSyncReportedCount: 0,
|
|
654
|
-
framePresentationReportedCount: 0,
|
|
655
|
-
verifiedMetadataTimestampCount: 0,
|
|
656
|
-
omittedSetupLifecycleCount: 0,
|
|
657
|
-
oversizeFallbackRecordCount: 0,
|
|
658
|
-
contentByteLimit: EVIDENCE_CONTENT_BYTE_LIMIT,
|
|
659
|
-
chunks: [],
|
|
660
|
-
};
|
|
661
|
-
}
|
|
662
|
-
function compactLogs(logs, telemetry) {
|
|
663
|
-
const compacted = [];
|
|
664
|
-
const detail = emptyDetail();
|
|
665
|
-
detail.sourceRecordCount = logs.length;
|
|
666
|
-
const timeSyncBuckets = new Map();
|
|
667
|
-
for (const log of logs) {
|
|
668
|
-
if (log.eventName === "time-sync-updated") {
|
|
669
|
-
detail.timeSyncInputCount += 1;
|
|
670
|
-
const correlation = toRecord(log.correlation);
|
|
671
|
-
const key = [
|
|
672
|
-
correlation.participantId ?? "",
|
|
673
|
-
correlation.trackId ?? "",
|
|
674
|
-
correlation.mediaKind ?? "",
|
|
675
|
-
Math.floor(log.wallClockMs / TIME_SYNC_BUCKET_MS),
|
|
676
|
-
].join("|");
|
|
677
|
-
timeSyncBuckets.set(key, log);
|
|
678
|
-
continue;
|
|
770
|
+
return this._report(installation, signal, {
|
|
771
|
+
category: "media",
|
|
772
|
+
grade: payload.outcome === "first-frame" ? "Info" : "Warning",
|
|
773
|
+
content: payload,
|
|
774
|
+
timeout: 1,
|
|
775
|
+
}, `[LiveAvatar first-frame] ${payload.outcome}`);
|
|
679
776
|
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
compacted.sort(compareCompactLogs);
|
|
698
|
-
detail.reportedRecordCount = compacted.length;
|
|
699
|
-
return { logs: compacted, detail };
|
|
700
|
-
}
|
|
701
|
-
function compactMediaTimeline(value) {
|
|
702
|
-
const buckets = new Map();
|
|
703
|
-
for (const item of value) {
|
|
704
|
-
const record = toRecord(item);
|
|
705
|
-
const participantId = stringOr(record.participantId, "");
|
|
706
|
-
const videoTrackId = stringOr(record.videoTrackId, "");
|
|
707
|
-
const wallClock = numberOr(record.wallClock, 0);
|
|
708
|
-
buckets.set(`${participantId}|${videoTrackId}|${Math.floor(wallClock / TIME_SYNC_BUCKET_MS)}`, record);
|
|
777
|
+
if (!this._reporting.timeline)
|
|
778
|
+
return;
|
|
779
|
+
const payload = toTimeline(record);
|
|
780
|
+
if (!payload)
|
|
781
|
+
return;
|
|
782
|
+
return this._report(installation, signal, {
|
|
783
|
+
category: record.module,
|
|
784
|
+
grade: record.level === "warn"
|
|
785
|
+
? "Warning"
|
|
786
|
+
: record.level === "error"
|
|
787
|
+
? "Error"
|
|
788
|
+
: "Info",
|
|
789
|
+
content: payload,
|
|
790
|
+
...(["monitoring.session.ended", "client.disposed"].includes(record.event)
|
|
791
|
+
? { timeout: 1 }
|
|
792
|
+
: {}),
|
|
793
|
+
}, `[LiveAvatar SDK] ${record.event}`);
|
|
709
794
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
"normalizationStatus",
|
|
723
|
-
"normalizationGeneration",
|
|
724
|
-
"normalizationResetReason",
|
|
725
|
-
"pairingCoverage",
|
|
726
|
-
"validPairCount",
|
|
727
|
-
"relativeWindowSpanMs",
|
|
728
|
-
"relativeDriftMs",
|
|
729
|
-
"relativeDriftAvgMs",
|
|
730
|
-
"relativeDriftJitterMs",
|
|
731
|
-
"relativeDriftSlopeMsPerMinute",
|
|
732
|
-
"videoFrameId",
|
|
733
|
-
]),
|
|
734
|
-
}));
|
|
735
|
-
}
|
|
736
|
-
function compactDiagnoses(value) {
|
|
737
|
-
return value.map((item) => {
|
|
738
|
-
const record = toRecord(item);
|
|
739
|
-
return {
|
|
740
|
-
q: numberOr(record.seq, 0),
|
|
741
|
-
t: numberOr(record.wallClock, 0),
|
|
742
|
-
o: numberOr(record.perfNow, 0),
|
|
743
|
-
y: "diagnosis",
|
|
744
|
-
e: stringOr(record.status, "unknown"),
|
|
745
|
-
d: pick(record, [
|
|
746
|
-
"suspectedNode",
|
|
747
|
-
"responsibility",
|
|
748
|
-
"confidence",
|
|
749
|
-
"receiverIncident",
|
|
750
|
-
"normalizationStatus",
|
|
751
|
-
"normalizationGeneration",
|
|
752
|
-
"normalizationResetReason",
|
|
753
|
-
"pairingCoverage",
|
|
754
|
-
"relativeDriftMs",
|
|
755
|
-
"relativeDriftAvgMs",
|
|
756
|
-
"relativeDriftJitterMs",
|
|
757
|
-
"relativeDriftSlopeMsPerMinute",
|
|
758
|
-
"videoCaptureToDisplayRelativeMs",
|
|
759
|
-
]),
|
|
760
|
-
};
|
|
761
|
-
});
|
|
762
|
-
}
|
|
763
|
-
function compactSourceLog(log) {
|
|
764
|
-
if (log.eventName === "remote-media-capture-completed") {
|
|
765
|
-
const data = toRecord(log.data);
|
|
766
|
-
return compactLog(log, "capture", "completed", {
|
|
767
|
-
id: data.captureId,
|
|
768
|
-
status: data.captureStatus,
|
|
769
|
-
mode: data.captureMode,
|
|
770
|
-
durationMs: data.captureDurationMs,
|
|
771
|
-
pairCount: data.pairCount,
|
|
772
|
-
unpairedChannelCount: data.unpairedChannelCount,
|
|
773
|
-
channelGroupCount: data.channelGroupCount,
|
|
774
|
-
playback: compactPlayback(data.playback),
|
|
775
|
-
timeSync: compactTimeSyncSummary(data.timeSync),
|
|
795
|
+
_queueAlert(installation, record, signal) {
|
|
796
|
+
if (!record.correlation?.alertId ||
|
|
797
|
+
!["raised", "updated", "recovered"].includes(String(record.data?.phase)))
|
|
798
|
+
return;
|
|
799
|
+
if (installation.pending.length >= MAX_PENDING_ALERTS) {
|
|
800
|
+
installation.pending.shift();
|
|
801
|
+
this._warn("A/V reporting queue full; dropped oldest pending alert");
|
|
802
|
+
}
|
|
803
|
+
// The SDK freezes observer records; still take an independent synchronous copy.
|
|
804
|
+
installation.pending.push({
|
|
805
|
+
record: JSON.parse(JSON.stringify(record)),
|
|
806
|
+
signal,
|
|
776
807
|
});
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
if (log.eventName === "video-pipeline-stalled") {
|
|
783
|
-
return compactLog(log, "incident", "video-pipeline-stalled", toRecord(log.data));
|
|
784
|
-
}
|
|
785
|
-
if (log.logType === "connection") {
|
|
786
|
-
return compactLog(log, "connection", log.eventName, toRecord(log.data));
|
|
787
|
-
}
|
|
788
|
-
if (log.logType === "lifecycle" && isCausalLifecycleEvent(log.eventName)) {
|
|
789
|
-
return compactLog(log, "lifecycle", log.eventName, compactLifecycleDetails(toRecord(log.data)));
|
|
790
|
-
}
|
|
791
|
-
return null;
|
|
792
|
-
}
|
|
793
|
-
function compactTimeSyncLog(log) {
|
|
794
|
-
const data = toRecord(log.data);
|
|
795
|
-
return compactLog(log, "time-sync", "updated", {
|
|
796
|
-
receiverTimestampMs: data.receiverTimestampMs,
|
|
797
|
-
frameId: data.frameId,
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
function compactLog(log, type, event, data) {
|
|
801
|
-
return {
|
|
802
|
-
q: log.sequence,
|
|
803
|
-
t: log.wallClockMs,
|
|
804
|
-
o: log.observedAtMs,
|
|
805
|
-
y: type,
|
|
806
|
-
e: event,
|
|
807
|
-
...(Object.keys(compactCorrelation(toRecord(log.correlation))).length === 0
|
|
808
|
-
? {}
|
|
809
|
-
: { c: compactCorrelation(toRecord(log.correlation)) }),
|
|
810
|
-
...(data === undefined || Object.keys(data).length === 0
|
|
811
|
-
? {}
|
|
812
|
-
: { d: data }),
|
|
813
|
-
};
|
|
814
|
-
}
|
|
815
|
-
function compactCorrelation(correlation) {
|
|
816
|
-
return pick(correlation, [
|
|
817
|
-
"participantId",
|
|
818
|
-
"trackId",
|
|
819
|
-
"mediaKind",
|
|
820
|
-
"pairId",
|
|
821
|
-
"streamId",
|
|
822
|
-
"playbackTargetId",
|
|
823
|
-
"captureId",
|
|
824
|
-
]);
|
|
825
|
-
}
|
|
826
|
-
function compactReceiverData(data) {
|
|
827
|
-
return removeUndefined({
|
|
828
|
-
source: data.statsSource,
|
|
829
|
-
error: data.statsError,
|
|
830
|
-
delta: compactReceiverDelta(toRecord(data.delta)),
|
|
831
|
-
transport: compactTransport(toRecord(data.transport)),
|
|
832
|
-
computed: compactReceiverComputed(toRecord(data.computed)),
|
|
833
|
-
frameMetadata: compactFrameMetadata(toRecord(data.frameMetadata)),
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
function compactReceiverDelta(data) {
|
|
837
|
-
return pick(data, [
|
|
838
|
-
"intervalMs",
|
|
839
|
-
"packetsReceived",
|
|
840
|
-
"packetsLost",
|
|
841
|
-
"concealedSamples",
|
|
842
|
-
"concealmentEvents",
|
|
843
|
-
"framesReceived",
|
|
844
|
-
"framesDecoded",
|
|
845
|
-
"framesDropped",
|
|
846
|
-
"nackCount",
|
|
847
|
-
"pliCount",
|
|
848
|
-
"firCount",
|
|
849
|
-
"freezeCount",
|
|
850
|
-
"framesDecodedPerSecond",
|
|
851
|
-
]);
|
|
852
|
-
}
|
|
853
|
-
function compactReceiverComputed(data) {
|
|
854
|
-
return pick(data, [
|
|
855
|
-
"packetLossRate",
|
|
856
|
-
"jitterMs",
|
|
857
|
-
"audioConcealedSamplesPerSecond",
|
|
858
|
-
"audioConcealmentEventsPerSecond",
|
|
859
|
-
"videoDecodedFramesPerSecond",
|
|
860
|
-
"videoDroppedFramesPerSecond",
|
|
861
|
-
"videoDecodeRatio",
|
|
862
|
-
]);
|
|
863
|
-
}
|
|
864
|
-
function compactTransport(transport) {
|
|
865
|
-
return pick(transport, [
|
|
866
|
-
"iceState",
|
|
867
|
-
"candidatePairState",
|
|
868
|
-
"candidatePairWritable",
|
|
869
|
-
"currentRoundTripTimeSeconds",
|
|
870
|
-
]);
|
|
871
|
-
}
|
|
872
|
-
function compactPlayback(value) {
|
|
873
|
-
return compactLifecycleDetails(toRecord(value));
|
|
874
|
-
}
|
|
875
|
-
function compactTimeSyncSummary(value) {
|
|
876
|
-
const summary = toRecord(value);
|
|
877
|
-
const latest = Array.isArray(summary.latest)
|
|
878
|
-
? summary.latest.map((entry) => pick(toRecord(entry), [
|
|
879
|
-
"trackId",
|
|
880
|
-
"participantId",
|
|
881
|
-
"kind",
|
|
882
|
-
"observedAtMs",
|
|
883
|
-
"receiverTimestampMs",
|
|
884
|
-
"frameId",
|
|
885
|
-
]))
|
|
886
|
-
: [];
|
|
887
|
-
return removeUndefined({ status: summary.status, latest });
|
|
888
|
-
}
|
|
889
|
-
function isCausalLifecycleEvent(eventName) {
|
|
890
|
-
return [
|
|
891
|
-
"track-subscribed",
|
|
892
|
-
"track-validated",
|
|
893
|
-
"pair-bind-started",
|
|
894
|
-
"pair-bind-completed",
|
|
895
|
-
"pair-bind-failed",
|
|
896
|
-
"track-replaced",
|
|
897
|
-
"playback-snapshot",
|
|
898
|
-
"element-waiting",
|
|
899
|
-
"element-stalled",
|
|
900
|
-
"element-recovered",
|
|
901
|
-
"native-playing",
|
|
902
|
-
"video-first-frame-presented",
|
|
903
|
-
"element-error",
|
|
904
|
-
].includes(eventName);
|
|
905
|
-
}
|
|
906
|
-
function compactLifecycleDetails(details) {
|
|
907
|
-
return pick(details, [
|
|
908
|
-
"requiredMediaKinds",
|
|
909
|
-
"attachedMediaKind",
|
|
910
|
-
"attachedKinds",
|
|
911
|
-
"bindingGeneration",
|
|
912
|
-
"targetId",
|
|
913
|
-
"elementTag",
|
|
914
|
-
"elementRole",
|
|
915
|
-
"elementBindingId",
|
|
916
|
-
"elementBound",
|
|
917
|
-
"srcObjectType",
|
|
918
|
-
"streamBindingState",
|
|
919
|
-
"streamId",
|
|
920
|
-
"streamTrackCount",
|
|
921
|
-
"streamTrackKinds",
|
|
922
|
-
"activeAudioTrackId",
|
|
923
|
-
"activeAudioParticipantId",
|
|
924
|
-
"activeVideoTrackId",
|
|
925
|
-
"activeVideoParticipantId",
|
|
926
|
-
"readyState",
|
|
927
|
-
"networkState",
|
|
928
|
-
"paused",
|
|
929
|
-
"currentTime",
|
|
930
|
-
"playbackRate",
|
|
931
|
-
"width",
|
|
932
|
-
"height",
|
|
933
|
-
"videoWidth",
|
|
934
|
-
"videoHeight",
|
|
935
|
-
"eventSemantic",
|
|
936
|
-
"pairReady",
|
|
937
|
-
"pendingPairCommit",
|
|
938
|
-
"source",
|
|
939
|
-
"presentationObservedAtMs",
|
|
940
|
-
"presentedFrames",
|
|
941
|
-
"videoCurrentTime",
|
|
942
|
-
"videoReadyState",
|
|
943
|
-
"videoPaused",
|
|
944
|
-
"videoPlaybackRate",
|
|
945
|
-
"errorCode",
|
|
946
|
-
"errorMessage",
|
|
947
|
-
]);
|
|
948
|
-
}
|
|
949
|
-
function compactFrameMetadata(metadata) {
|
|
950
|
-
if (Object.keys(metadata).length === 0)
|
|
951
|
-
return null;
|
|
952
|
-
const lookup = toRecord(metadata.captureLookup);
|
|
953
|
-
const item = toRecord(lookup.metadata);
|
|
954
|
-
const verifiedTimestamp = verifiedCaptureTimestamp(lookup, item);
|
|
955
|
-
return removeUndefined({
|
|
956
|
-
analysisEnabled: metadata.analysisEnabled,
|
|
957
|
-
workerConfigured: metadata.workerConfigured,
|
|
958
|
-
featureStatus: metadata.featureStatus,
|
|
959
|
-
lookupStatus: lookup.status,
|
|
960
|
-
associationAgeMs: lookup.associationAgeMs,
|
|
961
|
-
frameId: item.frameId,
|
|
962
|
-
userTimestamp: item.userTimestamp,
|
|
963
|
-
userDataByteLength: item.userDataByteLength,
|
|
964
|
-
userDataIsTruncated: item.userDataIsTruncated,
|
|
965
|
-
timestampEncoding: verifiedTimestamp === null ? undefined : "ascii-decimal-unix-us",
|
|
966
|
-
timestampVerified: verifiedTimestamp !== null,
|
|
967
|
-
videoCaptureTimestampUs: verifiedTimestamp,
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
function verifiedCaptureTimestamp(lookup, metadata) {
|
|
971
|
-
if (lookup.status !== "available" ||
|
|
972
|
-
metadata.userDataIsTruncated === true ||
|
|
973
|
-
typeof lookup.rtpTimestamp !== "number" ||
|
|
974
|
-
typeof metadata.frameId !== "number" ||
|
|
975
|
-
typeof lookup.associationAgeMs !== "number" ||
|
|
976
|
-
lookup.associationAgeMs > FRAME_METADATA_MAX_ASSOCIATION_AGE_MS) {
|
|
977
|
-
return null;
|
|
978
|
-
}
|
|
979
|
-
return decodeAsciiDecimalBase64(typeof metadata.userDataBase64 === "string"
|
|
980
|
-
? metadata.userDataBase64
|
|
981
|
-
: null);
|
|
982
|
-
}
|
|
983
|
-
function compactVideoFrames(videoFrames) {
|
|
984
|
-
const buckets = new Map();
|
|
985
|
-
for (const frame of videoFrames) {
|
|
986
|
-
if (frame.videoCaptureTimestampUs === null &&
|
|
987
|
-
frame.videoCaptureToDisplayRelativeMs === null) {
|
|
988
|
-
continue;
|
|
808
|
+
if (!installation.draining) {
|
|
809
|
+
installation.draining = true;
|
|
810
|
+
queueMicrotask(() => {
|
|
811
|
+
void this._drainAlerts(installation);
|
|
812
|
+
});
|
|
989
813
|
}
|
|
990
|
-
buckets.set(`${frame.trackId}|${Math.floor(frame.wallClock / TIME_SYNC_BUCKET_MS)}`, frame);
|
|
991
814
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
timestampEncoding: frame.videoCaptureTimestampUs === null
|
|
1007
|
-
? undefined
|
|
1008
|
-
: "ascii-decimal-unix-us",
|
|
1009
|
-
timestampVerified: frame.videoCaptureTimestampUs !== null,
|
|
1010
|
-
videoCaptureTimestampUs: frame.videoCaptureTimestampUs,
|
|
1011
|
-
videoCaptureToDisplayRelativeMs: frame.videoCaptureToDisplayRelativeMs,
|
|
1012
|
-
}),
|
|
1013
|
-
};
|
|
1014
|
-
});
|
|
1015
|
-
return { logs, verifiedCount };
|
|
1016
|
-
}
|
|
1017
|
-
function chunkCompactLogs(logs, detail) {
|
|
1018
|
-
const chunks = [];
|
|
1019
|
-
let current = [];
|
|
1020
|
-
for (const log of logs) {
|
|
1021
|
-
if (utf8JsonByteLength([log]) > EVIDENCE_CONTENT_BYTE_LIMIT) {
|
|
1022
|
-
detail.oversizeFallbackRecordCount += 1;
|
|
1023
|
-
const fallback = {
|
|
1024
|
-
q: log.q,
|
|
1025
|
-
t: log.t,
|
|
1026
|
-
o: log.o,
|
|
1027
|
-
y: log.y,
|
|
1028
|
-
e: log.e,
|
|
1029
|
-
...(log.c === undefined ? {} : { c: log.c }),
|
|
1030
|
-
d: {
|
|
1031
|
-
projection: "oversize-fallback",
|
|
1032
|
-
projectedByteLength: utf8JsonByteLength(log),
|
|
1033
|
-
},
|
|
1034
|
-
};
|
|
1035
|
-
current = appendCompactLog(chunks, current, fallback);
|
|
1036
|
-
continue;
|
|
815
|
+
async _drainAlerts(installation) {
|
|
816
|
+
try {
|
|
817
|
+
while (installation.active && installation.pending.length) {
|
|
818
|
+
const task = installation.pending.shift();
|
|
819
|
+
if (!this._isActive(installation, task.signal))
|
|
820
|
+
continue;
|
|
821
|
+
try {
|
|
822
|
+
await this._reportAlert(installation, task.record, task.signal);
|
|
823
|
+
}
|
|
824
|
+
catch (error) {
|
|
825
|
+
if (this._isActive(installation, task.signal))
|
|
826
|
+
this._warn("Failed to handle A/V evidence", error);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
1037
829
|
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
if (current.length > 0)
|
|
1041
|
-
chunks.push(current);
|
|
1042
|
-
const manifest = chunks.map((chunk, index) => ({
|
|
1043
|
-
index,
|
|
1044
|
-
byteLength: utf8JsonByteLength(chunk),
|
|
1045
|
-
recordCount: chunk.length,
|
|
1046
|
-
firstSequence: chunk[0]?.q ?? null,
|
|
1047
|
-
lastSequence: chunk[chunk.length - 1]?.q ?? null,
|
|
1048
|
-
}));
|
|
1049
|
-
const finalDetail = {
|
|
1050
|
-
...detail,
|
|
1051
|
-
reportedRecordCount: chunks.reduce((count, chunk) => count + chunk.length, 0),
|
|
1052
|
-
chunks: manifest,
|
|
1053
|
-
};
|
|
1054
|
-
const result = {
|
|
1055
|
-
logChunkCount: chunks.length,
|
|
1056
|
-
logRecordCount: chunks.reduce((count, chunk) => count + chunk.length, 0),
|
|
1057
|
-
detail: finalDetail,
|
|
1058
|
-
};
|
|
1059
|
-
if (chunks[0] !== undefined)
|
|
1060
|
-
result.logs = chunks[0];
|
|
1061
|
-
for (let index = 1; index < chunks.length; index += 1) {
|
|
1062
|
-
const chunk = chunks[index];
|
|
1063
|
-
if (chunk !== undefined)
|
|
1064
|
-
result[`logs_${index}`] = chunk;
|
|
1065
|
-
}
|
|
1066
|
-
return result;
|
|
1067
|
-
}
|
|
1068
|
-
function appendCompactLog(chunks, current, log) {
|
|
1069
|
-
const candidate = [...current, log];
|
|
1070
|
-
if (current.length > 0 &&
|
|
1071
|
-
utf8JsonByteLength(candidate) > EVIDENCE_CONTENT_BYTE_LIMIT) {
|
|
1072
|
-
chunks.push(current);
|
|
1073
|
-
return [log];
|
|
1074
|
-
}
|
|
1075
|
-
return candidate;
|
|
1076
|
-
}
|
|
1077
|
-
function createEvidenceId() {
|
|
1078
|
-
return `avse_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1079
|
-
}
|
|
1080
|
-
function collectPreparedCompactLogs(evidence) {
|
|
1081
|
-
const logs = [];
|
|
1082
|
-
for (const chunk of evidence.detail.chunks ?? []) {
|
|
1083
|
-
const value = chunk.index === 0
|
|
1084
|
-
? evidence.logs
|
|
1085
|
-
: evidence[`logs_${chunk.index}`];
|
|
1086
|
-
if (value !== undefined)
|
|
1087
|
-
logs.push(...value);
|
|
1088
|
-
}
|
|
1089
|
-
return logs;
|
|
1090
|
-
}
|
|
1091
|
-
function createLogChunkPayloads(evidenceId, alertId, sessionId, logs) {
|
|
1092
|
-
const safeLogs = logs.map((log) => fitsInLogChunk(log, evidenceId, alertId, sessionId, logs.length)
|
|
1093
|
-
? log
|
|
1094
|
-
: fallbackCompactLog(log));
|
|
1095
|
-
const chunks = [];
|
|
1096
|
-
let current = [];
|
|
1097
|
-
const maximumTotal = Math.max(1, safeLogs.length);
|
|
1098
|
-
for (const log of safeLogs) {
|
|
1099
|
-
const candidate = [...current, log];
|
|
1100
|
-
if (current.length > 0 &&
|
|
1101
|
-
!logChunkFits(candidate, evidenceId, alertId, sessionId, safeLogs.length, maximumTotal)) {
|
|
1102
|
-
chunks.push(current);
|
|
1103
|
-
current = [log];
|
|
830
|
+
finally {
|
|
831
|
+
installation.draining = false;
|
|
1104
832
|
}
|
|
1105
|
-
|
|
1106
|
-
|
|
833
|
+
}
|
|
834
|
+
async _reportAlert(installation, alert, signal) {
|
|
835
|
+
const key = JSON.stringify([
|
|
836
|
+
alert.clientInstanceId,
|
|
837
|
+
alert.monitoringSessionId,
|
|
838
|
+
alert.avsyncSessionId,
|
|
839
|
+
alert.correlation.alertId,
|
|
840
|
+
]);
|
|
841
|
+
const phase = alert.data.phase;
|
|
842
|
+
const alertId = alert.correlation.alertId;
|
|
843
|
+
const state = installation.alertReportStates.get(key) ?? {};
|
|
844
|
+
if (phase === "recovered") {
|
|
845
|
+
const payload = {
|
|
846
|
+
...operationalSource(alert),
|
|
847
|
+
kind: "liveavatar.avsync.recovery",
|
|
848
|
+
schemaVersion: 4,
|
|
849
|
+
alertId,
|
|
850
|
+
recoveredAtWallClockMs: alert.occurredAtMs,
|
|
851
|
+
};
|
|
852
|
+
await this._report(installation, signal, { category: "avsync", grade: "Recovered", content: payload }, "[LiveAvatar A/V Sync] alert recovered");
|
|
853
|
+
installation.alertReportStates.delete(key);
|
|
854
|
+
return;
|
|
1107
855
|
}
|
|
1108
|
-
if (!
|
|
1109
|
-
|
|
856
|
+
if (!installation.diagnostics)
|
|
857
|
+
return;
|
|
858
|
+
installation.alertReportStates.set(key, state);
|
|
859
|
+
// Bound inactive alert bookkeeping as well as queued work.
|
|
860
|
+
if (installation.alertReportStates.size > MAX_PENDING_ALERTS)
|
|
861
|
+
installation.alertReportStates.delete(installation.alertReportStates.keys().next().value);
|
|
862
|
+
const now = Date.now();
|
|
863
|
+
const previous = state.lastSuccessfulToWallClockMs;
|
|
864
|
+
const range = phase === "raised" || previous === undefined
|
|
865
|
+
? { kind: "recent", durationMs: 30000 }
|
|
866
|
+
: {
|
|
867
|
+
kind: "wall-clock",
|
|
868
|
+
fromMs: Math.max(now - 30000, Math.min(previous + 1, now)),
|
|
869
|
+
toMs: now,
|
|
870
|
+
};
|
|
871
|
+
const active = () => this._isActive(installation, signal);
|
|
872
|
+
const evidence = await collectEvidence(installation.diagnostics, alert, range, active);
|
|
873
|
+
if (!evidence || !active())
|
|
874
|
+
return;
|
|
875
|
+
const evidenceId = typeof crypto !== "undefined" && typeof crypto.randomUUID === "function"
|
|
876
|
+
? crypto.randomUUID()
|
|
877
|
+
: `avse_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;
|
|
878
|
+
const { summary, chunks } = createEvidencePayloads(evidenceId, evidence);
|
|
879
|
+
if (!(await this._report(installation, signal, { category: "avsync", grade: "Warning", content: summary }, `[LiveAvatar A/V Sync] ${String(alert.data?.finding)}`)))
|
|
880
|
+
return;
|
|
881
|
+
for (const chunk of chunks) {
|
|
882
|
+
if (!(await this._report(installation, signal, { category: "avsync", grade: "Info", content: chunk }, `[LiveAvatar A/V Sync] evidence chunk ${chunk.chunk.index + 1}/${chunk.chunk.total}`)))
|
|
883
|
+
return;
|
|
1110
884
|
}
|
|
885
|
+
// A successful local handoff is not a server delivery acknowledgment.
|
|
886
|
+
if (evidence.completeness.complete)
|
|
887
|
+
state.lastSuccessfulToWallClockMs =
|
|
888
|
+
evidence.pages[0]?.page.requestedToWallClockMs;
|
|
1111
889
|
}
|
|
1112
|
-
if (current.length > 0)
|
|
1113
|
-
chunks.push(current);
|
|
1114
|
-
return chunks.map((chunk, index) => createLogChunkPayload(evidenceId, alertId, sessionId, chunk, index, chunks.length));
|
|
1115
|
-
}
|
|
1116
|
-
function fitsInLogChunk(log, evidenceId, alertId, sessionId, total) {
|
|
1117
|
-
return logChunkFits([log], evidenceId, alertId, sessionId, total, total);
|
|
1118
890
|
}
|
|
1119
|
-
function
|
|
1120
|
-
return (
|
|
1121
|
-
}
|
|
1122
|
-
function fallbackCompactLog(log) {
|
|
1123
|
-
return {
|
|
1124
|
-
q: log.q,
|
|
1125
|
-
t: log.t,
|
|
1126
|
-
o: log.o,
|
|
1127
|
-
y: log.y,
|
|
1128
|
-
e: log.e,
|
|
1129
|
-
d: {
|
|
1130
|
-
projection: "oversize-fallback",
|
|
1131
|
-
projectedByteLength: utf8JsonByteLength(log),
|
|
1132
|
-
},
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
function createLogChunkPayload(evidenceId, alertId, sessionId, logs, index, total) {
|
|
1136
|
-
return {
|
|
1137
|
-
schemaVersion: 1,
|
|
1138
|
-
kind: "liveavatar.avsync.alert-evidence",
|
|
1139
|
-
sdkVersion: liveavatarJsSdk.VERSION,
|
|
1140
|
-
recordType: "log-chunk",
|
|
1141
|
-
evidenceId,
|
|
1142
|
-
alertId,
|
|
1143
|
-
sessionId,
|
|
1144
|
-
chunk: {
|
|
1145
|
-
index,
|
|
1146
|
-
total,
|
|
1147
|
-
byteLength: utf8JsonByteLength(logs),
|
|
1148
|
-
recordCount: logs.length,
|
|
1149
|
-
firstSequence: logs[0]?.q ?? null,
|
|
1150
|
-
lastSequence: logs[logs.length - 1]?.q ?? null,
|
|
1151
|
-
logs,
|
|
1152
|
-
},
|
|
1153
|
-
};
|
|
1154
|
-
}
|
|
1155
|
-
function createSummaryPayload(evidenceId, alert, evidence, logChunkCount) {
|
|
1156
|
-
const summaryEvidence = withoutPreparedLogs(evidence, logChunkCount);
|
|
1157
|
-
const payload = {
|
|
1158
|
-
schemaVersion: 1,
|
|
1159
|
-
kind: "liveavatar.avsync.alert-evidence",
|
|
1160
|
-
sdkVersion: liveavatarJsSdk.VERSION,
|
|
1161
|
-
recordType: "summary",
|
|
1162
|
-
evidenceId,
|
|
1163
|
-
alert,
|
|
1164
|
-
evidence: summaryEvidence,
|
|
1165
|
-
};
|
|
1166
|
-
if (utf8JsonByteLength(payload) <= EVIDENCE_CONTENT_BYTE_LIMIT)
|
|
1167
|
-
return payload;
|
|
1168
|
-
const compactPayload = {
|
|
1169
|
-
...payload,
|
|
1170
|
-
summaryTruncated: true,
|
|
1171
|
-
alert: compactAlertForSummary(alert),
|
|
1172
|
-
evidence: {
|
|
1173
|
-
...summaryEvidence,
|
|
1174
|
-
retention: null,
|
|
1175
|
-
triage: {
|
|
1176
|
-
trigger: summaryEvidence.triage?.trigger ?? {
|
|
1177
|
-
finding: alert.finding,
|
|
1178
|
-
status: alert.status,
|
|
1179
|
-
confidence: alert.confidence,
|
|
1180
|
-
capturedAtMs: alert.capturedAtMs,
|
|
1181
|
-
},
|
|
1182
|
-
evaluation: null,
|
|
1183
|
-
layers: null,
|
|
1184
|
-
participants: [],
|
|
1185
|
-
limitations: ["summary-truncated"],
|
|
1186
|
-
},
|
|
1187
|
-
detail: {
|
|
1188
|
-
projectionVersion: summaryEvidence.detail.projectionVersion,
|
|
1189
|
-
sourceRecordCount: summaryEvidence.detail.sourceRecordCount,
|
|
1190
|
-
reportedRecordCount: summaryEvidence.logRecordCount,
|
|
1191
|
-
timeSyncInputCount: 0,
|
|
1192
|
-
timeSyncReportedCount: 0,
|
|
1193
|
-
framePresentationReportedCount: 0,
|
|
1194
|
-
verifiedMetadataTimestampCount: 0,
|
|
1195
|
-
omittedSetupLifecycleCount: 0,
|
|
1196
|
-
oversizeFallbackRecordCount: summaryEvidence.detail.oversizeFallbackRecordCount,
|
|
1197
|
-
contentByteLimit: EVIDENCE_CONTENT_BYTE_LIMIT,
|
|
1198
|
-
},
|
|
1199
|
-
},
|
|
1200
|
-
};
|
|
1201
|
-
if (utf8JsonByteLength(compactPayload) <= EVIDENCE_CONTENT_BYTE_LIMIT)
|
|
1202
|
-
return compactPayload;
|
|
1203
|
-
throw new Error("A/V Sync summary exceeds the platform content limit");
|
|
1204
|
-
}
|
|
1205
|
-
function compactAlertForSummary(alert) {
|
|
1206
|
-
return {
|
|
1207
|
-
...alert,
|
|
1208
|
-
participantIds: alert.participantIds.slice(0, 32),
|
|
1209
|
-
message: truncateUtf8String(alert.message, 1024),
|
|
1210
|
-
};
|
|
1211
|
-
}
|
|
1212
|
-
function truncateUtf8String(value, byteLimit) {
|
|
1213
|
-
if (new TextEncoder().encode(value).byteLength <= byteLimit)
|
|
1214
|
-
return value;
|
|
1215
|
-
let end = value.length;
|
|
1216
|
-
while (end > 0) {
|
|
1217
|
-
const candidate = `${value.slice(0, end)}…`;
|
|
1218
|
-
if (new TextEncoder().encode(candidate).byteLength <= byteLimit)
|
|
1219
|
-
return candidate;
|
|
1220
|
-
end -= 1;
|
|
1221
|
-
}
|
|
1222
|
-
return "";
|
|
1223
|
-
}
|
|
1224
|
-
function withoutPreparedLogs(evidence, logChunkCount) {
|
|
1225
|
-
const { logs: _logs, detail, ...rest } = evidence;
|
|
1226
|
-
const { chunks: _chunks, ...summaryDetail } = detail;
|
|
1227
|
-
const summary = Object.fromEntries(Object.entries(rest).filter(([key]) => !/^logs_\d+$/.test(key)));
|
|
1228
|
-
return {
|
|
1229
|
-
...summary,
|
|
1230
|
-
logChunkCount,
|
|
1231
|
-
detail: summaryDetail,
|
|
1232
|
-
};
|
|
1233
|
-
}
|
|
1234
|
-
function decodeAsciiDecimalBase64(value) {
|
|
1235
|
-
if (value === null)
|
|
1236
|
-
return null;
|
|
1237
|
-
try {
|
|
1238
|
-
const decoded = atob(value);
|
|
1239
|
-
if (!/^\d{16}$/.test(decoded))
|
|
1240
|
-
return null;
|
|
1241
|
-
const parsed = Number(decoded);
|
|
1242
|
-
return Number.isSafeInteger(parsed) ? decoded : null;
|
|
1243
|
-
}
|
|
1244
|
-
catch {
|
|
1245
|
-
return null;
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
function utf8JsonByteLength(value) {
|
|
1249
|
-
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
891
|
+
function createSkyWalkingPlugin(config = {}) {
|
|
892
|
+
return new SkyWalkingPlugin(config);
|
|
1250
893
|
}
|
|
1251
|
-
function
|
|
894
|
+
function object(value) {
|
|
1252
895
|
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
1253
896
|
? value
|
|
1254
897
|
: {};
|
|
1255
898
|
}
|
|
1256
|
-
function pick(source, keys) {
|
|
1257
|
-
const result = {};
|
|
1258
|
-
for (const key of keys) {
|
|
1259
|
-
if (source[key] !== undefined && source[key] !== null)
|
|
1260
|
-
result[key] = source[key];
|
|
1261
|
-
}
|
|
1262
|
-
return result;
|
|
1263
|
-
}
|
|
1264
|
-
function removeUndefined(value) {
|
|
1265
|
-
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined));
|
|
1266
|
-
}
|
|
1267
|
-
function numberOr(value, fallback) {
|
|
1268
|
-
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
1269
|
-
}
|
|
1270
|
-
function stringOr(value, fallback) {
|
|
1271
|
-
return typeof value === "string" ? value : fallback;
|
|
1272
|
-
}
|
|
1273
|
-
function compareSourceLogs(left, right) {
|
|
1274
|
-
return left.sequence - right.sequence;
|
|
1275
|
-
}
|
|
1276
|
-
function compareCompactLogs(left, right) {
|
|
1277
|
-
return left.q - right.q || left.o - right.o;
|
|
1278
|
-
}
|
|
1279
|
-
function toJsonSafeAlert(alert) {
|
|
1280
|
-
return {
|
|
1281
|
-
...alert,
|
|
1282
|
-
sessionId: alert.sessionId ?? null,
|
|
1283
|
-
participantIds: [...alert.participantIds],
|
|
1284
|
-
features: { ...alert.features },
|
|
1285
|
-
};
|
|
1286
|
-
}
|
|
1287
|
-
/**
|
|
1288
|
-
* Strictly projects the published first-frame Operational Log. The SDK record
|
|
1289
|
-
* has additional identifiers and arbitrary attributes; none of those can
|
|
1290
|
-
* reach SkyWalking through this path.
|
|
1291
|
-
*/
|
|
1292
899
|
function toSkyWalkingFirstFrameLogPayload(record) {
|
|
1293
|
-
const correlation =
|
|
1294
|
-
const attributes =
|
|
900
|
+
const correlation = object(record.correlation);
|
|
901
|
+
const attributes = object(record.data);
|
|
1295
902
|
const attemptId = correlation.attemptId;
|
|
1296
903
|
const outcome = attributes.outcome;
|
|
1297
904
|
if (!isNonNegativeNumber(record.occurredAtMs) ||
|
|
@@ -1299,7 +906,7 @@ function toSkyWalkingFirstFrameLogPayload(record) {
|
|
|
1299
906
|
!isFirstFrameOutcome(outcome)) {
|
|
1300
907
|
return undefined;
|
|
1301
908
|
}
|
|
1302
|
-
const sourceNodes =
|
|
909
|
+
const sourceNodes = object(attributes.nodes);
|
|
1303
910
|
const nodes = {};
|
|
1304
911
|
copyNonNegativeNumber(sourceNodes, "configReadyMs", nodes);
|
|
1305
912
|
copyNonNegativeNumber(sourceNodes, "rtcConnectedMs", nodes);
|
|
@@ -1307,10 +914,9 @@ function toSkyWalkingFirstFrameLogPayload(record) {
|
|
|
1307
914
|
copyNonNegativeNumber(sourceNodes, "videoMetadataMs", nodes);
|
|
1308
915
|
copyNonNegativeNumber(sourceNodes, "firstFrameMs", nodes);
|
|
1309
916
|
return {
|
|
1310
|
-
schemaVersion:
|
|
917
|
+
schemaVersion: 4,
|
|
1311
918
|
kind: "liveavatar.performance.first-frame",
|
|
1312
|
-
|
|
1313
|
-
occurredAtMs: record.occurredAtMs,
|
|
919
|
+
...operationalSource(record),
|
|
1314
920
|
attemptId,
|
|
1315
921
|
outcome,
|
|
1316
922
|
...(typeof attributes.renderMode === "string"
|
|
@@ -1338,18 +944,6 @@ function isPositiveInteger(value) {
|
|
|
1338
944
|
function isNonNegativeNumber(value) {
|
|
1339
945
|
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
1340
946
|
}
|
|
1341
|
-
function stringifyJson(value) {
|
|
1342
|
-
const serialized = JSON.stringify(value);
|
|
1343
|
-
if (serialized === undefined) {
|
|
1344
|
-
throw new Error("LiveAvatar SkyWalking payload serialization failed");
|
|
1345
|
-
}
|
|
1346
|
-
return serialized;
|
|
1347
|
-
}
|
|
1348
|
-
/**
|
|
1349
|
-
* Loads the bundled browser client when needed and registers it exactly once.
|
|
1350
|
-
* An application-provided `window.ClientMonitor` is treated as already
|
|
1351
|
-
* registered and is never overwritten or registered again.
|
|
1352
|
-
*/
|
|
1353
947
|
function registerSkyWalking(config = {}) {
|
|
1354
948
|
if (typeof window === "undefined") {
|
|
1355
949
|
warnOnce("register-unavailable", "[LiveAvatar SkyWalking plugin] SkyWalking registration requires a browser window");
|
|
@@ -1415,12 +1009,18 @@ async function reportSkyWalkingFrameErrors(config, error) {
|
|
|
1415
1009
|
function normalizeReportingConfig(config) {
|
|
1416
1010
|
return {
|
|
1417
1011
|
sdkError: config?.sdkError ?? true,
|
|
1012
|
+
timeline: config?.timeline ?? true,
|
|
1418
1013
|
firstFrame: config?.firstFrame ?? true,
|
|
1419
1014
|
avSync: config?.avSync ?? true,
|
|
1015
|
+
playbackStatus: config?.playbackStatus ?? true,
|
|
1420
1016
|
};
|
|
1421
1017
|
}
|
|
1422
1018
|
function hasEnabledReporting(config) {
|
|
1423
|
-
return config.sdkError ||
|
|
1019
|
+
return (config.sdkError ||
|
|
1020
|
+
config.firstFrame ||
|
|
1021
|
+
config.avSync ||
|
|
1022
|
+
config.timeline ||
|
|
1023
|
+
config.playbackStatus);
|
|
1424
1024
|
}
|
|
1425
1025
|
function normalizeSkyWalkingConfig(config) {
|
|
1426
1026
|
return {
|
|
@@ -1447,7 +1047,7 @@ function normalizeSkyWalkingConfig(config) {
|
|
|
1447
1047
|
extraMsg: config.extraMsg,
|
|
1448
1048
|
hooks: { ...config.hooks },
|
|
1449
1049
|
pagePath: config.pagePath ?? "",
|
|
1450
|
-
serviceVersion:
|
|
1050
|
+
serviceVersion: liveavatarJsSdk.VERSION,
|
|
1451
1051
|
pageKey: config.pageKey ?? "",
|
|
1452
1052
|
group: config.group ?? "unknown",
|
|
1453
1053
|
subGroup: config.subGroup ?? "unknown",
|