package.build.cjs.instrument.globalUnhandledRejection.js.map Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of utils Show documentation
Show all versions of utils Show documentation
Utilities for all Sentry JavaScript SDKs
The newest version!
{"version":3,"file":"globalUnhandledRejection.js","sources":["../../../src/instrument/globalUnhandledRejection.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { HandlerDataUnhandledRejection } from '@sentry/types';\n\nimport { GLOBAL_OBJ } from '../worldwide';\nimport { addHandler, maybeInstrument, triggerHandlers } from './handlers';\n\nlet _oldOnUnhandledRejectionHandler: (typeof GLOBAL_OBJ)['onunhandledrejection'] | null = null;\n\n/**\n * Add an instrumentation handler for when an unhandled promise rejection is captured.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nexport function addGlobalUnhandledRejectionInstrumentationHandler(\n handler: (data: HandlerDataUnhandledRejection) => void,\n): void {\n const type = 'unhandledrejection';\n addHandler(type, handler);\n maybeInstrument(type, instrumentUnhandledRejection);\n}\n\nfunction instrumentUnhandledRejection(): void {\n _oldOnUnhandledRejectionHandler = GLOBAL_OBJ.onunhandledrejection;\n\n GLOBAL_OBJ.onunhandledrejection = function (e: any): boolean {\n const handlerData: HandlerDataUnhandledRejection = e;\n triggerHandlers('unhandledrejection', handlerData);\n\n if (_oldOnUnhandledRejectionHandler && !_oldOnUnhandledRejectionHandler.__SENTRY_LOADER__) {\n // eslint-disable-next-line prefer-rest-params\n return _oldOnUnhandledRejectionHandler.apply(this, arguments);\n }\n\n return true;\n };\n\n GLOBAL_OBJ.onunhandledrejection.__SENTRY_INSTRUMENTED__ = true;\n}\n"],"names":["addHandler","maybeInstrument","GLOBAL_OBJ","triggerHandlers"],"mappings":";;;;;AAOA,IAAI,+BAA+B,GAAuD,IAAI;;AAE9F;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iDAAiD;AACjE,EAAE,OAAO;AACT,EAAQ;AACR,EAAE,MAAM,IAAK,GAAE,oBAAoB;AACnC,EAAEA,mBAAU,CAAC,IAAI,EAAE,OAAO,CAAC;AAC3B,EAAEC,wBAAe,CAAC,IAAI,EAAE,4BAA4B,CAAC;AACrD;;AAEA,SAAS,4BAA4B,GAAS;AAC9C,EAAE,+BAAgC,GAAEC,oBAAU,CAAC,oBAAoB;;AAEnE,EAAEA,oBAAU,CAAC,oBAAqB,GAAE,UAAU,CAAC,EAAgB;AAC/D,IAAI,MAAM,WAAW,GAAkC,CAAC;AACxD,IAAIC,wBAAe,CAAC,oBAAoB,EAAE,WAAW,CAAC;;AAEtD,IAAI,IAAI,+BAAgC,IAAG,CAAC,+BAA+B,CAAC,iBAAiB,EAAE;AAC/F;AACA,MAAM,OAAO,+BAA+B,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC;AACnE;;AAEA,IAAI,OAAO,IAAI;AACf,GAAG;;AAEH,EAAED,oBAAU,CAAC,oBAAoB,CAAC,uBAAA,GAA0B,IAAI;AAChE;;;;"}