Skip to content

Commit 6add689

Browse files
committed
ref(angular): Don't include BrowserApiErrors in bundle
1 parent 8f4f3d8 commit 6add689

File tree

2 files changed

+39
-12
lines changed

2 files changed

+39
-12
lines changed

packages/angular/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export type { ErrorHandlerOptions } from './errorhandler';
22

33
export * from '@sentry/browser';
44

5-
export { init } from './sdk';
5+
export { init, getDefaultIntegrations } from './sdk';
66
export { createErrorHandler, SentryErrorHandler } from './errorhandler';
77
export {
88
browserTracingIntegration,

packages/angular/src/sdk.ts

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,52 @@
11
import { VERSION } from '@angular/core';
22
import type { BrowserOptions } from '@sentry/browser';
3-
import { getDefaultIntegrations, init as browserInit, setContext } from '@sentry/browser';
4-
import { applySdkMetadata } from '@sentry/core';
3+
import {
4+
breadcrumbsIntegration,
5+
globalHandlersIntegration,
6+
httpContextIntegration,
7+
linkedErrorsIntegration,
8+
} from '@sentry/browser';
9+
import { init as browserInit, setContext } from '@sentry/browser';
10+
import {
11+
applySdkMetadata,
12+
dedupeIntegration,
13+
functionToStringIntegration,
14+
inboundFiltersIntegration,
15+
} from '@sentry/core';
16+
import type { Integration } from '@sentry/types';
517
import { logger } from '@sentry/utils';
618

719
import { IS_DEBUG_BUILD } from './flags';
820

21+
/**
22+
* Get the default integrations for the Angular SDK.
23+
*/
24+
export function getDefaultIntegrations(): Integration[] {
25+
// Don't include the BrowserApiErrors integration as it interferes with the Angular SDK's `ErrorHandler`:
26+
// BrowserApiErrors would catch certain errors before they reach the `ErrorHandler` and
27+
// thus provide a lower fidelity error than what `SentryErrorHandler`
28+
// (see errorhandler.ts) would provide.
29+
//
30+
// see:
31+
// - https://github.com/getsentry/sentry-javascript/issues/5417#issuecomment-1453407097
32+
// - https://github.com/getsentry/sentry-javascript/issues/2744
33+
return [
34+
inboundFiltersIntegration(),
35+
functionToStringIntegration(),
36+
breadcrumbsIntegration(),
37+
globalHandlersIntegration(),
38+
linkedErrorsIntegration(),
39+
dedupeIntegration(),
40+
httpContextIntegration(),
41+
];
42+
}
43+
944
/**
1045
* Inits the Angular SDK
1146
*/
1247
export function init(options: BrowserOptions): void {
1348
const opts = {
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
16-
// lower fidelity error than what `SentryErrorHandler` (see errorhandler.ts) would provide.
17-
// see:
18-
// - https://github.com/getsentry/sentry-javascript/issues/5417#issuecomment-1453407097
19-
// - https://github.com/getsentry/sentry-javascript/issues/2744
20-
defaultIntegrations: getDefaultIntegrations(options).filter(integration => {
21-
return integration.name !== 'BrowserApiErrors';
22-
}),
49+
defaultIntegrations: getDefaultIntegrations(),
2350
...options,
2451
};
2552

0 commit comments

Comments
 (0)