Skip to main content
The Sentry Angular SDK provides comprehensive error monitoring and performance tracking for Angular applications (Angular 14-20).

Installation

Version Compatibility

  • Angular 14+ is fully supported
  • Angular 10-13: Use SDK version 7.x
  • Angular versions below 10: Not supported

Basic Setup

Initialize Sentry before bootstrapping your application:

ErrorHandler Integration

Register Sentry’s ErrorHandler to capture Angular errors:

Performance Monitoring

TraceService Setup

Enable automatic route change tracking:

Initialize Browser Tracing

Component Tracking

Track component performance with decorators and directives:
Track component initialization in templates:
This tracks the duration between OnInit and AfterViewInit lifecycle hooks.

Custom Performance Tracking

Track Bootstrap Process

Track Service Methods

Error Handling

Manual Error Capture

ErrorHandler Options

HTTP Interceptor

Track HTTP requests:

Context & User Information

Router Instrumentation

The SDK automatically instruments Angular Router when TraceService is initialized:

Advanced Configuration

Best Practices

TraceService

Always inject TraceService to enable automatic route tracking.

ErrorHandler

Register the ErrorHandler provider to catch all Angular errors.

Component Tracking

Use TraceDirective for template-based tracking, decorators for classes.

Lazy Loading

Component tracking works with lazy-loaded modules automatically.

Next Steps

Router Tracking

Advanced router instrumentation

HTTP Interceptor

Track HTTP requests and responses

Performance

Component performance monitoring

Source Maps

Upload source maps for production