spy-client 2.1.14 → 2.2.1
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/.travis.yml +7 -4
- package/AGENTS.md +132 -0
- package/README.md +29 -18
- package/dist/head/base.d.ts +27 -25
- package/dist/head/error.d.ts +6 -6
- package/dist/head/observer.d.ts +5 -5
- package/dist/head/whitescreen.d.ts +6 -6
- package/dist/lib/data.d.ts +6 -6
- package/dist/lib/huffman.d.ts +9 -9
- package/dist/lib/interface.d.ts +209 -209
- package/dist/lib/spyHeadInterface.d.ts +36 -28
- package/dist/lib/util.d.ts +22 -22
- package/dist/module/fid.d.ts +15 -15
- package/dist/module/layoutShift.d.ts +18 -18
- package/dist/module/lcp.d.ts +17 -17
- package/dist/module/longtask.d.ts +46 -46
- package/dist/module/memory.d.ts +11 -11
- package/dist/module/navigatorInfo.d.ts +9 -9
- package/dist/module/resource.d.ts +39 -39
- package/dist/module/timing.d.ts +11 -11
- package/dist/module/tti.d.ts +19 -19
- package/dist/spy-client-basic.d.ts +118 -104
- package/dist/spy-client-basic.esm.js +298 -294
- package/dist/spy-client-basic.iife.js +298 -294
- package/dist/spy-client-basic.iife.min.js +1 -1
- package/dist/spy-client-basic.js +298 -294
- package/dist/spy-client-basic.min.js +1 -1
- package/dist/spy-client-basic.mjs +298 -294
- package/dist/spy-client.d.ts +32 -32
- package/dist/spy-client.esm.js +1430 -1419
- package/dist/spy-client.iife.js +1430 -1419
- package/dist/spy-client.iife.min.js +1 -1
- package/dist/spy-client.js +1430 -1419
- package/dist/spy-client.min.js +1 -1
- package/dist/spy-client.mjs +1430 -1419
- package/dist/spy-head.d.ts +6 -6
- package/dist/spy-head.js +359 -355
- package/dist/spy-head.min.js +1 -1
- package/dist/spy-local-cache.d.ts +18 -18
- package/dist/spy-local-cache.js +718 -711
- package/dist/spy-local-cache.min.js +1 -1
- package/package.json +26 -73
- package/test-results/.last-run.json +4 -0
- package/karma.conf.js +0 -111
package/dist/spy-head.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).__spyHead=n()}(this,function(){"use strict";function e(e){var n=function(e){if(URL&&e)try{var n=new URL(e);if(void 0!==n.host)return{protocol:n.protocol,host:n.host,pathname:n.pathname,ext:""}}catch(e){console.error(e)}}(e);if(!n){var r=document.createElement("a");r.href=e,n={protocol:r.protocol,host:r.host||location.host,pathname:r.pathname,ext:""}}var t=n.pathname.split(".");return n.ext=t[t.length-1],n}function n(e){return+e.toFixed(1)}var r={conf:{},winerrors:[],errorDestroy:function(){},observerDestroy:function(){},entryMap:{},interceptor:void 0,init:function(e){this.conf=e},update:function(e){this.conf=Object.assign(this.conf,e||{})},addError:function(e){if(this.winerrors.length>0){var n=this.winerrors[this.winerrors.length-1];if(e.info.msg===n.info.msg)return void(n.info.count+=n.info.count||0)}this.winerrors.length<1e3&&this.winerrors.push(e)},send:function(e,n,r){var t=this.conf;if(e.type=e.type||"except",e.pid=t.pid,e.lid=t.lid,e.ts=Date.now(),this.addError(e),this.interceptor&&this.interceptor(e),!1!==n){r=r||t.logServer;var o="".concat(r,"?pid=").concat(e.pid,"&lid=").concat(e.lid,"&ts=").concat(e.ts)+"&type=".concat(e.type,"&group=").concat(e.group,"&info=").concat(encodeURIComponent(JSON.stringify(e.info)));e.dim&&(o+="&dim="+encodeURIComponent(JSON.stringify(e.dim)));var i=new Image;i.src=o,i.onload=i.onerror=function(){i=null}}}};function t(n){var t=n.resourceError||{},o=n.jsError||{},i=Math.random()<(o.sample?o.sample:0),a=Math.random()<(t.sample?t.sample:0),s=r.winerrors,c=0;function d(n){try{var d=n.target,f={info:{},dim:{},group:""},u=f.info,p=n.srcElement;if(p===window){f.group=o.group;var l=n.error||n.reason||{};if(u.msg=n.message||l.message||"",u.file=n.filename,u.ln=n.lineno,u.col=n.colno,u.stack=(l.stack||"").split("\n").slice(0,3).join("\n"),-1!==u.msg.indexOf("MODULE_TIMEOUT")){var h=u.msg.match(/^.*Hang:(.*); Miss:(.*)/);h&&h[2]&&(u.msg="MODULE_TIMEOUT for miss:"+h[2])}for(var m=[],g=0;g<s.length;g++){var v=s[g],w=v.info.count>1?"(".concat(v.info.count,")"):"";m.push(w+v.info.msg)}u.hisErrors=m.join("----");var y=!0;o.handler&&(y=o.handler(f)),!1!==y&&r.send(f,i)}else{f.group=t.group,f.dim.type=p.tagName.toLowerCase();var E=p.src||p.href||"";if(E.indexOf("/mwb2.gif?")>-1)return;u.msg=E||"unknown load eror",f.dim.host=e(E).host,d&&"IMG"===d.tagName&&(u.xpath=function(e){if(!e)return{xpath:""};for(var n=[];e&&1===e.nodeType&&e!==e.parentNode;){var r=e.tagName.toLowerCase();if(e.getAttribute("id")?r+="[#"+e.getAttribute("id")+"]":e.classList&&e.classList.length&&(r+="[."+e.classList[e.classList.length-1]+"]"),n.push(r),e===document.body)break;e=e.parentNode}return{xpath:n.join("<")}}(d).xpath),c&&(u.hisErrCount=c);y=!0;t.handler&&(y=t.handler(f)),!1!==y&&r.send(f,a),c++}}catch(e){console.error(e)}}window.addEventListener("error",d,!0),window.addEventListener("unhandledrejection",d,!0),r.errorDestroy=function(){window.removeEventListener("error",d,!0),window.removeEventListener("unhandledrejection",d,!0),r.winerrors=[]}}function o(e){var t=e.whiteScreenError||{},o=t.handler,i=t.selector,a=t.subSelector,s=t.timeout||6e3,c=Math.random()<(t.sample?t.sample:0);function d(){if(!window.performance)return!1;var e,r={wait:n((e=window.performance.timing).domainLookupStart-(e.navigationStart||e.fetchStart||e.startTime)),dns:n(e.domainLookupEnd-e.domainLookupStart),connect:n(e.connectEnd-e.connectStart),req:n(e.responseStart-e.requestStart),res:n(e.responseEnd-e.responseStart)};return"&wait=".concat(r.wait)+"&dns=".concat(r.dns)+"&connect=".concat(r.connect)+"&requestTime=".concat(r.req)+"&resoneTime=".concat(r.res)}function f(){if(!r.winerrors)return!1;for(var e=r.winerrors,n=[],t=0;t<e.length;t++){var o=(e[t].info.stack||"").split("\n")[0];n.push("(".concat(t,")").concat(o||e[t].info.msg))}return n.join(";;")}i&&setTimeout(function(){if(!(p=document.querySelector(i))||!p.querySelector(a)||p.clientHeight<2*window.innerHeight/3){var e={group:t.group,info:{msg:"",netTime:d(),hisErrors:f(),deviceInfo:(s={},u=navigator.connection||{},s.downlink=u.downlink,s.effectiveType=u.effectiveType,s.rtt=u.rtt,s.deviceMemory=navigator.deviceMemory||0,s.hardwareConcurrency=navigator.hardwareConcurrency||0,s)}};e.info.msg="WhiteScren Error";var n=!0;o&&(n=o(e)),!1!==n&&e.info.msg&&r&&r.send(e,c)}var s,u,p},s)}return r.init=function(e){e.logServer||(e.logServer="https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif"),this.conf=e,t(e),function(){if(window.PerformanceObserver){var e=new window.PerformanceObserver(function(e){for(var n=r.entryMap,t=e.getEntries(),o=0;o<t.length;o++){var i=t[o];n[i.entryType]||(n[i.entryType]=[]),n[i.entryType].push(i)}});r.observerDestroy=function(){e.disconnect()};try{e.observe({entryTypes:["longtask","layout-shift","first-input","largest-contentful-paint"]})}catch(e){}}}(),o(e)},window.__spyclientConf&&r.init(window.__spyclientConf),window.__spyHead=window.__spyHead||r,r});
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export default class SpyLocalCache {
|
|
2
|
-
private readonly option;
|
|
3
|
-
private storage;
|
|
4
|
-
private timer;
|
|
5
|
-
private tmpList;
|
|
6
|
-
constructor(option?: any);
|
|
7
|
-
init(): void;
|
|
8
|
-
load(): void;
|
|
9
|
-
addLog(info: any): void;
|
|
10
|
-
getData(cb: any): void;
|
|
11
|
-
save(): void;
|
|
12
|
-
flushLog(): void;
|
|
13
|
-
zip(str: string): {
|
|
14
|
-
codes: any;
|
|
15
|
-
result: string;
|
|
16
|
-
};
|
|
17
|
-
unzip(str: string, codes?: any): string;
|
|
18
|
-
}
|
|
1
|
+
export default class SpyLocalCache {
|
|
2
|
+
private readonly option;
|
|
3
|
+
private storage;
|
|
4
|
+
private timer;
|
|
5
|
+
private tmpList;
|
|
6
|
+
constructor(option?: any);
|
|
7
|
+
init(): void;
|
|
8
|
+
load(): void;
|
|
9
|
+
addLog(info: any): void;
|
|
10
|
+
getData(cb: any): void;
|
|
11
|
+
save(): void;
|
|
12
|
+
flushLog(): void;
|
|
13
|
+
zip(str: string): {
|
|
14
|
+
codes: any;
|
|
15
|
+
result: string;
|
|
16
|
+
};
|
|
17
|
+
unzip(str: string, codes?: any): string;
|
|
18
|
+
}
|