NestJS with AllStak
Add error tracking and request monitoring to your NestJS app with the AllStak module.
- Source repository:
- AllStak/allstak-nestjs
- Source README:
- README.md
- SDK version:
- 0.2.1
- Installation source:
- npm
- Last verified:
- 2026-05-31
Installation
Install the SDK (peers: @nestjs/common, @nestjs/core, reflect-metadata, rxjs).
npm install @allstak/nestjsConfiguration
Register AllStakModule.forRoot in your root module. It is global and auto-registers the interceptor and exception filter.
import { Module } from '@nestjs/common';
import { AllStakModule } from '@allstak/nestjs';
@Module({
imports: [
AllStakModule.forRoot({
apiKey: process.env.ALLSTAK_API_KEY,
environment: process.env.NODE_ENV ?? 'production',
release: process.env.ALLSTAK_RELEASE,
serviceName: 'api',
captureRequestHeaders: true,
}),
],
})
export class AppModule {}Basic example
Use forRootAsync to build config from your config service.
AllStakModule.forRootAsync({
inject: [ConfigService],
useFactory: (config: ConfigService) => ({ apiKey: config.get('ALLSTAK_API_KEY') }),
});Capturing errors
The global exception filter captures unhandled errors automatically. Capture manually with the exported captureException.
import { captureException } from '@allstak/nestjs';
captureException(new Error('checkout failed'), { level: 'error' });Tracking requests
The auto-registered AllStakNestInterceptor captures inbound HTTP telemetry and opens a nestjs.request span on response, and sets W3C traceparent + baggage response headers. No manual wiring needed.
Best practices
- Use forRoot/forRootAsync — no manual interceptor or filter wiring is required.
- Set serviceName and release.
- Enable captureRequestHeaders if you need request header context.