bugg-lens-nestjs
v1.0.0
Published
NestJS integration for Bugg Lens.
Maintainers
Readme
bugg-lens-nestjs
NestJS integration for Bugg Lens error tracking and real-time debugging.
Installation
npm install bugg-lens-nestjsConfiguration
Import and configure the BuggLensModule inside your root AppModule.
import { Module } from '@nestjs/common';
import { BuggLensModule } from 'bugg-lens-nestjs';
@Module({
imports: [
BuggLensModule.forRoot({
dsn: process.env.BUGG_LENS_DSN || '[https://your-backend.example.com](https://your-backend.example.com)',
}),
],
})
export class AppModule {}Usage: Capturing Errors
Inject the BuggLens instance into your services using the BUGG_LENS token to capture errors manually.
import { Inject, Injectable } from '@nestjs/common';
import { BUGG_LENS, BuggLensService } from 'bugg-lens-nestjs';
@Injectable()
export class AppService {
constructor(private readonly buggLens: BuggLensService) {}
async run() {
try {
throw new Error('Something failed');
} catch (error) {
this.buggLens.captureException(error);
}
}
}Real-Time Debugging
Bugg Lens provides a built-in real-time debugging UI to monitor your application and you can use the debugger without dsn.
1. Enable Debug Mode
Add the following environment variable to your .env file:
BUGG_LENS_DEBUG=true2. Import the Debug Module
Include the DebugModule alongside your BuggLensModule configuration in your AppModule.
import { Module } from '@nestjs/common';
import { BuggLensModule, DebugModule } from 'bugg-lens-nestjs';
@Module({
imports: [
BuggLensModule.forRoot({
dsn: process.env.BUGG_LENS_DSN || '[https://your-backend.example.com](https://your-backend.example.com)',
stream: true,
}),
DebugModule,
],
})
export class AppModule {}3. Access the UI
Open your browser and navigate to the following URL to view the real-time debugging interface:
http://localhost/bugg-lens4. Test the Debugger
Define a test route in one of your controllers to intentionally trigger an error:
import { Controller, Get } from '@nestjs/common';
@Controller()
export class AppController {
@Get('debug')
debug() {
throw new Error('Error Test');
}
}