Skip to content

Commit 5a5dc8b

Browse files
authored
feat(angular): Update Angular docs for v7 release (#4963)
This PR updates our Angular SDK docs for the v7 release. It adds information about compatibility of our SDK with different Angular versions and updates information on `TraceDirective` compatibility.
1 parent 87e9b54 commit 5a5dc8b

File tree

2 files changed

+54
-44
lines changed

2 files changed

+54
-44
lines changed

src/includes/getting-started-install/javascript.angular.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,14 @@ npm install --save @sentry/angular @sentry/tracing
55
```bash {tabTitle:Yarn}
66
yarn add @sentry/angular @sentry/tracing
77
```
8+
9+
<Alert level="info" title="Angular Version Compatibility" >
10+
11+
The latest version of the Sentry Angular SDK officially supports Angular 10 and newer.
12+
If you need to use Angular 9 or older and you experience problems with the latest version of the Sentry SDK,
13+
try downgrading the SDK to version 6 (`@sentry/angular@^6.x`). If you are using Sentry Tracing,
14+
be sure to also downgrade it to the same version (`@sentry/tracing@^6.x`).
15+
Version 6 of the Sentry SDK was compiled differently and might work with older versions of Angular.
16+
Please note that this combination of packages is not being maintained or tested.
17+
18+
</Alert>

src/platforms/javascript/guides/angular/components/tracehelpers.mdx

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,42 @@ title: Track Angular Components
44

55
To track Angular components as part of your transactions, use any of these three options:
66

7-
1. `TraceClassDecorator` tracks a duration between `OnInit` and `AfterViewInit` lifecycle hooks in components:
7+
1. `TraceDirective` tracks a duration between `OnInit` and `AfterViewInit` lifecycle hooks in template:
8+
9+
Import `TraceModule` either globally in your application's `app.module.ts` file or locally in the module(s)
10+
you want to track your components:
11+
12+
```javascript
13+
import * as Sentry from "@sentry/angular";
14+
15+
@NgModule({
16+
// ...
17+
imports: [Sentry.TraceModule],
18+
// ...
19+
})
20+
export class AppModule {}
21+
```
22+
23+
Then, inside your components template, (remember that the directive name attribute is required):
24+
25+
```html
26+
<app-header [trace]="'header'"></app-header>
27+
<articles-list [trace]="'articles-list'"></articles-list>
28+
<app-footer [trace]="'footer'"></app-footer>
29+
```
30+
31+
<Alert level="info" title="Compatibility">
32+
33+
If you're using version 6 of the Angular SDK, using `TraceDirective` or `TraceModule` causes a
34+
compiler error at application compile time of your Angular application. This is a [known issue](https://github.com/getsentry/sentry-javascript/issues/3282)
35+
of our Angular SDK v6 and it was [fixed](https://github.com/getsentry/sentry-javascript/issues/4644)
36+
in v7 of our Angular SDK. We recommend upgrading to the latest Angular SDK version.
37+
Otherwise, please use options 2 (`TraceClassDecorator`) and 3 (`TraceMethodDecorator`)
38+
below to track your Angular components.
39+
40+
</Alert>
41+
42+
2. `TraceClassDecorator` tracks a duration between `OnInit` and `AfterViewInit` lifecycle hooks in components:
843

944
```javascript
1045
import { Component } from "@angular/core";
@@ -20,7 +55,7 @@ export class HeaderComponent {
2055
}
2156
```
2257

23-
2. `TraceMethodDecorator` tracks a specific lifecycle hooks as point-in-time spans in components:
58+
3. `TraceMethodDecorator` tracks a specific lifecycle hooks as point-in-time spans in components:
2459

2560
```javascript
2661
import { Component, OnInit } from "@angular/core";
@@ -40,20 +75,20 @@ You can also add your own custom spans by attaching them to the current active t
4075
helper. For example, to track the duration of the Angular bootstraping process:
4176

4277
```javascript
43-
import { enableProdMode } from '@angular/core';
44-
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
45-
import * as Sentry from '@sentry/angular';
78+
import { enableProdMode } from "@angular/core";
79+
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
80+
import * as Sentry from "@sentry/angular";
4681

47-
import { AppModule } from './app/app.module';
82+
import { AppModule } from "./app/app.module";
4883

4984
// ...
5085

5186
const activeTransaction = Sentry.getActiveTransaction();
5287
const bootstrapSpan =
5388
activeTransaction &&
5489
activeTransaction.startChild({
55-
description: 'platform-browser-dynamic',
56-
op: 'ui.angular.bootstrap',
90+
description: "platform-browser-dynamic",
91+
op: "ui.angular.bootstrap",
5792
});
5893

5994
platformBrowserDynamic()
@@ -66,39 +101,3 @@ platformBrowserDynamic()
66101
}
67102
});
68103
```
69-
70-
3. `TraceDirective` tracks a duration between `OnInit` and `AfterViewInit` lifecycle hooks in template:
71-
72-
<Alert level="warning" title="Important">
73-
74-
Using `TraceDirective` or `TraceModule` currently causes a compiler error at application compile
75-
time of your Angular application if AOT compilation is enabled in your application config (which it is by default).
76-
This is a [known limitation](https://github.com/getsentry/sentry-javascript/issues/3282) of our current
77-
Angular SDK (v6.*) and it will be [adressed and fixed](https://github.com/getsentry/sentry-javascript/issues/4644)
78-
in our next major Angular SDK release (v7).
79-
In the meantime, please use options 1 (`TraceClassDecorator`) and 2 (`TraceMethodDecorator`)
80-
above to track your Angular components.
81-
82-
</Alert>
83-
84-
Import `TraceModule` either globally in your application's `app.module.ts` file or locally in the module(s)
85-
you want to track your components:
86-
87-
```javascript
88-
import * as Sentry from "@sentry/angular";
89-
90-
@NgModule({
91-
// ...
92-
imports: [Sentry.TraceModule],
93-
// ...
94-
})
95-
export class AppModule {}
96-
```
97-
98-
Then, inside your components template, (remember that the directive name attribute is required):
99-
100-
```html
101-
<app-header [trace]="'header'"></app-header>
102-
<articles-list [trace]="'articles-list'"></articles-list>
103-
<app-footer [trace]="'footer'"></app-footer>
104-
```

0 commit comments

Comments
 (0)