Skip to content

traque-dev/nest-traque-sentry-sdk-example

Repository files navigation

Traque Sentry SDK Example

This repository demonstrates how to use the standard Sentry SDK with Traque by simply configuring a Traque-compatible DSN.

Traque is API-compatible with Sentry, meaning you can use existing Sentry SDKs to send errors and events to your Traque instance.

Prerequisites

  • Node.js
  • pnpm (or npm/yarn)
  • A running Traque instance (or use the cloud version)

Setup

  1. Install dependencies

    pnpm install
  2. Configure Environment

    Create a .env file in the root directory:

    SENTRY_DSN=https://<your-traque-public-key>@<your-traque-host>/<project-id>
    PORT=3000

    Important: Replace the SENTRY_DSN value with your Traque DSN.

    • If you are running Traque locally, it might look like: http://<public-key>@localhost:8000/<project-id>
    • The Sentry SDK will send events to this URL, effectively reporting to Traque instead of Sentry.

How it works

The project uses the standard @sentry/nestjs package.

  1. Initialization: In src/instrument.ts, Sentry is initialized with the DSN from the environment variables.

    import * as Sentry from '@sentry/nestjs';
    
    Sentry.init({
      dsn: process.env.SENTRY_DSN, // Your Traque DSN goes here
      // ... other config
    });
  2. Global Filter: The application uses a global exception filter (src/global-exception-filter.ts) to capture exceptions.

  3. Bootstrap: src/main.ts imports the instrumentation before the app starts.

    import './instrument';
    // ...

Running the App

# development
pnpm run start

# watch mode
pnpm run start:dev

Testing the Integration

  1. Start the application.

  2. Trigger a test error using one of the built-in routes:

    • 500 Error: GET /error

      curl http://localhost:3000/error

      This throws a standard Error('Test 500 Error').

    • 400 Bad Request: POST /

      curl -X POST http://localhost:3000/

      This throws a BadRequestException.

  3. Check your Traque dashboard to see the reported errors.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors