@embrace-io/web-sdk
Version:
3 lines (2 loc) • 1.14 kB
JavaScript
import{EmbraceInstrumentationBase as e}from"../../EmbraceInstrumentationBase/EmbraceInstrumentationBase.js";class n extends e{constructor({diag:e,perf:n}={}){super({instrumentationName:"GlobalExceptionInstrumentation",instrumentationVersion:"1.0.0",diag:e,perf:n,config:{}}),this._onErrorHandler=e=>{this.logManager.logException(e.error,{handled:!1,timestamp:this.perf.epochMillisFromOriginOffset(e.timeStamp)})},this._onUnhandledRejectionHandler=e=>{let n;e.reason&&e.reason instanceof Error?n=e.reason:(n=new Error("string"==typeof e.reason?e.reason:"Unhandled Rejected Promise"),n.stack=""),this.logManager.logException(n,{handled:!1,timestamp:this.perf.epochMillisFromOriginOffset(e.timeStamp)})},this._config.enabled&&this.enable()}disable(){window.removeEventListener("error",this._onErrorHandler),window.removeEventListener("unhandledrejection",this._onUnhandledRejectionHandler)}enable(){window.addEventListener("error",this._onErrorHandler),window.addEventListener("unhandledrejection",this._onUnhandledRejectionHandler)}}export{n as GlobalExceptionInstrumentation};
//# sourceMappingURL=GlobalExceptionInstrumentation.js.map