Repository navigation
Expand file tree
/
Copy pathsdk.ts
More file actions
executable file
·58 lines (51 loc) · 1.96 KB
/
Copy pathsdk.ts
File metadata and controls
executable file
·58 lines (51 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { VERSION } from '@angular/core';
import type { BrowserOptions } from '@sentry/browser';
import { SDK_VERSION, defaultIntegrations, init as browserInit, setContext } from '@sentry/browser';
import type { SdkMetadata } from '@sentry/types';
import { logger } from '@sentry/utils';
import { IS_DEBUG_BUILD } from './flags';
/**
* Inits the Angular SDK
*/
export function init(options: BrowserOptions): void {
const opts = {
_metadata: {} as SdkMetadata,
// Filter out TryCatch integration as it interferes with our Angular `ErrorHandler`:
// TryCatch would catch certain errors before they reach the `ErrorHandler` and thus provide a
// lower fidelity error than what `SentryErrorHandler` (see errorhandler.ts) would provide.
// see:
// - https://github.com/getsentry/sentry-javascript/issues/5417#issuecomment-1453407097
// - https://github.com/getsentry/sentry-javascript/issues/2744
defaultIntegrations: defaultIntegrations.filter(integration => {
return integration.name !== 'TryCatch';
}),
...options,
};
opts._metadata.sdk = opts._metadata.sdk || {
name: 'sentry.javascript.angular',
packages: [
{
name: 'npm:@sentry/angular',
version: SDK_VERSION,
},
],
version: SDK_VERSION,
};
checkAndSetAngularVersion();
browserInit(opts);
}
function checkAndSetAngularVersion(): void {
const ANGULAR_MINIMUM_VERSION = 10;
const angularVersion = VERSION && VERSION.major ? parseInt(VERSION.major, 10) : undefined;
if (angularVersion) {
if (angularVersion < ANGULAR_MINIMUM_VERSION) {
IS_DEBUG_BUILD &&
logger.warn(
`The Sentry SDK does not officially support Angular ${angularVersion}.`,
`This version of the Sentry SDK supports Angular ${ANGULAR_MINIMUM_VERSION} and above.`,
'Please consider upgrading your Angular version or downgrading the Sentry SDK.',
);
}
setContext('angular', { version: angularVersion });
}
}