Method for achieving Script error monitoring and reporting
A technology for error and abnormal information, applied in hardware monitoring, instruments, electrical and digital data processing, etc., can solve the problem of lack of perfect monitoring mechanism, and achieve the effect of reducing losses
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0032] combined with figure 1 As shown, a method for realizing Script error monitoring and reporting includes:
[0033] Step S100: Capture exception information, which includes JS runtime errors, unhandled Promise errors, resource loading exception errors, and interface errors, specifically including:
[0034] Use window.onerror monitoring and function window.addEventListener('error') to capture JS runtime error types, where window.onerror contains detailed error information error.stack;
[0035] Use the function window.addEventListener('unhandledrejection') to capture unhandled promise errors;
[0036] Use window.addEventListener('error') to capture resource loading exception errors;
[0037] Capture global interface errors by encapsulating xmlHttpRequest or fetch functions.
[0038] Step S200: Report the captured abnormal information to the collection platform, including:
[0039] Step S210: When the abnormal information is captured, first construct an error object, and ...
Embodiment 2
[0046] On the basis of Embodiment 1, the step S230 specifically includes:
[0047] Step S231: Adding a crossorigin attribute to the script tag on the page. After adding the crossorigin attribute, the browser will automatically add an Origin field to the request header to initiate a cross-origin resource sharing request. Origin indicates the source of the request to the server, and the server will judge whether it responds normally according to the source;
[0048] Step S232: Add Access-Control-Allow-Origin to the response header to support cross-domain resource sharing. Access-Control-Allow-Origin: * indicates that the cross-domain request is passed, and the resource can be accessed by any site. And when the resource only allows cross-site requests from http: / / 127.0.0.1:8066, and other sites cannot cross-site access, it will be able to return;
[0049] Step S233: Vary:Origin needs to be included in the response header of Access-Control-Allow-Origin of the domain name. The ...
PUM
Login to View More Abstract
Description
Claims
Application Information
Login to View More 


