|
1 | | -import { convertIntegrationFnToClass, defineIntegration } from '@sentry/core'; |
2 | | -import type { Integration, IntegrationClass, IntegrationFn, WrappedFunction } from '@sentry/types'; |
| 1 | +import { defineIntegration } from '@sentry/core'; |
| 2 | +import type { IntegrationFn, WrappedFunction } from '@sentry/types'; |
3 | 3 | import { fill, getFunctionName, getOriginalFunction } from '@sentry/utils'; |
4 | 4 |
|
5 | 5 | import { WINDOW, wrap } from '../helpers'; |
@@ -38,19 +38,19 @@ const DEFAULT_EVENT_TARGET = [ |
38 | 38 | 'XMLHttpRequestUpload', |
39 | 39 | ]; |
40 | 40 |
|
41 | | -const INTEGRATION_NAME = 'TryCatch'; |
| 41 | +const INTEGRATION_NAME = 'BrowserApiErrors'; |
42 | 42 |
|
43 | 43 | type XMLHttpRequestProp = 'onload' | 'onerror' | 'onprogress' | 'onreadystatechange'; |
44 | 44 |
|
45 | | -interface TryCatchOptions { |
| 45 | +interface BrowserApiErrorsOptions { |
46 | 46 | setTimeout: boolean; |
47 | 47 | setInterval: boolean; |
48 | 48 | requestAnimationFrame: boolean; |
49 | 49 | XMLHttpRequest: boolean; |
50 | 50 | eventTarget: boolean | string[]; |
51 | 51 | } |
52 | 52 |
|
53 | | -const _browserApiErrorsIntegration = ((options: Partial<TryCatchOptions> = {}) => { |
| 53 | +const _browserApiErrorsIntegration = ((options: Partial<BrowserApiErrorsOptions> = {}) => { |
54 | 54 | const _options = { |
55 | 55 | XMLHttpRequest: true, |
56 | 56 | eventTarget: true, |
@@ -90,25 +90,10 @@ const _browserApiErrorsIntegration = ((options: Partial<TryCatchOptions> = {}) = |
90 | 90 | }; |
91 | 91 | }) satisfies IntegrationFn; |
92 | 92 |
|
93 | | -export const browserApiErrorsIntegration = defineIntegration(_browserApiErrorsIntegration); |
94 | | - |
95 | 93 | /** |
96 | 94 | * Wrap timer functions and event targets to catch errors and provide better meta data. |
97 | | - * @deprecated Use `browserApiErrorsIntegration()` instead. |
98 | 95 | */ |
99 | | -// eslint-disable-next-line deprecation/deprecation |
100 | | -export const TryCatch = convertIntegrationFnToClass( |
101 | | - INTEGRATION_NAME, |
102 | | - browserApiErrorsIntegration, |
103 | | -) as IntegrationClass<Integration> & { |
104 | | - new (options?: { |
105 | | - setTimeout: boolean; |
106 | | - setInterval: boolean; |
107 | | - requestAnimationFrame: boolean; |
108 | | - XMLHttpRequest: boolean; |
109 | | - eventTarget: boolean | string[]; |
110 | | - }): Integration; |
111 | | -}; |
| 96 | +export const browserApiErrorsIntegration = defineIntegration(_browserApiErrorsIntegration); |
112 | 97 |
|
113 | 98 | function _wrapTimeFunction(original: () => void): () => number { |
114 | 99 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
@@ -167,7 +152,7 @@ function _wrapXHR(originalSend: () => void): () => void { |
167 | 152 | }, |
168 | 153 | }; |
169 | 154 |
|
170 | | - // If Instrument integration has been called before TryCatch, get the name of original function |
| 155 | + // If Instrument integration has been called before BrowserApiErrors, get the name of original function |
171 | 156 | const originalFunction = getOriginalFunction(original); |
172 | 157 | if (originalFunction) { |
173 | 158 | wrapOptions.mechanism.data.handler = getFunctionName(originalFunction); |
|
0 commit comments