|
1 | 1 | import { convertIntegrationFnToClass } from '@sentry/core'; |
2 | | -import type { IntegrationFn, WrappedFunction } from '@sentry/types'; |
| 2 | +import type { Integration, IntegrationClass, IntegrationFn, WrappedFunction } from '@sentry/types'; |
3 | 3 | import { fill, getFunctionName, getOriginalFunction } from '@sentry/utils'; |
4 | 4 |
|
5 | 5 | import { WINDOW, wrap } from '../helpers'; |
@@ -50,7 +50,7 @@ interface TryCatchOptions { |
50 | 50 | eventTarget: boolean | string[]; |
51 | 51 | } |
52 | 52 |
|
53 | | -const tryCatchIntegration: IntegrationFn = (options: Partial<TryCatchOptions> = {}) => { |
| 53 | +const browserApiErrorsIntegration = ((options: Partial<TryCatchOptions> = {}) => { |
54 | 54 | const _options = { |
55 | 55 | XMLHttpRequest: true, |
56 | 56 | eventTarget: true, |
@@ -88,11 +88,22 @@ const tryCatchIntegration: IntegrationFn = (options: Partial<TryCatchOptions> = |
88 | 88 | } |
89 | 89 | }, |
90 | 90 | }; |
91 | | -}; |
| 91 | +}) satisfies IntegrationFn; |
92 | 92 |
|
93 | 93 | /** Wrap timer functions and event targets to catch errors and provide better meta data */ |
94 | 94 | // eslint-disable-next-line deprecation/deprecation |
95 | | -export const TryCatch = convertIntegrationFnToClass(INTEGRATION_NAME, tryCatchIntegration); |
| 95 | +export const TryCatch = convertIntegrationFnToClass( |
| 96 | + INTEGRATION_NAME, |
| 97 | + browserApiErrorsIntegration, |
| 98 | +) as IntegrationClass<Integration> & { |
| 99 | + new (options?: { |
| 100 | + setTimeout: boolean; |
| 101 | + setInterval: boolean; |
| 102 | + requestAnimationFrame: boolean; |
| 103 | + XMLHttpRequest: boolean; |
| 104 | + eventTarget: boolean | string[]; |
| 105 | + }): Integration; |
| 106 | +}; |
96 | 107 |
|
97 | 108 | function _wrapTimeFunction(original: () => void): () => number { |
98 | 109 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
0 commit comments