Skip to content

feat(sentry): integrate Sentry for error tracking and performance mon…#42

Merged
memplethee-lab merged 1 commit into
SourceXXL:mainfrom
A-one-tech:alian_structure-api
Jun 20, 2026
Merged

feat(sentry): integrate Sentry for error tracking and performance mon…#42
memplethee-lab merged 1 commit into
SourceXXL:mainfrom
A-one-tech:alian_structure-api

Conversation

@A-one-tech

Copy link
Copy Markdown

closes #23

PR: Add Sentry Error Tracking Integration

Summary

This PR integrates Sentry into the NestJS backend for centralized error reporting, performance tracing, and production monitoring.

What changed

  • Added src/config/sentry.ts to initialize Sentry with DSN, environment, release, traces sampling, and uncaught exception / unhandled rejection handling.
  • Added src/common/middleware/sentry.middleware.ts to capture request-level breadcrumbs for request method, path, params, and query context.
  • Updated src/main.ts to initialize Sentry during bootstrap and register request/tracing middleware.
  • Enhanced src/common/filters/global-exception.filter.ts to report server errors and auth failures to Sentry with request tags and correlation IDs.
  • Expanded environment validation in src/config/env.validation.ts to include SENTRY_DSN, SENTRY_ENVIRONMENT, SENTRY_RELEASE, and SENTRY_TRACES_SAMPLE_RATE.
  • Added Sentry configuration examples to .env.example and .env.production.example.
  • Documented the Sentry configuration in README.md.
  • Added @sentry/node to package.json.

Files changed

  • src/config/sentry.ts
  • src/common/middleware/sentry.middleware.ts
  • src/main.ts
  • src/common/filters/global-exception.filter.ts
  • src/config/env.validation.ts
  • .env.example
  • .env.production.example
  • README.md
  • package.json

Environment variables added

  • SENTRY_DSN
  • SENTRY_ENVIRONMENT
  • SENTRY_RELEASE
  • SENTRY_TRACES_SAMPLE_RATE

Notes for reviewers

  • Sentry initialization is intentionally skipped when SENTRY_DSN is not set.
  • The global exception filter sends 500, 401, and 403 errors to Sentry for alerting and grouping.
  • Uncaught exceptions and unhandled promise rejections are flushed before process exit.

Testing

  • Run npm install after package.json update.
  • Start the app with a valid SENTRY_DSN and verify startup logs include Sentry initialized.
  • Trigger a handled error through a controller and confirm the event appears in Sentry.
  • Trigger an uncaught exception to verify the process flushes Sentry events before exit.

@memplethee-lab memplethee-lab merged commit 313b25b into SourceXXL:main Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setup Error Tracking & Alerting (Sentry Integration)

3 participants