Skip to content

[20] Add Sentry error tracking to all modules #12

Description

@EmeditWeb

Problem

@sentry/nestjs is installed in package.json but SentryModule.forRoot() is not registered in app.module.ts, and main.ts does not initialize Sentry. Unhandled exceptions are logged to stdout only — invisible in production.

Context

Render's free-tier logs roll over fast. Without an external error sink, real production issues vanish before the team sees them. Sentry is the table-stakes minimum.

Before Starting

Read these context files first:

  • context/architecture-context.md
  • context/code-standards.md
  • context/progress-tracker.md
  • package.json
  • src/main.ts
  • src/app.module.ts

What To Build

  1. Call Sentry.init({ dsn: process.env.SENTRY_DSN, environment: process.env.NODE_ENV, tracesSampleRate: 0.1 }) at the very top of main.ts, before NestFactory.create.
  2. Register SentryModule.forRoot() in app.module.ts.
  3. Add SentryGlobalFilter to APP_FILTER so all unhandled exceptions report to Sentry.
  4. Add SENTRY_DSN= and NODE_ENV=development to .env.example.
  5. Verify integration locally with a deliberate throw new Error('sentry test') in a test endpoint — confirm event lands in Sentry.
  6. Add a README section "Error tracking" describing how to enable Sentry.

Files To Touch

  • src/main.ts
  • src/app.module.ts
  • .env.example
  • README.md

Acceptance Criteria

  • Sentry initializes before Nest bootstrap
  • Unhandled exceptions in any controller reach Sentry
  • App still starts when SENTRY_DSN is empty (no-op fallback)
  • traces_sample_rate is configurable via env
  • README documents the env vars
  • No any types introduced

Mandatory Checks Before PR

  • npm run build passes with zero TypeScript errors
  • No new any types introduced anywhere
  • Full Swagger @apioperation + @apiresponse decorators on any new endpoints
  • New migration file created for any schema changes
  • context/progress-tracker.md updated

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions