-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Onboarding wizard for errors + replay + performance #6633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
d5cfce3
998b098
1c93570
bcc9aff
5b9d632
700409e
a73bbf4
f7c2bc8
a5ad64c
e6afb06
1b7721a
ae563d1
a75bbc8
bc11960
4887323
0e22b38
c5b4fc0
1ddb16d
d8124e0
ed530f8
a2de507
d9410a9
43a03fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
--- | ||
name: Angular | ||
doc_link: https://docs.sentry.io/platforms/javascript/guides/angular/ | ||
support_level: production | ||
type: framework | ||
--- | ||
|
||
## Install | ||
To use Sentry with your Angular application, you'll need `@sentry/angular-ivy` or `@sentry/angular`, Sentry’s Browser Angular SDKs: | ||
|
||
- If you're using Angular 12 or newer, use `@sentry/angular-ivy` | ||
- If you're using Angular 10 or 11, use `@sentry/angular` | ||
|
||
Add the Sentry SDK as a dependency using `yarn` or `npm`: | ||
|
||
```bash | ||
# Using yarn (Angular 12+) | ||
yarn add @sentry/angular-ivy | ||
# Using yarn (Angular 10 and 11) | ||
yarn add @sentry/angular | ||
|
||
# Using npm (Angular 12+) | ||
npm install --save @sentry/angular-ivy | ||
# Using npm (Angular 10 and 11) | ||
npm install --save @sentry/angular | ||
``` | ||
|
||
## Configure | ||
You should `init` the Sentry browser SDK in your `main.ts` file as soon as possible during application load up, before initializing Angular: | ||
|
||
```javascript | ||
import { enableProdMode } from "@angular/core"; | ||
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; | ||
// import * as Sentry from "@sentry/angular" // for Angular 10/11 instead | ||
import * as Sentry from "@sentry/angular-ivy"; | ||
|
||
import { AppModule } from "./app/app.module"; | ||
|
||
Sentry.init({ | ||
dsn: "___PUBLIC_DSN___", | ||
integrations: [ | ||
new Sentry.BrowserTracing({ | ||
tracePropagationTargets: ["localhost", "my-site-url.com", /^\//], | ||
routingInstrumentation: Sentry.routingInstrumentation, | ||
}), | ||
], | ||
// Performance Monitoring | ||
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production! | ||
}); | ||
|
||
enableProdMode(); | ||
platformBrowserDynamic() | ||
.bootstrapModule(AppModule) | ||
.then(success => console.log(`Bootstrap success`)) | ||
.catch(err => console.error(err)); | ||
``` | ||
|
||
### ErrorHandler and Tracer | ||
|
||
The Sentry Angular SDK exports a function to instantiate `ErrorHandler` provider that will automatically send JavaScript errors captured by the Angular's error handler. | ||
|
||
```javascript | ||
import { APP_INITIALIZER, ErrorHandler, NgModule } from "@angular/core"; | ||
import { Router } from "@angular/router"; | ||
// import * as Sentry from "@sentry/angular" // for Angular 10/11 instead | ||
import * as Sentry from "@sentry/angular-ivy"; | ||
|
||
@NgModule({ | ||
// ... | ||
providers: [ | ||
{ | ||
provide: ErrorHandler, | ||
useValue: Sentry.createErrorHandler({ | ||
showDialog: true, | ||
}), | ||
}, | ||
{ | ||
provide: Sentry.TraceService, | ||
deps: [Router], | ||
}, | ||
{ | ||
provide: APP_INITIALIZER, | ||
useFactory: () => () => {}, | ||
deps: [Sentry.TraceService], | ||
multi: true, | ||
}, | ||
], | ||
// ... | ||
}) | ||
export class AppModule {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just stumbled across this. This is definitely required to set up the SDK properly in Angular apps. Otherwise the routing instrumentation doesn't work (==> no/incorrect pageload navigation transactions) and errors would only be caught by the global handlers. |
||
``` | ||
|
||
## Verify | ||
This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected. | ||
|
||
```javascript | ||
myUndefinedFunction(); | ||
``` | ||
|
||
--- | ||
## Next Steps | ||
- [Source Maps](https://docs.sentry.io/platforms/javascript/guides/angular/sourcemaps/): Learn how to enable readable stack traces in your Sentry errors. | ||
- [Angular Features](https://docs.sentry.io/platforms/javascript/guides/angular/features/): Learn about our first class integration with the Angular framework. | ||
- [Performance Monitoring](https://docs.sentry.io/platforms/javascript/guides/angular/performance/): Track down transactions to connect the dots between 10-second page loads and poor-performing API calls or slow database queries. | ||
bruno-garcia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- [Session Replay](https://docs.sentry.io/platforms/javascript/guides/angular/session-replay/): Get to the root cause of an error or latency issue faster by seeing all the technical details related to that issue in one visual replay on your web application. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
--- | ||
name: Angular | ||
doc_link: https://docs.sentry.io/platforms/javascript/guides/angular/ | ||
support_level: production | ||
type: framework | ||
--- | ||
|
||
## Install | ||
To use Sentry with your Angular application, you'll need `@sentry/angular-ivy` or `@sentry/angular`, Sentry’s Browser Angular SDKs: | ||
|
||
- If you're using Angular 12 or newer, use `@sentry/angular-ivy` | ||
- If you're using Angular 10 or 11, use `@sentry/angular` | ||
|
||
Add the Sentry SDK as a dependency using `yarn` or `npm`: | ||
|
||
```bash | ||
# Using yarn (Angular 12+) | ||
yarn add @sentry/angular-ivy | ||
# Using yarn (Angular 10 and 11) | ||
yarn add @sentry/angular | ||
|
||
# Using npm (Angular 12+) | ||
npm install --save @sentry/angular-ivy | ||
# Using npm (Angular 10 and 11) | ||
npm install --save @sentry/angular | ||
``` | ||
|
||
## Configure | ||
You should `init` the Sentry browser SDK in your `main.ts` file as soon as possible during application load up, before initializing Angular: | ||
|
||
```javascript | ||
import { enableProdMode } from "@angular/core"; | ||
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; | ||
// import * as Sentry from "@sentry/angular" // for Angular 10/11 instead | ||
import * as Sentry from "@sentry/angular-ivy"; | ||
|
||
import { AppModule } from "./app/app.module"; | ||
|
||
Sentry.init({ | ||
dsn: "___PUBLIC_DSN___", | ||
integrations: [ | ||
new Sentry.Replay(), | ||
], | ||
// Session Replay | ||
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production. | ||
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur. | ||
}); | ||
|
||
enableProdMode(); | ||
platformBrowserDynamic() | ||
.bootstrapModule(AppModule) | ||
.then(success => console.log(`Bootstrap success`)) | ||
.catch(err => console.error(err)); | ||
``` | ||
|
||
### ErrorHandler and Tracer | ||
|
||
The Sentry Angular SDK exports a function to instantiate `ErrorHandler` provider that will automatically send JavaScript errors captured by the Angular's error handler. | ||
|
||
```javascript | ||
import { APP_INITIALIZER, ErrorHandler, NgModule } from "@angular/core"; | ||
import { Router } from "@angular/router"; | ||
// import * as Sentry from "@sentry/angular" // for Angular 10/11 instead | ||
import * as Sentry from "@sentry/angular-ivy"; | ||
|
||
@NgModule({ | ||
// ... | ||
providers: [ | ||
{ | ||
provide: ErrorHandler, | ||
useValue: Sentry.createErrorHandler({ | ||
showDialog: true, | ||
}), | ||
}, | ||
{ | ||
provide: Sentry.TraceService, | ||
AbhiPrasad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
deps: [Router], | ||
}, | ||
{ | ||
provide: APP_INITIALIZER, | ||
useFactory: () => () => {}, | ||
deps: [Sentry.TraceService], | ||
AbhiPrasad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
multi: true, | ||
}, | ||
], | ||
// ... | ||
}) | ||
export class AppModule {} | ||
``` | ||
|
||
## Verify | ||
This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected. | ||
|
||
```javascript | ||
myUndefinedFunction(); | ||
``` | ||
|
||
--- | ||
## Next Steps | ||
- [Source Maps](https://docs.sentry.io/platforms/javascript/guides/angular/sourcemaps/): Learn how to enable readable stack traces in your Sentry errors. | ||
- [Angular Features](https://docs.sentry.io/platforms/javascript/guides/angular/features/): Learn about our first class integration with the Angular framework. | ||
- [Performance Monitoring](https://docs.sentry.io/platforms/javascript/guides/angular/performance/): Track down transactions to connect the dots between 10-second page loads and poor-performing API calls or slow database queries. | ||
- [Session Replay](https://docs.sentry.io/platforms/javascript/guides/angular/session-replay/): Get to the root cause of an error or latency issue faster by seeing all the technical details related to that issue in one visual replay on your web application. | ||
bruno-garcia marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
--- | ||
name: Angular | ||
doc_link: https://docs.sentry.io/platforms/javascript/guides/angular/ | ||
support_level: production | ||
type: framework | ||
--- | ||
|
||
## Install | ||
To use Sentry with your Angular application, you'll need `@sentry/angular-ivy` or `@sentry/angular`, Sentry’s Browser Angular SDKs: | ||
|
||
- If you're using Angular 12 or newer, use `@sentry/angular-ivy` | ||
- If you're using Angular 10 or 11, use `@sentry/angular` | ||
|
||
Add the Sentry SDK as a dependency using `yarn` or `npm`: | ||
|
||
```bash | ||
# Using yarn (Angular 12+) | ||
yarn add @sentry/angular-ivy | ||
# Using yarn (Angular 10 and 11) | ||
yarn add @sentry/angular | ||
|
||
# Using npm (Angular 12+) | ||
npm install --save @sentry/angular-ivy | ||
# Using npm (Angular 10 and 11) | ||
npm install --save @sentry/angular | ||
``` | ||
|
||
## Configure | ||
You should `init` the Sentry browser SDK in your `main.ts` file as soon as possible during application load up, before initializing Angular: | ||
|
||
```javascript | ||
import { enableProdMode } from "@angular/core"; | ||
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; | ||
// import * as Sentry from "@sentry/angular" // for Angular 10/11 instead | ||
import * as Sentry from "@sentry/angular-ivy"; | ||
|
||
import { AppModule } from "./app/app.module"; | ||
|
||
Sentry.init({ | ||
dsn: "___PUBLIC_DSN___", | ||
integrations: [ | ||
new Sentry.BrowserTracing({ | ||
tracePropagationTargets: ["localhost", "my-site-url.com", /^\//], | ||
routingInstrumentation: Sentry.routingInstrumentation, | ||
}), | ||
new Sentry.Replay(), | ||
], | ||
// Performance Monitoring | ||
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production! | ||
// Session Replay | ||
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production. | ||
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur. | ||
}); | ||
|
||
enableProdMode(); | ||
platformBrowserDynamic() | ||
.bootstrapModule(AppModule) | ||
.then(success => console.log(`Bootstrap success`)) | ||
.catch(err => console.error(err)); | ||
``` | ||
|
||
### ErrorHandler and Tracer | ||
|
||
The Sentry Angular SDK exports a function to instantiate `ErrorHandler` provider that will automatically send JavaScript errors captured by the Angular's error handler. | ||
|
||
```javascript | ||
import { APP_INITIALIZER, ErrorHandler, NgModule } from "@angular/core"; | ||
import { Router } from "@angular/router"; | ||
// import * as Sentry from "@sentry/angular" // for Angular 10/11 instead | ||
import * as Sentry from "@sentry/angular-ivy"; | ||
|
||
@NgModule({ | ||
// ... | ||
providers: [ | ||
{ | ||
provide: ErrorHandler, | ||
useValue: Sentry.createErrorHandler({ | ||
showDialog: true, | ||
}), | ||
}, | ||
{ | ||
provide: Sentry.TraceService, | ||
deps: [Router], | ||
}, | ||
{ | ||
provide: APP_INITIALIZER, | ||
useFactory: () => () => {}, | ||
deps: [Sentry.TraceService], | ||
multi: true, | ||
}, | ||
], | ||
// ... | ||
}) | ||
export class AppModule {} | ||
``` | ||
|
||
## Verify | ||
This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected. | ||
|
||
```javascript | ||
myUndefinedFunction(); | ||
``` | ||
|
||
--- | ||
## Next Steps | ||
- [Source Maps](https://docs.sentry.io/platforms/javascript/guides/angular/sourcemaps/): Learn how to enable readable stack traces in your Sentry errors. | ||
- [Angular Features](https://docs.sentry.io/platforms/javascript/guides/angular/features/): Learn about our first class integration with the Angular framework. | ||
- [Performance Monitoring](https://docs.sentry.io/platforms/javascript/guides/angular/performance/): Track down transactions to connect the dots between 10-second page loads and poor-performing API calls or slow database queries. | ||
- [Session Replay](https://docs.sentry.io/platforms/javascript/guides/angular/session-replay/): Get to the root cause of an error or latency issue faster by seeing all the technical details related to that issue in one visual replay on your web application. | ||
bruno-garcia marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.