Sentry

This page explains how to set up Sentry debugging tools

Create Sentry Project

Step 1: Create a New Project on Sentry

  1. Go to Sentry and create new or log in to your account.

  2. In your dashboard, select Projects > Create Project.

  3. Choose NestJS as the platform.

  4. Name your project, assign it to a team, and click Create Project.

  5. After project creation, you’ll see a DSN (Data Source Name) key on the setup page. This DSN is essential for connecting your NestJS app to Sentry.

  6. Copy the DSN, as you’ll need it for environment variables.

API Setup

  1. Install dependencies

yarn add @sentry/nestjs @sentry/profiling-node
  1. Setup enviroment variables

.env
SENTRY_DNS=your_dsn
SENTRY_ENVIRONMENT=your_enviroment # 'development', 'production', etc.
constants.ts
SENTRY_DNS: process.env.SENTRY_DNS,
SENTRY_ENVIRONMENT: process.env.SENTRY_ENVIRONMENT,
  1. Initialize Sentry

In Sentry initialization file, you can set up Sentry with tracing and profiling, along with advanced configuration options to manage error handling more effectively.

  1. Create Sentry filter

The Sentry filter allows you to add context to each error, making debugging more insightful by providing request details and user information without exposing sensitive data.

  1. Initialize filter

In your main application module, register the Sentry filter globally.

After completing this steps you should be able to create test endopoint and catch your first error.

Last updated