Basic Usage
Learn how to use Traque SDK with NestJS for exception tracking
Automatic Exception Tracking
Once you've set up Traque with the setupNestExceptionFilter
method in your application bootstrap, all unhandled exceptions will be automatically captured and reported to Traque:
Manual Exception Tracking
You can also manually capture exceptions using the captureException
method from your Traque instance:
Singleton Instance
Traque is designed to maintain a single instance throughout your application. The same instance that you initialize in your main.ts
file can be used across your application through dependency injection.
To use the Traque instance in your services or controllers:
Then inject it into your services:
Best Practices
-
Single Instance: Always use the same Traque instance throughout your application to ensure consistent error tracking and proper resource management.
-
Automatic Tracking: Let the automatic exception filter handle unexpected errors in your application.
-
Manual Tracking: Use manual tracking when you want to:
- Add custom context to exceptions
- Track handled exceptions
- Create custom error reports
-
Context: When manually tracking exceptions, provide meaningful context to help with debugging: