UNPKG

@embrace-io/web-sdk

Version:
3 lines (2 loc) 1.27 kB
import{__extends as e}from"tslib";import{EmbraceInstrumentationBase as n}from"../../EmbraceInstrumentationBase/EmbraceInstrumentationBase.js";var r=function(n){function r(e){var r=void 0===e?{}:e,o=r.diag,t=r.perf,i=n.call(this,{instrumentationName:"GlobalExceptionInstrumentation",instrumentationVersion:"1.0.0",diag:o,perf:t,config:{}})||this;return i._onErrorHandler=function(e){i.logManager.logException(e.error,{handled:!1,timestamp:i.perf.epochMillisFromOriginOffset(e.timeStamp)})},i._onUnhandledRejectionHandler=function(e){var n;e.reason&&e.reason instanceof Error?n=e.reason:(n=new Error("string"==typeof e.reason?e.reason:"Unhandled Rejected Promise")).stack="",i.logManager.logException(n,{handled:!1,timestamp:i.perf.epochMillisFromOriginOffset(e.timeStamp)})},i._config.enabled&&i.enable(),i}return e(r,n),r.prototype.disable=function(){window.removeEventListener("error",this._onErrorHandler),window.removeEventListener("unhandledrejection",this._onUnhandledRejectionHandler)},r.prototype.enable=function(){window.addEventListener("error",this._onErrorHandler),window.addEventListener("unhandledrejection",this._onUnhandledRejectionHandler)},r}(n);export{r as GlobalExceptionInstrumentation}; //# sourceMappingURL=GlobalExceptionInstrumentation.js.map