Angular is a popular TypeScript-based framework for building scalable web applications. Atatus provides real-time error tracking and performance monitoring for Angular applications.

Agent Installation

For NPM and Yarn

If you bundle the Atatus script with your source code, install the atatus-spa package using your preferred package manager. Install atatus-spa from the registry:
Import and initialize Atatus in your application’s entry point (e.g., main.ts):

For CDN

Alternatively, you can load the Atatus agent via CDN by adding the following snippet into the <head> section of your src/index.html file before any other script tags:
For more advanced configuration options, refer to Customizing the Agent.

Test Integration

To verify that your integration is working properly, trigger a test error anywhere in your application:
Within a few seconds, performance metrics and the test error will appear in your Atatus project dashboard.

Track Exceptions in Angular Apps

Angular catches unhandled exceptions within its zone and delegates them to an ErrorHandler class. To report these exceptions to Atatus, create a custom error handler.

1. Create a Custom Error Handler

Create an atatus.handler.ts file in your application directory:

2. Register the Error Handler

Register AtatusErrorHandler in your application configuration depending on the setup you are using:

Option A: Standalone Application (Angular 14+)

If your project uses standalone components and application bootstrap (bootstrapApplication), provide the custom error handler in app.config.ts:

Option B: NgModule Application (Classic Angular)

If your project uses @NgModule, register AtatusErrorHandler in the providers array of app.module.ts: