Angular with AllStak

Add error tracking, router instrumentation, and an HTTP interceptor to your Angular app.

Source repository:
AllStak/allstak-angular
Source README:
README.md
SDK version:
0.2.0
Installation source:
npm
Last verified:
2026-05-31

Installation

Install from npm.

npm install @allstak/angular

Configuration

Call init in main.ts before bootstrapping the app.

import { init } from '@allstak/angular';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
import { appConfig } from './app/app.config';

init({ apiKey: 'your-ingest-key', environment: 'production' });

bootstrapApplication(AppComponent, appConfig);

Basic example

Register the providers (standalone API).

import {
  provideAllStak,
  provideAllStakErrorHandler,
  provideAllStakRouterInstrumentation,
  allStakHttpInterceptor,
} from '@allstak/angular';

export const appConfig = {
  providers: [
    provideRouter(routes),
    provideAllStak({ apiKey: 'your-ingest-key', environment: 'production' }),
    provideAllStakErrorHandler(),
    provideAllStakRouterInstrumentation(),
    provideHttpClient(withInterceptors([allStakHttpInterceptor])),
  ],
};

Capturing errors

Use provideAllStakErrorHandler() (or createErrorHandler) to forward uncaught errors; capture manually via AllStak.captureException.

import { ErrorHandler } from '@angular/core';
import { createErrorHandler } from '@allstak/angular';

providers: [
  { provide: ErrorHandler, useValue: createErrorHandler({ logErrors: true }) },
];

Tracking requests

Add the HTTP interceptor to record each outbound request and open an http.client span — use the functional allStakHttpInterceptor with withInterceptors, or the class AllStakHttpInterceptor with HTTP_INTERCEPTORS.

provideHttpClient(withInterceptors([allStakHttpInterceptor]))

Best practices

  • Call init() before bootstrapApplication.
  • Add the HTTP interceptor to trace outbound calls.
  • Set release for per-deploy grouping.