spy-client 2.1.15 → 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.
Files changed (44) hide show
  1. package/.travis.yml +7 -4
  2. package/AGENTS.md +132 -0
  3. package/README.md +27 -19
  4. package/dist/head/base.d.ts +27 -26
  5. package/dist/head/error.d.ts +6 -6
  6. package/dist/head/observer.d.ts +5 -5
  7. package/dist/head/whitescreen.d.ts +6 -6
  8. package/dist/lib/data.d.ts +6 -6
  9. package/dist/lib/huffman.d.ts +9 -9
  10. package/dist/lib/interface.d.ts +209 -209
  11. package/dist/lib/spyHeadInterface.d.ts +36 -36
  12. package/dist/lib/util.d.ts +22 -22
  13. package/dist/module/fid.d.ts +15 -15
  14. package/dist/module/layoutShift.d.ts +18 -18
  15. package/dist/module/lcp.d.ts +17 -17
  16. package/dist/module/longtask.d.ts +46 -46
  17. package/dist/module/memory.d.ts +11 -11
  18. package/dist/module/navigatorInfo.d.ts +9 -9
  19. package/dist/module/resource.d.ts +39 -39
  20. package/dist/module/timing.d.ts +11 -11
  21. package/dist/module/tti.d.ts +19 -19
  22. package/dist/spy-client-basic.d.ts +118 -118
  23. package/dist/spy-client-basic.esm.js +298 -298
  24. package/dist/spy-client-basic.iife.js +298 -298
  25. package/dist/spy-client-basic.iife.min.js +1 -1
  26. package/dist/spy-client-basic.js +298 -298
  27. package/dist/spy-client-basic.min.js +1 -1
  28. package/dist/spy-client-basic.mjs +298 -298
  29. package/dist/spy-client.d.ts +32 -32
  30. package/dist/spy-client.esm.js +1430 -1423
  31. package/dist/spy-client.iife.js +1430 -1423
  32. package/dist/spy-client.iife.min.js +1 -1
  33. package/dist/spy-client.js +1430 -1423
  34. package/dist/spy-client.min.js +1 -1
  35. package/dist/spy-client.mjs +1430 -1423
  36. package/dist/spy-head.d.ts +6 -6
  37. package/dist/spy-head.js +359 -358
  38. package/dist/spy-head.min.js +1 -1
  39. package/dist/spy-local-cache.d.ts +18 -18
  40. package/dist/spy-local-cache.js +718 -711
  41. package/dist/spy-local-cache.min.js +1 -1
  42. package/package.json +26 -73
  43. package/test-results/.last-run.json +4 -0
  44. package/karma.conf.js +0 -111
@@ -1 +1 @@
1
- ((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(){function y(e){var n,r=(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),e=(r||((n=document.createElement("a")).href=e,r={protocol:n.protocol,host:n.host||location.host,pathname:n.pathname,ext:""}),r.pathname.split("."));return r.ext=e[e.length-1],r}function n(e){return+e.toFixed(1)}var E={conf:{},winerrors:[],errorDestroy:function(){},observerDestroy:function(){},entryMap:{},init:function(e){this.conf=e},update:function(e){this.conf=Object.assign(this.conf,e||{})},addError:function(e){if(0<this.winerrors.length){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,o=this.conf;e.type=e.type||"except",e.pid=o.pid,e.lid=o.lid,e.ts=Date.now(),this.addError(e),this.interceptor&&this.interceptor(e),!1!==n&&(r=r||o.logServer,n="".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&&(n+="&dim="+encodeURIComponent(JSON.stringify(e.dim))),(t=new Image).src=n,t.onload=t.onerror=function(){t=null})}};function r(e){var h=e.resourceError||{},l=e.jsError||{},m=Math.random()<(l.sample||0),g=Math.random()<(h.sample||0),w=E.winerrors,v=0;function n(e){try{var n=e.target,r={info:{},dim:{},group:""},t=r.info,o=e.srcElement;if(o===window){r.group=l.group;for(var i,s=e.error||e.reason||{},a=(t.msg=e.message||s.message||"",t.file=e.filename,t.ln=e.lineno,t.col=e.colno,t.stack=(s.stack||"").split("\n").slice(0,3).join("\n"),-1!==t.msg.indexOf("MODULE_TIMEOUT")&&(i=t.msg.match(/^.*Hang:(.*); Miss:(.*)/))&&i[2]&&(t.msg="MODULE_TIMEOUT for miss:"+i[2]),[]),c=0;c<w.length;c++){var d=w[c],f=1<d.info.count?"(".concat(d.info.count,")"):"";a.push(f+d.info.msg)}t.hisErrors=a.join("----");var p=!0;!1!==(p=l.handler?l.handler(r):p)&&E.send(r,m)}else{r.group=h.group,r.dim.type=o.tagName.toLowerCase();var u=o.src||o.href||"";-1<u.indexOf("/mwb2.gif?")||(t.msg=u||"unknown load eror",r.dim.host=y(u).host,n&&"IMG"===n.tagName&&(t.xpath=(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("<")}})(n).xpath),v&&(t.hisErrCount=v),!(p=!0)!==(p=h.handler?h.handler(r):p)&&E.send(r,g),v++)}}catch(e){console.error(e)}}window.addEventListener("error",n,!0),window.addEventListener("unhandledrejection",n,!0),E.errorDestroy=function(){window.removeEventListener("error",n,!0),window.removeEventListener("unhandledrejection",n,!0),E.winerrors=[]}}function t(e){var t=e.whiteScreenError||{},o=t.handler,i=t.selector,s=t.subSelector,e=t.timeout||6e3,a=Math.random()<(t.sample||0);function c(){var e;return!!window.performance&&(e={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)},"&wait=".concat(e.wait)+"&dns=".concat(e.dns)+"&connect=".concat(e.connect)+"&requestTime=".concat(e.req)+"&resoneTime=".concat(e.res))}i&&setTimeout(function(){var e,n,r;(r=document.querySelector(i))&&r.querySelector(s)&&!(r.clientHeight<2*window.innerHeight/3)||(r=!0,!((n={group:t.group,info:{msg:"",netTime:c(),hisErrors:(()=>{if(!E.winerrors)return!1;for(var e=E.winerrors,n=[],r=0;r<e.length;r++){var t=(e[r].info.stack||"").split("\n")[0];n.push("(".concat(r,")").concat(t||e[r].info.msg))}return n.join(";;")})(),deviceInfo:(e={},n=navigator.connection||{},e.downlink=n.downlink,e.effectiveType=n.effectiveType,e.rtt=n.rtt,e.deviceMemory=navigator.deviceMemory||0,e.hardwareConcurrency=navigator.hardwareConcurrency||0,e)}}).info.msg="WhiteScren Error")!==(r=o?o(n):r)&&n.info.msg&&E&&E.send(n,a))},e)}return E.init=function(e){if(e.logServer||(e.logServer="https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif"),r(this.conf=e),window.PerformanceObserver){var n=new window.PerformanceObserver(function(e){for(var n=E.entryMap,r=e.getEntries(),t=0;t<r.length;t++){var o=r[t];n[o.entryType]||(n[o.entryType]=[]),n[o.entryType].push(o)}});E.observerDestroy=function(){n.disconnect()};try{n.observe({entryTypes:["longtask","layout-shift","first-input","largest-contentful-paint"]})}catch(e){}}t(e)},window.__spyclientConf&&E.init(window.__spyclientConf),window.__spyHead=window.__spyHead||E,E});
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
+ }