Agent Installation
For NPM and Yarn
If you bundle the Atatus script with your source code, install theatatus-spa package using your preferred package manager:
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:
Test Integration
To verify that your integration is working properly, trigger a test error anywhere in your application: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
$exceptionHandlerto report errors to Atatus while preserving the default AngularJS behavior and console output. - Using a factory: Replaces the default exception handler entirely.
Option 1: Using a Decorator (Recommended)
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, enablehashRoutes during agent initialization:
Custom URL Transformation
If you want to transform hash-based URLs into clean, pretty URLs in error payloads, use theonBeforeErrorSend callback: