A front-end monitoring tool that includes functions such as monitoring errors, monitoring first screen performance, collecting device information and monitoring network status.
-
Collects and reports errors generated by the front-end and supports the capture of cross-domain Javascript file errors.
E.g. JavaScript, Promise, Resource, Vue type errors
-
Support for reporting first screen performance and loading status of page resources, calculating data on multiple key performance nodes for page performance optimisation reference.
E.g. First byte, first interactable time, page load completion time, time taken to parse dom tree...
-
Provide device information for the runtime environment based on the above functions.
E.g. Model, network environment, browser information, resolution...
-
Support for reporting
console
custom type output messages. -
Support for reporting the current page speed at custom intervals.
The error message can be reported to the server and the stack information can be parsed with sourcemap to locate the error in the original file, making it easier to resolve the error in the project.
See specific examples of use:zephyr-monitor-use-demo
npm install zephyr-monitor
cnpm install zephyr-monitor -S
yarn add zephyr-monitor
git clone git@github.com:ZephyrAndMoon/zephyr-monitor.git
npm install / cnpm install / yarn
npm run build
# The packaged file will be output as: dist/ZephyrMonitor.min.js
<!-- <script> import -->
<script src="ZephyrMonitor.min.js"></script>
// ES module
import ZephyrMonitor from "zephyr-monitor";
// CommonJS
const ZephyrMonitor = require("zephyr-monitor");
// Initialize the basic configuration of the tool
const ZM = new ZephyrMonitor({
pageId:"" // page ID
})
// Error monitoring initialization
ZM.initError({
url:"", // report url
});
// Page performance monitoring initialization
ZM.initPerformance({
url:"", // report url
useNetworkSpeed:true, // Timed interval reporting of network speed, default false
});
-
pageId
String(require)
Page ID
-
useLogger
Boolean
-
Enable console log output
-
Default on, set to
false
if you need to turn it off
-
-
useCrossorigin
Boolean
Positioning of error messages for error reporting in cross-domain JavaScript files
-
url
String(require)
Report url
-
reportMethod
Object
Reporting method, default XHR upload (If more than one sub-parameter is passed in, the default order is Img - Fetch - Beacon - XHR)
reportMethod.useImg: Boolean
defaultfalse
,upload using Img tagsreportMethod.useFetch: Boolean
defaultfalse
,upload using the Fetch methodreportMethod.useBeacon: Boolean
defaultfalse
,upload using the Beacon method
-
error
Object
Error types to catch, default JavaScript type、 resource type、 Promise type errors
error.vue: Boolean
defaultfalse
,catching Vue type errorserror.console: Boolean
defaultfalse
,capture printout type logerror.js: Boolean
defaulttrue
,catching Javascript type errorserror.resource: Boolean
defaulttrue
,catching resource load type errorserror.promise: Boolean
defaulttrue
,catching Promise type errors
-
vue
VueConstructor
To enable Vue type error catching you need to pass in the introduced Vue
import Vue from "vue"; ZephyrMonitor.initError({ // ... vue: Vue, });
-
extendsInfo
String
Customised extension information
-
url
String(require)
Report url
-
usePerf
Boolean
Enable page performance monitoring, default
true
-
useResource
Boolean
Enable resource load monitoring, default
true
-
usefulResourceType
Object
The monitored resource type, default
script/css/fetch/xmlhttprequest/link/img
usefulResourceType.useRScript: Boolean
defaultfalse
,monitoring the loading ofscript
tag type resourcesusefulResourceType.useRCSS: Boolean
defaultfalse
,monitoring the loading ofcss
tag type resourcesusefulResourceType.useRLink: Boolean
defaultfalse
,monitoring the loading oflink
tag type resourcesusefulResourceType.useRImg: Boolean
defaultfalse
,monitoring the loading ofImg
tag type resourcesusefulResourceType.useRFetch: Boolean
defaultfalse
,monitoring the loading of resources fetched byFetch
usefulResourceType.useRXHR: Boolean
defaultfalse
,monitoring the loading of resources fetched byXHR
-
reportMethod
Object
Same as in
FrontEndMonitor.initError
-
useNetworkSpeed
Boolean
Enable timed speed information reporting, default
false
, interval is60s
-
timeInterval
Number
Interval for reporting network speed information
{
pageId: String, // Page ID
time: String, // The time when the error occurred
category: String, // Type of error
logType: String, // Type of information
logInfo: {
url: String, // The url where the error occurred
stack: String, // Error stack(unanalysed)
errorInfo: String, // Error message
otherInfo: Object // Other information
},
deviceInfo: Object, // Device information, as described under "Equipment information objects" below
extendsInfo: Object // Customised extension information
}
{
pageId: String, // Page ID
time: String, // The time when the error occurred
markUser: String, // User identification
markUv: String, // Unique Visitor
deviceInfo: Object, // Device information, as described under "Equipment information objects" below
performance: {
analysisTime: String, // Time consumed by parsing dom trees
blankTime: String, // Time consumed by white screen
dnsCacheTime: String, // Time consumed by DNS query cache
dnsTime: String, // Time consumed by DNS query
domReadyTime: String, // Time consumed for dom loading to complete
firstInteractTime: String, // Time consumed for the first interactable
pageLoadedTime: String, // Time consumed for page load completion
redirectTime: String, // Time consumed by redirects
resTime: String, // Time consumed by data transfer
tcpTime: String, // Time consumed by tcp connections
ttfbTime: String, // First Byte Duration
unloadTime: String, // Time consumed to unload the page
},
resource:[
{
dnsTime: String, // Time consumed by DNS query
initiatorType: String, // Type of resource requested
name: String, // The path to the requested resource or the name of the resource
nextHopProtocol: String, // http protocol version
redirectTime: String, // Time consumed by redirects
reqTotalTime: String, // Time consumed by requests and responses
responseTime: String, // Time consumed to receive a response
tcpTime: String, // Time consumed by tcp connections
ttfbTime: String, // First Byte Duration
}
]
}
{
pageId: String, // Page ID
time: String, // Record time
category: String, // Type of log
logType: String, // Type of information
networkSpeed: String, // Network speed
deviceInfo: Object, // Device information, as described under "Equipment information objects" below
extendsInfo: Object // Customised extension information
}
{
deviceType: String, // Type of device
browserInfo: {
name: String, // Browser name
version: String, // Browser version
},
engineInfo: {
name: String, // Engine name
version: String, // Engine version
},
detailInfo: { // This information is null when deviceType is PC
vendor: Boolean, // device brands
model: String, // device model
type: String, // device type
},
OSInfo:{
name: String, // OS name
version: String, // OS version
},
fingerprint: String, // Browser fingerprint
language: String, // Current language
netWork: String, // Network Status
orientation: String, // Horizontal and vertical screen status
screenHeight: Number, // Height of device
screenWidth: Number, // Width of device
userAgent: String // User Agent