AngularJS (Angular 1.x) is a JavaScript framework for building dynamic single-page web applications. Atatus seamlessly integrates with AngularJS to provide real-time exception tracking, AJAX error monitoring, and frontend performance metrics.

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:
Import and initialize Atatus in your application’s bootstrap file:

For CDN

Alternatively, include the Atatus agent via CDN by adding the following snippet into the <head> section of your HTML page before 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 AngularJS Apps

AngularJS handles uncaught exceptions through the $exceptionHandler service. You can integrate Atatus using either of the following approaches:
  • Using a decorator (Recommended): Decorates the $exceptionHandler to report errors to Atatus while preserving the default AngularJS behavior and console output.
  • Using a factory: Replaces the default exception handler entirely.
Decorating $exceptionHandler using $provide.decorator is the preferred approach because it preserves existing error logging and passes errors to the default delegate:

Option 2: Using a Factory

You can override the default $exceptionHandler using a factory. This is a quick way to send errors to Atatus, but note that it suppresses the default AngularJS console logging unless handled manually:

Capture AJAX Errors

Server error responses can be automatically intercepted and reported to Atatus by configuring an $http interceptor:

Capture $log.error Calls

If you want calls made to $log.error() to automatically report errors to Atatus, decorate the $log service:

Handle Hash-Based Routing

By default, AngularJS applications use hash-based routing (/#/...). Atatus removes the hash fragment from URLs by default to prevent duplicate path entries.

Enable Hash Routes in Configuration

To preserve hash-based routes in your performance metrics and page views, enable hashRoutes during agent initialization:
You can also toggle this dynamically:

Custom URL Transformation

If you want to transform hash-based URLs into clean, pretty URLs in error payloads, use the onBeforeErrorSend callback: