1
1
import { VERSION } from '@angular/core' ;
2
- import { BrowserOptions , init as browserInit , SDK_VERSION } from '@sentry/browser' ;
2
+ import { BrowserOptions , init as browserInit , SDK_VERSION , setContext } from '@sentry/browser' ;
3
3
import { logger } from '@sentry/utils' ;
4
4
5
5
import { ANGULAR_MINIMUM_VERSION } from './constants' ;
@@ -20,20 +20,23 @@ export function init(options: BrowserOptions): void {
20
20
] ,
21
21
version : SDK_VERSION ,
22
22
} ;
23
- checkAngularVersion ( ) ;
23
+
24
+ checkAndSetAngularVersion ( ) ;
24
25
browserInit ( options ) ;
25
26
}
26
27
27
- function checkAngularVersion ( ) : void {
28
- if ( VERSION && VERSION . major ) {
29
- const major = parseInt ( VERSION . major , 10 ) ;
30
- if ( major < ANGULAR_MINIMUM_VERSION ) {
28
+ function checkAndSetAngularVersion ( ) : void {
29
+ const angularVersion = VERSION && VERSION . major ? parseInt ( VERSION . major , 10 ) : undefined ;
30
+
31
+ if ( angularVersion ) {
32
+ if ( angularVersion < ANGULAR_MINIMUM_VERSION ) {
31
33
IS_DEBUG_BUILD &&
32
34
logger . warn (
33
- `The Sentry SDK does not officially support Angular ${ major } .` ,
35
+ `The Sentry SDK does not officially support Angular ${ angularVersion } .` ,
34
36
`This version of the Sentry SDK supports Angular ${ ANGULAR_MINIMUM_VERSION } and above.` ,
35
37
'Please consider upgrading your Angular version or downgrading the Sentry SDK.' ,
36
38
) ;
37
39
}
40
+ setContext ( 'angular' , { version : angularVersion } ) ;
38
41
}
39
42
}
0 commit comments