| title | Angular | ||
|---|---|---|---|
| description | Learn how to set up Sentry in your Angular application and capture your first errors. | ||
| sdk | sentry.javascript.angular | ||
| categories |
|
You need:
If you're using Angular 16 or older, install and Set Up the SDK Manually. The Sentry Angular SDK still works for Angular versions 14 and newer but the installation wizards requires at least Angular 17.
## InstallRun the Sentry wizard to automatically configure Sentry in your Angular application. It will then guide you through the setup process, asking you to enable additional (optional) Sentry features for your application beyond error monitoring.
npx @sentry/wizard@latest -i angularThis guide assumes that you enable all features and allow the wizard to add an example component to your application. You can add or remove features at any time, but setting them up now will save you the effort of configuring them manually later.
Prefer to set things up yourself? Check out the Manual Setup guide.
- Adds a
Sentry.init()call into yourmain.tsfile - Registers the Sentry
ErrorHandlerandTraceServicein yourapp.config.tsfile - Creates
.sentryclircwith an auth token to upload source maps (this file is automatically added to.gitignore) - Walks you through enabling source maps upload when making a production build, locally as well as in CI
- Adds an example component to your application to help verify your Sentry setup
If you haven't tested your Sentry configuration yet, let's do it now. You can confirm that the Sentry SDK is sending data to your Sentry project by using the example component created by the installation wizard:
- Open the page you added the example component to in your browser.
- Click the "Throw error" button. This triggers an error.
Sentry captures this error for you. Additionally, the button click starts a trace to measure the time it takes for the error to be thrown.
Don't forget to explore the example component's code in your project to understand what's happening after your button click.
Now, head over to your project on Sentry.io to view the collected data (it takes a couple of moments for the data to appear).
At this point, you should have integrated Sentry into Angular application and should already be sending error and tracing data to your Sentry project.
Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are:
- Explore practical guides on what to monitor, log, track, and investigate after setup
- Extend Sentry to your backend using one of our SDKs
- Continue to customize your configuration
- Make use of Angular-specific features
- Learn how to manually capture errors
- If you encountered issues with our installation wizard, try setting up Sentry manually
- Find various topics in Troubleshooting
- Get support