From fcdfe7de71953d36e32591b10a01139cd284280b Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 22 Apr 2022 09:42:19 +0200 Subject: [PATCH 1/4] feat(angular): Log warning if SDK is used with an older Angular version than officially supported --- packages/angular/src/constants.ts | 5 +++++ packages/angular/src/sdk.ts | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/packages/angular/src/constants.ts b/packages/angular/src/constants.ts index a0786e7b516c..9e98b366d841 100644 --- a/packages/angular/src/constants.ts +++ b/packages/angular/src/constants.ts @@ -3,3 +3,8 @@ export const ANGULAR_ROUTING_OP = 'ui.angular.routing'; export const ANGULAR_INIT_OP = 'ui.angular.init'; export const ANGULAR_OP = 'ui.angular'; + +/** + * Minimum Angular version this SDK supports + */ +export const ANGULAR_MINIMUM_VERSION = 10; diff --git a/packages/angular/src/sdk.ts b/packages/angular/src/sdk.ts index 09267d1f2082..6fddffe1eb6b 100644 --- a/packages/angular/src/sdk.ts +++ b/packages/angular/src/sdk.ts @@ -1,4 +1,8 @@ +import { VERSION } from '@angular/core'; import { BrowserOptions, init as browserInit, SDK_VERSION } from '@sentry/browser'; +import { logger } from '@sentry/utils'; +import { ANGULAR_MINIMUM_VERSION } from './constants'; +import { IS_DEBUG_BUILD } from './flags'; /** * Inits the Angular SDK @@ -15,5 +19,20 @@ export function init(options: BrowserOptions): void { ], version: SDK_VERSION, }; + checkAngularVersion(); browserInit(options); } + +function checkAngularVersion(): void { + if (VERSION && VERSION.major) { + const major = parseInt(VERSION.major, 10); + if (major < ANGULAR_MINIMUM_VERSION) { + IS_DEBUG_BUILD && + logger.warn( + `The Sentry SDK does not officially support Angular ${major}.`, + `This version of the Sentry SDK supports Angular ${ANGULAR_MINIMUM_VERSION} and above.`, + 'Please consider upgrading your Angular version or downgrading the Sentry SDK.', + ); + } + } +} From be0743ddd17bd7b416e59c32343876f4f49afdbf Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 22 Apr 2022 09:43:16 +0200 Subject: [PATCH 2/4] update Readme and Migration docs w.r.t Angular version compatiblity --- MIGRATION.md | 6 +++++- packages/angular/README.md | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 77f1c21e7aca..b3a3a9eb7944 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -129,7 +129,11 @@ The Sentry Angular SDK (`@sentry/angular`) is now compiled with the Angular comp ### Angular Version Compatibility -Given the forward compatibility of the Angular compiler, v7 of our SDK will only work with Angular 10 and above. Previously, it was possible to use the SDK with versions <10, although we officially only supported Angular 10-13 as peer dependencies. If you are using Angular <10 in your project, we recommend staying on the latest 6.x version until you can upgrade your Angular version. +As in v6, we continue to list Angular 10-13 in our peer dependencies, meaning that these are the Angular versions we officially support. +If you are using v7 with Angular <10 in your project and you experience problems, we recommend staying on the latest 6.x +version until you can upgrade your Angular version. As v7 of our SDK is compiled with the Angular 10 compiler and we upgraded +our Typescript version, the SDK will work with Angular 10 and above. Tests have shown that Angular 9 seems to work as well +(use at your own risk) but we recommend upgrading to a more recent Angular version. ### Import Changes diff --git a/packages/angular/README.md b/packages/angular/README.md index 2a110538a349..0e57bcbb43bc 100644 --- a/packages/angular/README.md +++ b/packages/angular/README.md @@ -14,8 +14,8 @@ ## Angular Version Compatibility -For Angular 10-13 use the latest version of the Sentry Angular SDK. In case -you are using an Angular 9 or earlier, use version 6.x of the SDK as newer versions do not support Angular <10. +The latest version of this SDK officially supports Angular 10-13. In case you are using an older version of Angular, +use v6 of the Sentry Angular SDK if you experience problems with newer SDK versions. ## General From 57e8954ac10e3fa98e62d4fac976e34179984a85 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 22 Apr 2022 10:06:50 +0200 Subject: [PATCH 3/4] Update packages/angular/README.md Co-authored by @lforst Co-authored-by: Luca Forstner --- packages/angular/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/angular/README.md b/packages/angular/README.md index 0e57bcbb43bc..82132d7543b2 100644 --- a/packages/angular/README.md +++ b/packages/angular/README.md @@ -14,8 +14,7 @@ ## Angular Version Compatibility -The latest version of this SDK officially supports Angular 10-13. In case you are using an older version of Angular, -use v6 of the Sentry Angular SDK if you experience problems with newer SDK versions. +The latest version of this SDK officially supports Angular 10-13. If you are using an older version of Angular and experience problems with the Angular SDK, we recommend downgrading the SDK to version 6.x. ## General From 333f5dda88a9e01ff3f678a8ca3a1808cb2909e5 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 22 Apr 2022 10:13:28 +0200 Subject: [PATCH 4/4] fix linter error (import order) --- packages/angular/src/sdk.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/angular/src/sdk.ts b/packages/angular/src/sdk.ts index 6fddffe1eb6b..bcce7c85ccdb 100644 --- a/packages/angular/src/sdk.ts +++ b/packages/angular/src/sdk.ts @@ -1,6 +1,7 @@ import { VERSION } from '@angular/core'; import { BrowserOptions, init as browserInit, SDK_VERSION } from '@sentry/browser'; import { logger } from '@sentry/utils'; + import { ANGULAR_MINIMUM_VERSION } from './constants'; import { IS_DEBUG_BUILD } from './flags';