Browser
Server
Native OpenTelemetry
Fullstack Frameworks
Overview
Self Host & Local Dev
Menu
Nest.js Quick Start
Learn how to set up highlight.io in Nest.js.
1
Configure client-side Highlight. (optional)
If you're using Highlight on the frontend for your application, make sure you've initialized it correctly and followed the fullstack mapping guide.
2
Install the relevant Highlight SDK(s).
Install @highlight-run/nest with your package manager.
npm install --save @highlight-run/nest
3
Add the @highlight-run/nest app middleware.
Use the HighlightErrorFilter
middleware to capture backend errors.
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { HighlightInterceptor, H } from '@highlight-run/nest';
const env = {
projectID: '<YOUR_PROJECT_ID>',
serviceName: 'my-nestjs-app',
serviceVersion: 'git-sha',
environment: 'production',
debug: false,
};
async function bootstrap() {
H.init(env);
const app = await NestFactory.create(AppModule);
app.useGlobalInterceptors(new HighlightInterceptor(env));
await app.listen(3000);
}
bootstrap();
4
Optionally, report manual errors in your app.
If you need to report exceptions outside of a handler, use the Highlight SDK.
const parsed = H.parseHeaders(request.headers)
H.consumeError(error, parsed?.secureSessionId, parsed?.requestId)
5
Verify that your SDK is reporting errors.
You'll want to throw an exception in one of your Nest.js handlers. Access the API handler and make sure the error shows up in Highlight.
import { Injectable } from '@nestjs/common'
@Injectable()
export class AppService {
getHello(): string {
console.log('hello, world!')
console.warn('whoa there! ', Math.random())
if (Math.random() < 0.2) {
// error will be caught by the HighlightErrorFilter
throw new Error(`a random error occurred! 0.8006699662111119`)
}
return 'Hello World!'
}
}
6
Verify your backend logs are being recorded.
Visit the highlight logs portal and check that backend logs are coming in.
7
Verify your backend traces are being recorded.
Visit the highlight traces portal and check that backend traces are coming in.