← All platforms

Nest.js error tracking

Controllers, services, and one exception on its way out. The Sentry Nest.js integration sends the backtrace to Telebugs on your server.

~/hoofnotes  npm install @sentry/nestjs
~/hoofnotes  nvim src/instrument.ts src/main.ts src/app.module.ts
import * as Sentry from "@sentry/nestjs";
Sentry.init({
// Copy the complete Telebugs DSN, key and path included.
dsn: "YOUR_TELEBUGS_DSN",
});
import "./instrument";
import { NestFactory } from "@nestjs/core";
import { AppModule } from "./app.module";
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();
import { Module } from "@nestjs/common";
import { APP_FILTER } from "@nestjs/core";
import { SentryModule, SentryGlobalFilter } from "@sentry/nestjs/setup";
import { NotesModule } from "./notes/notes.module";
@Module({
imports: [SentryModule.forRoot(), NotesModule],
providers: [{ provide: APP_FILTER, useClass: SentryGlobalFilter }],
})
export class AppModule {}
~/hoofnotes  npm run start:dev

Space pauses or resumes. R replays. Escape shows the complete setup.

Hang on, I already use Sentry

Keep @sentry/nestjs and change its destination to your Telebugs DSN. Your error reports stay on your server. You don’t need a Sentry account.

Can I keep my exception filters?

Yes. Nest’s Sentry integration supports custom exception filters as well as its global filter. Expected HTTP errors needn’t drown out unexpected failures in your services.

What if the error starts in a service?

Its backtrace travels with the exception. When request handling reports it, Telebugs can show the calls through your controller and service code.