Skip to content

Commit df9c05c

Browse files
committed
feat(v8/browser): Rename TryCatch integration to browserApiErrorsIntegration (#10755)
Resolves #8838 - Removes `TryCatch` integration class export - Updates angular to refer to browserApiErrorsIntegration by name instead of using `TryCatch`
1 parent 0433f2e commit df9c05c

File tree

13 files changed

+26
-42
lines changed

13 files changed

+26
-42
lines changed

dev-packages/browser-integration-tests/suites/public-api/debug/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ sentryTest('logs debug messages correctly', async ({ getLocalTestUrl, page }) =>
2525
? [
2626
'Sentry Logger [log]: Integration installed: InboundFilters',
2727
'Sentry Logger [log]: Integration installed: FunctionToString',
28-
'Sentry Logger [log]: Integration installed: TryCatch',
28+
'Sentry Logger [log]: Integration installed: BrowserApiErrors',
2929
'Sentry Logger [log]: Integration installed: Breadcrumbs',
3030
'Sentry Logger [log]: Global Handler attached: onerror',
3131
'Sentry Logger [log]: Global Handler attached: onunhandledrejection',

dev-packages/browser-integration-tests/suites/replay/captureReplay/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ sentryTest('should capture replays (@sentry/browser export)', async ({ getLocalT
4545
integrations: [
4646
'InboundFilters',
4747
'FunctionToString',
48-
'TryCatch',
48+
'BrowserApiErrors',
4949
'Breadcrumbs',
5050
'GlobalHandlers',
5151
'LinkedErrors',
@@ -82,7 +82,7 @@ sentryTest('should capture replays (@sentry/browser export)', async ({ getLocalT
8282
integrations: [
8383
'InboundFilters',
8484
'FunctionToString',
85-
'TryCatch',
85+
'BrowserApiErrors',
8686
'Breadcrumbs',
8787
'GlobalHandlers',
8888
'LinkedErrors',

dev-packages/browser-integration-tests/suites/replay/captureReplayFromReplayPackage/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ sentryTest('should capture replays (@sentry/replay export)', async ({ getLocalTe
4545
integrations: [
4646
'InboundFilters',
4747
'FunctionToString',
48-
'TryCatch',
48+
'BrowserApiErrors',
4949
'Breadcrumbs',
5050
'GlobalHandlers',
5151
'LinkedErrors',
@@ -82,7 +82,7 @@ sentryTest('should capture replays (@sentry/replay export)', async ({ getLocalTe
8282
integrations: [
8383
'InboundFilters',
8484
'FunctionToString',
85-
'TryCatch',
85+
'BrowserApiErrors',
8686
'Breadcrumbs',
8787
'GlobalHandlers',
8888
'LinkedErrors',

dev-packages/browser-integration-tests/utils/replayEventTemplates.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const DEFAULT_REPLAY_EVENT = {
1919
integrations: [
2020
'InboundFilters',
2121
'FunctionToString',
22-
'TryCatch',
22+
'BrowserApiErrors',
2323
'Breadcrumbs',
2424
'GlobalHandlers',
2525
'LinkedErrors',

packages/angular-ivy/src/sdk.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import { IS_DEBUG_BUILD } from './flags';
1111
*/
1212
export function init(options: BrowserOptions): void {
1313
const opts = {
14-
// Filter out TryCatch integration as it interferes with our Angular `ErrorHandler`:
15-
// TryCatch would catch certain errors before they reach the `ErrorHandler` and thus provide a
14+
// Filter out BrowserApiErrors integration as it interferes with our Angular `ErrorHandler`:
15+
// BrowserApiErrors would catch certain errors before they reach the `ErrorHandler` and thus provide a
1616
// lower fidelity error than what `SentryErrorHandler` (see errorhandler.ts) would provide.
1717
// see:
1818
// - https://github.com/getsentry/sentry-javascript/issues/5417#issuecomment-1453407097
1919
// - https://github.com/getsentry/sentry-javascript/issues/2744
2020
defaultIntegrations: getDefaultIntegrations(options).filter(integration => {
21-
return integration.name !== 'TryCatch';
21+
return integration.name !== 'BrowserApiErrors';
2222
}),
2323
...options,
2424
};

packages/angular/src/sdk.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import { IS_DEBUG_BUILD } from './flags';
1111
*/
1212
export function init(options: BrowserOptions): void {
1313
const opts = {
14-
// Filter out TryCatch integration as it interferes with our Angular `ErrorHandler`:
15-
// TryCatch would catch certain errors before they reach the `ErrorHandler` and thus provide a
14+
// Filter out BrowserApiErrors integration as it interferes with our Angular `ErrorHandler`:
15+
// BrowserApiErrors would catch certain errors before they reach the `ErrorHandler` and thus provide a
1616
// lower fidelity error than what `SentryErrorHandler` (see errorhandler.ts) would provide.
1717
// see:
1818
// - https://github.com/getsentry/sentry-javascript/issues/5417#issuecomment-1453407097
1919
// - https://github.com/getsentry/sentry-javascript/issues/2744
2020
defaultIntegrations: getDefaultIntegrations(options).filter(integration => {
21-
return integration.name !== 'TryCatch';
21+
return integration.name !== 'BrowserApiErrors';
2222
}),
2323
...options,
2424
};

packages/angular/test/sdk.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('init', () => {
1414
expect(setContextSpy).toHaveBeenCalledWith('angular', { version: 10 });
1515
});
1616

17-
describe('filtering out the `TryCatch` integration', () => {
17+
describe('filtering out the `BrowserApiErrors` integration', () => {
1818
const browserInitSpy = jest.spyOn(SentryBrowser, 'init');
1919

2020
beforeEach(() => {
@@ -27,7 +27,7 @@ describe('init', () => {
2727
expect(browserInitSpy).toHaveBeenCalledTimes(1);
2828

2929
const options = browserInitSpy.mock.calls[0][0] || {};
30-
expect(options.defaultIntegrations).not.toContainEqual(expect.objectContaining({ name: 'TryCatch' }));
30+
expect(options.defaultIntegrations).not.toContainEqual(expect.objectContaining({ name: 'BrowserApiErrors' }));
3131
});
3232

3333
it("doesn't filter if `defaultIntegrations` is set to `false`", () => {

packages/browser/src/exports.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export { dedupeIntegration } from './integrations/dedupe';
112112
export { globalHandlersIntegration } from './integrations/globalhandlers';
113113
export { httpContextIntegration } from './integrations/httpcontext';
114114
export { linkedErrorsIntegration } from './integrations/linkederrors';
115-
export { browserApiErrorsIntegration } from './integrations/trycatch';
115+
export { browserApiErrorsIntegration } from './integrations/browserapierrors';
116116

117117
// eslint-disable-next-line deprecation/deprecation
118-
export { TryCatch, Breadcrumbs, LinkedErrors, HttpContext, Dedupe } from './integrations';
118+
export { Breadcrumbs, LinkedErrors, HttpContext, Dedupe } from './integrations';

packages/browser/src/integrations/trycatch.ts renamed to packages/browser/src/integrations/browserapierrors.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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';
33
import { fill, getFunctionName, getOriginalFunction } from '@sentry/utils';
44

55
import { WINDOW, wrap } from '../helpers';
@@ -38,19 +38,19 @@ const DEFAULT_EVENT_TARGET = [
3838
'XMLHttpRequestUpload',
3939
];
4040

41-
const INTEGRATION_NAME = 'TryCatch';
41+
const INTEGRATION_NAME = 'BrowserApiErrors';
4242

4343
type XMLHttpRequestProp = 'onload' | 'onerror' | 'onprogress' | 'onreadystatechange';
4444

45-
interface TryCatchOptions {
45+
interface BrowserApiErrorsOptions {
4646
setTimeout: boolean;
4747
setInterval: boolean;
4848
requestAnimationFrame: boolean;
4949
XMLHttpRequest: boolean;
5050
eventTarget: boolean | string[];
5151
}
5252

53-
const _browserApiErrorsIntegration = ((options: Partial<TryCatchOptions> = {}) => {
53+
const _browserApiErrorsIntegration = ((options: Partial<BrowserApiErrorsOptions> = {}) => {
5454
const _options = {
5555
XMLHttpRequest: true,
5656
eventTarget: true,
@@ -90,25 +90,10 @@ const _browserApiErrorsIntegration = ((options: Partial<TryCatchOptions> = {}) =
9090
};
9191
}) satisfies IntegrationFn;
9292

93-
export const browserApiErrorsIntegration = defineIntegration(_browserApiErrorsIntegration);
94-
9593
/**
9694
* Wrap timer functions and event targets to catch errors and provide better meta data.
97-
* @deprecated Use `browserApiErrorsIntegration()` instead.
9895
*/
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);
11297

11398
function _wrapTimeFunction(original: () => void): () => number {
11499
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -167,7 +152,7 @@ function _wrapXHR(originalSend: () => void): () => void {
167152
},
168153
};
169154

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
171156
const originalFunction = getOriginalFunction(original);
172157
if (originalFunction) {
173158
wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);

packages/browser/src/integrations/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable deprecation/deprecation */
2-
export { TryCatch } from './trycatch';
32
export { Breadcrumbs } from './breadcrumbs';
43
export { LinkedErrors } from './linkederrors';
54
export { HttpContext } from './httpcontext';

packages/browser/src/sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import { BrowserClient } from './client';
2121
import { DEBUG_BUILD } from './debug-build';
2222
import { WINDOW, wrap as internalWrap } from './helpers';
2323
import { breadcrumbsIntegration } from './integrations/breadcrumbs';
24+
import { browserApiErrorsIntegration } from './integrations/browserapierrors';
2425
import { dedupeIntegration } from './integrations/dedupe';
2526
import { globalHandlersIntegration } from './integrations/globalhandlers';
2627
import { httpContextIntegration } from './integrations/httpcontext';
2728
import { linkedErrorsIntegration } from './integrations/linkederrors';
28-
import { browserApiErrorsIntegration } from './integrations/trycatch';
2929
import { defaultStackParser } from './stack-parsers';
3030
import { makeFetchTransport } from './transports/fetch';
3131

packages/replay/test/fixtures/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function Error(obj?: Event): any {
4141
integrations: [
4242
'InboundFilters',
4343
'FunctionToString',
44-
'TryCatch',
44+
'BrowserApiErrors',
4545
'Breadcrumbs',
4646
'GlobalHandlers',
4747
'LinkedErrors',

packages/replay/test/fixtures/transaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export function Transaction(traceId?: string, obj?: Partial<Event>): any {
249249
integrations: [
250250
'InboundFilters',
251251
'FunctionToString',
252-
'TryCatch',
252+
'BrowserApiErrors',
253253
'Breadcrumbs',
254254
'GlobalHandlers',
255255
'LinkedErrors',

0 commit comments

Comments
 (0)