@sentry/angular 8.12.0 → 8.13.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/package.json +7 -7
- package/build/README.md +0 -235
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/angular",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.13.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,10 +21,10 @@
|
|
|
21
21
|
"rxjs": "^6.5.5 || ^7.x"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@sentry/browser": "8.
|
|
25
|
-
"@sentry/core": "8.
|
|
26
|
-
"@sentry/types": "8.
|
|
27
|
-
"@sentry/utils": "8.
|
|
24
|
+
"@sentry/browser": "8.13.0",
|
|
25
|
+
"@sentry/core": "8.13.0",
|
|
26
|
+
"@sentry/types": "8.13.0",
|
|
27
|
+
"@sentry/utils": "8.13.0",
|
|
28
28
|
"tslib": "^2.4.1"
|
|
29
29
|
},
|
|
30
30
|
"volta": {
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"outputs": [
|
|
42
42
|
"{projectRoot}/build/esm2015",
|
|
43
43
|
"{projectRoot}/build/fesm2015",
|
|
44
|
-
"{projectRoot}/build
|
|
45
|
-
"{projectRoot}/build
|
|
44
|
+
"{projectRoot}/build/fesm2020",
|
|
45
|
+
"{projectRoot}/build/*.d.ts"
|
|
46
46
|
]
|
|
47
47
|
}
|
|
48
48
|
}
|
package/build/README.md
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
|
|
3
|
-
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
|
|
4
|
-
</a>
|
|
5
|
-
</p>
|
|
6
|
-
|
|
7
|
-
# Official Sentry SDK for Angular
|
|
8
|
-
|
|
9
|
-
[](https://www.npmjs.com/package/@sentry/angular)
|
|
10
|
-
[](https://www.npmjs.com/package/@sentry/angular)
|
|
11
|
-
[](https://www.npmjs.com/package/@sentry/angular)
|
|
12
|
-
|
|
13
|
-
## Links
|
|
14
|
-
|
|
15
|
-
- [Official SDK Docs](https://docs.sentry.io/platforms/javascript/angular/)
|
|
16
|
-
- [TypeDoc](http://getsentry.github.io/sentry-javascript/)
|
|
17
|
-
|
|
18
|
-
## Angular Version Compatibility
|
|
19
|
-
|
|
20
|
-
This SDK officially supports Angular 15 to 17.
|
|
21
|
-
|
|
22
|
-
If you're using an older Angular version please check the
|
|
23
|
-
[compatibility table in the docs](https://docs.sentry.io/platforms/javascript/guides/angular/#angular-version-compatibility).
|
|
24
|
-
|
|
25
|
-
If you're using an older version of Angular and experience problems with the Angular SDK, we recommend downgrading the
|
|
26
|
-
SDK to version 7.x. Please note that we don't provide any support for Angular versions below 10.
|
|
27
|
-
|
|
28
|
-
## General
|
|
29
|
-
|
|
30
|
-
This package is a wrapper around `@sentry/browser`, with added functionality related to Angular. All methods available
|
|
31
|
-
in `@sentry/browser` can be imported from `@sentry/angular`.
|
|
32
|
-
|
|
33
|
-
To use this SDK, call `Sentry.init(options)` before you bootstrap your Angular application.
|
|
34
|
-
|
|
35
|
-
```javascript
|
|
36
|
-
import { enableProdMode } from '@angular/core';
|
|
37
|
-
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
38
|
-
import { init } from '@sentry/angular';
|
|
39
|
-
|
|
40
|
-
import { AppModule } from './app/app.module';
|
|
41
|
-
|
|
42
|
-
init({
|
|
43
|
-
dsn: '__DSN__',
|
|
44
|
-
// ...
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// ...
|
|
48
|
-
|
|
49
|
-
enableProdMode();
|
|
50
|
-
platformBrowserDynamic()
|
|
51
|
-
.bootstrapModule(AppModule)
|
|
52
|
-
.then(success => console.log(`Bootstrap success`))
|
|
53
|
-
.catch(err => console.error(err));
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### ErrorHandler
|
|
57
|
-
|
|
58
|
-
`@sentry/angular` exports a function to instantiate an ErrorHandler provider that will automatically send Javascript
|
|
59
|
-
errors captured by the Angular's error handler.
|
|
60
|
-
|
|
61
|
-
```javascript
|
|
62
|
-
import { NgModule, ErrorHandler } from '@angular/core';
|
|
63
|
-
import { createErrorHandler } from '@sentry/angular';
|
|
64
|
-
|
|
65
|
-
@NgModule({
|
|
66
|
-
// ...
|
|
67
|
-
providers: [
|
|
68
|
-
{
|
|
69
|
-
provide: ErrorHandler,
|
|
70
|
-
useValue: createErrorHandler({
|
|
71
|
-
showDialog: true,
|
|
72
|
-
}),
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
// ...
|
|
76
|
-
})
|
|
77
|
-
export class AppModule {}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Additionally, `createErrorHandler` accepts a set of options that allows you to configure its behavior. For more details
|
|
81
|
-
see `ErrorHandlerOptions` interface in `src/errorhandler.ts`.
|
|
82
|
-
|
|
83
|
-
### Tracing
|
|
84
|
-
|
|
85
|
-
`@sentry/angular` exports a Trace Service, Directive and Decorators that leverage the tracing features to add
|
|
86
|
-
Angular-related spans to transactions. If tracing is not enabled, this functionality will not work. The SDK's
|
|
87
|
-
`TraceService` itself tracks route changes and durations, while directive and decorators are tracking components
|
|
88
|
-
initializations.
|
|
89
|
-
|
|
90
|
-
#### Install
|
|
91
|
-
|
|
92
|
-
Registering a Trace Service is a 3-step process.
|
|
93
|
-
|
|
94
|
-
1. Register and configure the `BrowserTracing` integration, including custom Angular routing instrumentation:
|
|
95
|
-
|
|
96
|
-
```javascript
|
|
97
|
-
import { init, browserTracingIntegration } from '@sentry/angular';
|
|
98
|
-
|
|
99
|
-
init({
|
|
100
|
-
dsn: '__DSN__',
|
|
101
|
-
integrations: [browserTracingIntegration()],
|
|
102
|
-
tracePropagationTargets: ['localhost', 'https://yourserver.io/api'],
|
|
103
|
-
tracesSampleRate: 1,
|
|
104
|
-
});
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
2. Register `SentryTrace` as a provider in Angular's DI system, with a `Router` as its dependency:
|
|
108
|
-
|
|
109
|
-
```javascript
|
|
110
|
-
import { NgModule } from '@angular/core';
|
|
111
|
-
import { Router } from '@angular/router';
|
|
112
|
-
import { TraceService } from '@sentry/angular';
|
|
113
|
-
|
|
114
|
-
@NgModule({
|
|
115
|
-
// ...
|
|
116
|
-
providers: [
|
|
117
|
-
{
|
|
118
|
-
provide: TraceService,
|
|
119
|
-
deps: [Router],
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
// ...
|
|
123
|
-
})
|
|
124
|
-
export class AppModule {}
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
3. Either require the `TraceService` from inside `AppModule` or use `APP_INITIALIZER` to force-instantiate Tracing.
|
|
128
|
-
|
|
129
|
-
```javascript
|
|
130
|
-
@NgModule({
|
|
131
|
-
// ...
|
|
132
|
-
})
|
|
133
|
-
export class AppModule {
|
|
134
|
-
constructor(trace: TraceService) {}
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
or
|
|
139
|
-
|
|
140
|
-
```javascript
|
|
141
|
-
import { APP_INITIALIZER } from '@angular/core';
|
|
142
|
-
|
|
143
|
-
@NgModule({
|
|
144
|
-
// ...
|
|
145
|
-
providers: [
|
|
146
|
-
{
|
|
147
|
-
provide: APP_INITIALIZER,
|
|
148
|
-
useFactory: () => () => {},
|
|
149
|
-
deps: [TraceService],
|
|
150
|
-
multi: true,
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
// ...
|
|
154
|
-
})
|
|
155
|
-
export class AppModule {}
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
#### Use
|
|
159
|
-
|
|
160
|
-
To track Angular components as part of your transactions, you have 3 options.
|
|
161
|
-
|
|
162
|
-
_TraceDirective:_ used to track a duration between `OnInit` and `AfterViewInit` lifecycle hooks in template:
|
|
163
|
-
|
|
164
|
-
```javascript
|
|
165
|
-
import { TraceModule } from '@sentry/angular';
|
|
166
|
-
|
|
167
|
-
@NgModule({
|
|
168
|
-
// ...
|
|
169
|
-
imports: [TraceModule],
|
|
170
|
-
// ...
|
|
171
|
-
})
|
|
172
|
-
export class AppModule {}
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
Then, inside your component's template (keep in mind that the directive's name attribute is required):
|
|
176
|
-
|
|
177
|
-
```html
|
|
178
|
-
<app-header trace="header"></app-header>
|
|
179
|
-
<articles-list trace="articles-list"></articles-list>
|
|
180
|
-
<app-footer trace="footer"></app-footer>
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
_TraceClass:_ used to track a duration between `OnInit` and `AfterViewInit` lifecycle hooks in components:
|
|
184
|
-
|
|
185
|
-
```javascript
|
|
186
|
-
import { Component } from '@angular/core';
|
|
187
|
-
import { TraceClass } from '@sentry/angular';
|
|
188
|
-
|
|
189
|
-
@Component({
|
|
190
|
-
selector: 'layout-header',
|
|
191
|
-
templateUrl: './header.component.html',
|
|
192
|
-
})
|
|
193
|
-
@TraceClass()
|
|
194
|
-
export class HeaderComponent {
|
|
195
|
-
// ...
|
|
196
|
-
}
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
_TraceMethod:_ used to track a specific lifecycle hooks as point-in-time spans in components:
|
|
200
|
-
|
|
201
|
-
```javascript
|
|
202
|
-
import { Component, OnInit } from '@angular/core';
|
|
203
|
-
import { TraceMethod } from '@sentry/angular';
|
|
204
|
-
|
|
205
|
-
@Component({
|
|
206
|
-
selector: 'app-footer',
|
|
207
|
-
templateUrl: './footer.component.html',
|
|
208
|
-
})
|
|
209
|
-
export class FooterComponent implements OnInit {
|
|
210
|
-
@TraceMethod()
|
|
211
|
-
ngOnInit() {}
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
You can also add your own custom spans via `startSpan()`. For example, if you'd like to track the duration of Angular
|
|
216
|
-
boostraping process, you can do it as follows:
|
|
217
|
-
|
|
218
|
-
```javascript
|
|
219
|
-
import { enableProdMode } from '@angular/core';
|
|
220
|
-
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
221
|
-
import { init, startSpan } from '@sentry/angular';
|
|
222
|
-
|
|
223
|
-
import { AppModule } from './app/app.module';
|
|
224
|
-
|
|
225
|
-
// ...
|
|
226
|
-
startSpan(
|
|
227
|
-
{
|
|
228
|
-
name: 'platform-browser-dynamic',
|
|
229
|
-
op: 'ui.angular.bootstrap',
|
|
230
|
-
},
|
|
231
|
-
async () => {
|
|
232
|
-
await platformBrowserDynamic().bootstrapModule(AppModule);
|
|
233
|
-
},
|
|
234
|
-
);
|
|
235
|
-
```
|