All posts

Error Tracking for NestJS: A Setup Guide

Step-by-step tutorial for configuring Bugsly error tracking in NestJS. Includes code snippets and optimization tips.

Overview

Production bugs in NestJS projects are inevitable. The difference between a resilient team and a struggling one often comes down to how quickly they detect and resolve errors.

Bugsly provides a first-class NestJS integration for error tracking that takes minutes to set up and immediately starts delivering value.

Installation and Setup

Start by adding Bugsly to your project:

npm install @bugsly/node

Next, initialize the SDK in your application:

import * as Bugsly from "@bugsly/node";

Bugsly.init({
  dsn: "YOUR_BUGSLY_DSN",
  tracesSampleRate: 1.0,
});

// In app.module.ts
@Module({
  providers: [{ provide: APP_INTERCEPTOR, useClass: BugslyInterceptor }],
})
export class AppModule {}

How It Works

Once initialized, the Bugsly NestJS SDK automatically instruments your application. Here's what happens behind the scenes:

  • Automatic error capture: Unhandled exceptions and promise rejections are caught and reported with full stack traces
  • Context enrichment: Each event includes environment data, request details, and user context where available
  • Intelligent grouping: Similar errors are grouped together so you see issues, not individual events
  • Performance data: Transaction traces help you understand the performance impact of errors

Customizing Your Integration

For NestJS projects, we recommend enabling these additional features after the basic setup:

  1. Source maps (if applicable) — upload source maps during your build so Bugsly can display readable stack traces
  2. User feedback — prompt users who encounter errors for additional context
  3. Custom tags — add business-specific metadata to events for filtering and analysis

Bugsly's dashboard will become your team's go-to tool for understanding what's happening in your NestJS production environment.

Try Bugsly Free

AI-powered error tracking that explains your bugs. Set up in 2 minutes, free forever for small projects.

Get Started Free