11import { 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' ;
33import { logger } from '@sentry/utils' ;
44
55import { ANGULAR_MINIMUM_VERSION } from './constants' ;
@@ -20,20 +20,23 @@ export function init(options: BrowserOptions): void {
2020 ] ,
2121 version : SDK_VERSION ,
2222 } ;
23- checkAngularVersion ( ) ;
23+
24+ checkAndSetAngularVersion ( ) ;
2425 browserInit ( options ) ;
2526}
2627
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 ) {
3133 IS_DEBUG_BUILD &&
3234 logger . warn (
33- `The Sentry SDK does not officially support Angular ${ major } .` ,
35+ `The Sentry SDK does not officially support Angular ${ angularVersion } .` ,
3436 `This version of the Sentry SDK supports Angular ${ ANGULAR_MINIMUM_VERSION } and above.` ,
3537 'Please consider upgrading your Angular version or downgrading the Sentry SDK.' ,
3638 ) ;
3739 }
40+ setContext ( 'angular' , { version : angularVersion } ) ;
3841 }
3942}
0 commit comments