@sentry/angular 11.0.0 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -212
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -10,219 +10,15 @@
|
|
|
10
10
|
[](https://www.npmjs.com/package/@sentry/angular)
|
|
11
11
|
[](https://www.npmjs.com/package/@sentry/angular)
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
The official Sentry SDK for monitoring Angular applications.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
## Documentation
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
- [Getting started](https://docs.sentry.io/platforms/javascript/guides/angular/)
|
|
18
|
+
- [Configuration](https://docs.sentry.io/platforms/javascript/guides/angular/configuration/)
|
|
19
|
+
- [Angular-specific features](https://docs.sentry.io/platforms/javascript/guides/angular/features/)
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
## Support
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
[
|
|
23
|
-
|
|
24
|
-
If you're using an older version of Angular and experience problems with the Angular SDK, we recommend downgrading the
|
|
25
|
-
SDK to version 7.x. Please note that we don't provide any support for Angular versions below 10.
|
|
26
|
-
|
|
27
|
-
## General
|
|
28
|
-
|
|
29
|
-
This package is a wrapper around `@sentry/browser`, with added functionality related to Angular. All methods available
|
|
30
|
-
in `@sentry/browser` can be imported from `@sentry/angular`.
|
|
31
|
-
|
|
32
|
-
To use this SDK, call `Sentry.init(options)` before you bootstrap your Angular application.
|
|
33
|
-
|
|
34
|
-
```javascript
|
|
35
|
-
import { bootstrapApplication } from '@angular/platform-browser';
|
|
36
|
-
import { init } from '@sentry/angular';
|
|
37
|
-
|
|
38
|
-
import { AppComponent } from './app/app.component';
|
|
39
|
-
|
|
40
|
-
init({
|
|
41
|
-
dsn: '__DSN__',
|
|
42
|
-
// ...
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
bootstrapApplication(AppComponent, appConfig);
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### ErrorHandler
|
|
49
|
-
|
|
50
|
-
`@sentry/angular` exports a function to instantiate an ErrorHandler provider that will automatically send Javascript
|
|
51
|
-
errors captured by the Angular's error handler.
|
|
52
|
-
|
|
53
|
-
```ts
|
|
54
|
-
import { ApplicationConfig, NgModule, ErrorHandler } from '@angular/core';
|
|
55
|
-
import { createErrorHandler } from '@sentry/angular';
|
|
56
|
-
|
|
57
|
-
export const appConfig: ApplicationConfig = {
|
|
58
|
-
providers: [
|
|
59
|
-
{
|
|
60
|
-
provide: ErrorHandler,
|
|
61
|
-
useValue: createErrorHandler({
|
|
62
|
-
showDialog: true,
|
|
63
|
-
}),
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// Or using an old module approach:
|
|
69
|
-
@NgModule({
|
|
70
|
-
// ...
|
|
71
|
-
providers: [
|
|
72
|
-
{
|
|
73
|
-
provide: ErrorHandler,
|
|
74
|
-
useValue: createErrorHandler({
|
|
75
|
-
showDialog: true,
|
|
76
|
-
}),
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
// ...
|
|
80
|
-
})
|
|
81
|
-
export class AppModule {}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Additionally, `createErrorHandler` accepts a set of options that allows you to configure its behavior. For more details
|
|
85
|
-
see `ErrorHandlerOptions` interface in `src/errorhandler.ts`.
|
|
86
|
-
|
|
87
|
-
### Tracing
|
|
88
|
-
|
|
89
|
-
`@sentry/angular` exports a Trace Service, Directive and Decorators that leverage the tracing features to add
|
|
90
|
-
Angular-related spans to transactions. If tracing is not enabled, this functionality will not work. The SDK's
|
|
91
|
-
`TraceService` itself tracks route changes and durations, while directive and decorators are tracking components
|
|
92
|
-
initializations.
|
|
93
|
-
|
|
94
|
-
#### Install
|
|
95
|
-
|
|
96
|
-
Registering a Trace Service is a 3-step process.
|
|
97
|
-
|
|
98
|
-
1. Register and configure the `BrowserTracing` integration, including custom Angular routing instrumentation:
|
|
99
|
-
|
|
100
|
-
```javascript
|
|
101
|
-
import { init, browserTracingIntegration } from '@sentry/angular';
|
|
102
|
-
|
|
103
|
-
init({
|
|
104
|
-
dsn: '__DSN__',
|
|
105
|
-
integrations: [browserTracingIntegration()],
|
|
106
|
-
tracePropagationTargets: ['localhost', 'https://yourserver.io/api'],
|
|
107
|
-
tracesSampleRate: 1,
|
|
108
|
-
});
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
2. Inject the `TraceService` in the `APP_INITIALIZER`:
|
|
112
|
-
|
|
113
|
-
```ts
|
|
114
|
-
import { ApplicationConfig, APP_INITIALIZER, provideAppInitializer } from '@angular/core';
|
|
115
|
-
|
|
116
|
-
export const appConfig: ApplicationConfig = {
|
|
117
|
-
providers: [
|
|
118
|
-
{
|
|
119
|
-
provide: APP_INITIALIZER,
|
|
120
|
-
useFactory: () => () => {},
|
|
121
|
-
deps: [TraceService],
|
|
122
|
-
multi: true,
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
// Starting with Angular 19, we can use `provideAppInitializer`
|
|
126
|
-
// instead of directly providing `APP_INITIALIZER` (deprecated):
|
|
127
|
-
provideAppInitializer(() => inject(TraceService)),
|
|
128
|
-
],
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// Or using an old module approach:
|
|
132
|
-
@NgModule({
|
|
133
|
-
// ...
|
|
134
|
-
providers: [
|
|
135
|
-
{
|
|
136
|
-
provide: APP_INITIALIZER,
|
|
137
|
-
useFactory: () => () => {},
|
|
138
|
-
deps: [TraceService],
|
|
139
|
-
multi: true,
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
// Starting with Angular 19, we can use `provideAppInitializer`
|
|
143
|
-
// instead of directly providing `APP_INITIALIZER` (deprecated):
|
|
144
|
-
provideAppInitializer(() => inject(TraceService)),
|
|
145
|
-
],
|
|
146
|
-
// ...
|
|
147
|
-
})
|
|
148
|
-
export class AppModule {}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
#### Use
|
|
152
|
-
|
|
153
|
-
To track Angular components as part of your transactions, you have 3 options.
|
|
154
|
-
|
|
155
|
-
_TraceDirective:_ used to track a duration between `OnInit` and `AfterViewInit` lifecycle hooks in template:
|
|
156
|
-
|
|
157
|
-
```ts
|
|
158
|
-
import { TraceModule } from '@sentry/angular';
|
|
159
|
-
|
|
160
|
-
@Component({
|
|
161
|
-
selector: 'some-component',
|
|
162
|
-
imports: [TraceModule],
|
|
163
|
-
// ...
|
|
164
|
-
})
|
|
165
|
-
export class SomeComponentThatUsesTraceDirective {}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
Then, inside your component's template (keep in mind that the directive's name attribute is required):
|
|
169
|
-
|
|
170
|
-
```html
|
|
171
|
-
<app-header trace="header"></app-header>
|
|
172
|
-
<articles-list trace="articles-list"></articles-list>
|
|
173
|
-
<app-footer trace="footer"></app-footer>
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
_TraceClass:_ used to track a duration between `OnInit` and `AfterViewInit` lifecycle hooks in components:
|
|
177
|
-
|
|
178
|
-
```javascript
|
|
179
|
-
import { Component } from '@angular/core';
|
|
180
|
-
import { TraceClass } from '@sentry/angular';
|
|
181
|
-
|
|
182
|
-
@Component({
|
|
183
|
-
selector: 'layout-header',
|
|
184
|
-
templateUrl: './header.component.html',
|
|
185
|
-
})
|
|
186
|
-
@TraceClass()
|
|
187
|
-
export class HeaderComponent {
|
|
188
|
-
// ...
|
|
189
|
-
}
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
_TraceMethod:_ used to track a specific lifecycle hooks as point-in-time spans in components:
|
|
193
|
-
|
|
194
|
-
```javascript
|
|
195
|
-
import { Component, OnInit } from '@angular/core';
|
|
196
|
-
import { TraceMethod } from '@sentry/angular';
|
|
197
|
-
|
|
198
|
-
@Component({
|
|
199
|
-
selector: 'app-footer',
|
|
200
|
-
templateUrl: './footer.component.html',
|
|
201
|
-
})
|
|
202
|
-
export class FooterComponent implements OnInit {
|
|
203
|
-
@TraceMethod()
|
|
204
|
-
ngOnInit() {}
|
|
205
|
-
}
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
You can also add your own custom spans via `startSpan()`. For example, if you'd like to track the duration of Angular
|
|
209
|
-
boostraping process, you can do it as follows:
|
|
210
|
-
|
|
211
|
-
```javascript
|
|
212
|
-
import { enableProdMode } from '@angular/core';
|
|
213
|
-
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
214
|
-
import { init, startSpan } from '@sentry/angular';
|
|
215
|
-
|
|
216
|
-
import { AppModule } from './app/app.module';
|
|
217
|
-
|
|
218
|
-
// ...
|
|
219
|
-
startSpan(
|
|
220
|
-
{
|
|
221
|
-
name: 'platform-browser-dynamic',
|
|
222
|
-
op: 'ui.mount',
|
|
223
|
-
},
|
|
224
|
-
async () => {
|
|
225
|
-
await platformBrowserDynamic().bootstrapModule(AppModule);
|
|
226
|
-
},
|
|
227
|
-
);
|
|
228
|
-
```
|
|
23
|
+
- [Report a bug](https://github.com/getsentry/sentry-javascript/issues/new/choose)
|
|
24
|
+
- [Contributing](https://github.com/getsentry/sentry-javascript/blob/develop/CONTRIBUTING.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/angular",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.0",
|
|
4
4
|
"description": "Official Sentry SDK for Angular",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/angular",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"rxjs": "^6.5.5 || ^7.x"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@sentry/browser": "11.
|
|
25
|
-
"@sentry/core": "11.
|
|
26
|
-
"@sentry/conventions": "^0.
|
|
24
|
+
"@sentry/browser": "11.2.0",
|
|
25
|
+
"@sentry/core": "11.2.0",
|
|
26
|
+
"@sentry/conventions": "^0.24.0",
|
|
27
27
|
"tslib": "^2.4.1"
|
|
28
28
|
},
|
|
29
29
|
"volta": {
|