keeson-web-report-sdk 1.1.1 → 1.1.2
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/bundle.min.js +1 -1
- package/package.json +2 -2
package/bundle.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e
|
|
1
|
+
!function(o,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((o="undefined"!=typeof globalThis?globalThis:o||self).reportSdk={})}(this,function(o){"use strict";function e(o,e,t){return e&&function(o,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(o,i(n.key),n)}}(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),o}function t(o,e,t){return(e=i(e))in o?Object.defineProperty(o,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[e]=t,o}function n(o,e){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(o);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable})),t.push.apply(t,n)}return t}function r(o){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach(function(e){t(o,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(r,e))})}return o}function i(o){var e=function(o,e){if("object"!=typeof o||!o)return o;var t=o[Symbol.toPrimitive];if(void 0!==t){var n=t.call(o,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(o)}(o,"string");return"symbol"==typeof e?e:e+""}function s(o){var e=o.getEntries();console.log(e),e.forEach(function(o){if("paint"===o.entryType&&(console.log("-------------------------FP/FCP-------------------------"),console.log(o),"first-paint"===o.name&&console.log("白屏时间 (FP):",o.startTime,"毫秒"),"first-contentful-paint"===o.name&&console.log("首屏时间 (FCP):",o.startTime,"毫秒"),console.log("-------------------------FP/FCP-------------------------")),"largest-contentful-paint"===o.entryType&&(console.log("-------------------------lcp-------------------------"),console.log("LCP:",o.startTime,"ms"),console.log("-------------------------lcp-------------------------")),"first-input"===o.entryType&&(console.log("-------------------------fid-------------------------"),console.log("FID:",o.processingStart-o.startTime,"ms"),console.log("-------------------------fid-------------------------")),"layout-shift"!==o.entryType||o.hadRecentInput||(console.log("-------------------------cls-------------------------"),console.log("CLS:",o.value),console.log("is smaller than 0.1:",o.value<=.1),console.log("-------------------------cls-------------------------")),"navigation"===o.entryType){console.log("-------------------------navigation-------------------------");var e=o.domainLookupEnd-o.domainLookupStart;console.log("页面dnsTime",e);var t=o.responseEnd-o.startTime;console.log("页面请求耗时",t),console.log("-------------------------navigation-------------------------")}if("resource"===o.entryType){console.log("-------------------------资源请求-------------------------"),console.log("resource",o,"resource");var n=o.domainLookupEnd-o.domainLookupStart,r=o.responseEnd-o.requestStart,i=o.duration;console.log("dnsTime",n,"serverTime",r,"totalTime",i),console.log("-------------------------资源请求-------------------------")}if("longtask"===o.entryType){console.log("-------------------------长任务-------------------------"),console.log("longtask",o,"longtask");var s=o.duration-50;console.log("检测到长任务,总耗时: ".concat(o.duration," ms, 阻塞时间约: ").concat(s>0?s:0," ms"),o),console.log("-------------------------长任务-------------------------")}})}function l(o){var e=[];return e.push(function(o){var e=history.pushState,t=history.replaceState;history.pushState=function(){for(var t=window.location.href,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var s=e.apply(this,r),l=window.location.href;return t!==l&&o({to:l,from:t}),s},history.replaceState=function(){for(var e=window.location.href,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var s=t.apply(this,r),l=window.location.href;return e!==l&&o({to:l,from:e}),s};var n=function(){o({to:window.location.href,from:window.location.href})};return window.addEventListener("popstate",n),function(){window.removeEventListener("popstate",n),history.pushState=e,history.replaceState=t}}(o)),function(){e.forEach(function(o){return o()})}}var c,a={appId:"",reportUrl:"",env:"production",appUrl:window.location.origin,reportError:!0,reportPromiseReject:!0,reportVueError:!0,vueInstance:null,reportPerformance:!0,reportLongTimeRequest:!0,longTimeRequestThreshold:2e3,reportErrorReqest:!0,reportUserNavigate:!0},u=function(){return e(function o(e){!function(o,e){if(!(o instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),t(this,"records",[]),t(this,"timer",null),t(this,"options",{}),this.options=r(r({},a),e)},[{key:"init",value:function(){var o,e,t,n;if(this.options.reportError&&(o=function(o){var e=o.msg,t=o.url,n=o.line,r=o.col,i=o.error;console.log({msg:e,url:t,line:n,col:r,error:i})},window.onerror=function(e,t,n,r,i){o&&o({msg:e,url:t,line:n,col:r,error:i})}),this.options.reportPromiseReject&&function(o){window.addEventListener("unhandledrejection",function(e){o&&o(e)})}(function(o){console.log("Unhandled Promise Rejection:",o,o.reason)}),this.options.reportVueError&&this.options.vueInstance&&function(o,e){o.config.errorHandler=function(o,t,n){console.error("Error in ".concat(n,":"),o),e&&e({err:o,vm:t,info:n})}}(this.options.vueInstance,function(o){var e=o.err,t=o.vm,n=o.info;console.log("Vue error:",e,t,n)}),this.options.reportPerformance&&(window.onload=function(){if(console.log("window.onload"),window.PerformanceObserver){var o=new PerformanceObserver(s);console.log("supportedEntryTypes",PerformanceObserver.supportedEntryTypes),o.observe({entryTypes:["paint","largest-contentful-paint","first-input","layout-shift","navigation","resource","longtask"],buffered:!0})}window.performance&&(console.log("-----------------------------------"),s(window.performance),console.log("-----------------------------------"))}),this.options.reportLongTimeRequest&&(e=function(o){console.log(o)},t=function(o){console.log(o)},n=XMLHttpRequest.prototype.open,XMLHttpRequest.prototype.open=function(o,r,i,s,l){var c=Date.now();this.addEventListener("load",function(){var t=Date.now();e&&e({url:r,method:o,duration:t-c,status:this.status,statusText:this.statusText,response:this.responseText}),console.log("Response:",this.responseText)}),this.addEventListener("error",function(){console.log("Error:",this.statusText),t&&t({url:r,method:o,duration:duration,status:this.status,statusText:this.statusText,response:this.responseText})}),console.log("Request URL:",r),console.log("Request Method:",o),n.call(this,o,r,i,s,l)},function(o,e){var t=window.fetch;window.fetch=function(n,r){console.log("Fetch URL:",n),console.log("Fetch Options:",r),r&&r.headers&&(r.headers["X-Custom-Header"]="Value");var i=Date.now();return t(n,r).then(function(e){var t=Date.now();return o&&o({url:n,method:method,duration:t-i,status:e.status,statusText:e.statusText,response:e.responseText}),console.log("Response:",e),e}).catch(function(o){console.log("Error:",o),e&&e({url:n,method:method,duration:duration})})}}(function(o){console.log(o)},function(o){console.log(o)})),this.options.reportUserNavigate){var r=window.location.href;console.log("current href:",r),l(function(o){console.log("route change:",o)})}}},{key:"addReportRecord",value:function(o){var e=this;this.timer&&clearTimeout(this.timer),this.timer=setTimeout(function(){try{e.sendReport(JSON.parse(JSON.stringify(e.records))),e.records=[]}catch(o){console.log(o)}},1e3),this.records.push(o)}},{key:"sendReport",value:function(o){navigator.sendBeacon(this.options.reportUrl,JSON.stringify(o))}}])}();o.init=function(){c||(c=new u(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})),c.init()}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keeson-web-report-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "for web/h5",
|
|
5
5
|
"main": "bundle.min.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
17
17
|
"@rollup/plugin-terser": "^0.4.4",
|
|
18
18
|
"core-js": "^3.47.0",
|
|
19
|
+
"regenerator-runtime": "^0.14.1",
|
|
19
20
|
"rollup": "^4.55.1"
|
|
20
21
|
},
|
|
21
22
|
"files": [
|
|
22
23
|
"bundle.min.js"
|
|
23
24
|
],
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"regenerator-runtime": "^0.14.1"
|
|
26
26
|
}
|
|
27
27
|
}
|