Skip to content

feat: integrate Sentry for error tracking and fix metrics DI startup …#55

Merged
EmeditWeb merged 1 commit into
StepFi-app:mainfrom
Truphile:feature/sentry-integration
Jun 19, 2026
Merged

feat: integrate Sentry for error tracking and fix metrics DI startup …#55
EmeditWeb merged 1 commit into
StepFi-app:mainfrom
Truphile:feature/sentry-integration

Conversation

@Truphile

Copy link
Copy Markdown
Contributor

Closes #12

I have completed the task successfully. Here is a summary of the work:

  1. Sentry Initialization:
    • Initialized Sentry via Sentry.init at the very top of main.ts, ensuring it runs before NestJS
    bootstraps.
    • Used process.env.SENTRY_TRACES_SAMPLE_RATE to support configuring the trace sample rate via environment
    variables (falling back to 0.1 as requested).
    • Configured process.env.SENTRY_DSN as an optional fallback ( process.env.SENTRY_DSN || undefined ) to
    ensure the application starts up gracefully as a no-op fallback when SENTRY_DSN is empty.

  2. NestJS Setup & Sentry Module:
    • Registered SentryModule.forRoot() in the imports list in app.module.ts.
    • Registered the SentryGlobalFilter globally as APP_FILTER under the providers array in app.module.ts,
    enabling all unhandled controller exceptions to be caught and logged directly to Sentry.

  3. Validation & Test Route:
    • Added a sentry-test endpoint to the HealthController in health.controller.ts which throws a deliberate
    error
    ( throw new Error('sentry test') ).
    • Decorated the endpoint with full Swagger @apioperation and @apiresponse decorators to conform to our
    standards, with no any types introduced.
    • Tested the endpoint locally and confirmed that unhandled exceptions are caught by the Sentry filter and
    logged.

  4. Environment Template:
    • Created the .env.example configuration template containing environment variable definitions, adding
    SENTRY_DSN= and SENTRY_TRACES_SAMPLE_RATE=0.1 , alongside other project variables.

  5. Fixed Pre-existing DI Bug:
    • Resolved a pre-existing DI error in the codebase's prometheus metrics setup which had prevented the
    application from starting:
    • Updated metrics.service.ts to use @InjectMetric(...) instead of Nest's generic @Inject(...) to allow
    @willsoto/nestjs-prometheus to correctly resolve the metric tokens.
    • Decorated MetricsModule with @global() in metrics.module.ts so that the MetricsService provider is
    globally accessible.
    • Removed MetricsController from the duplicate declaration in the controllers array in
    metrics.module.ts
    to avoid duplicated route binding errors in Fastify.

  6. Documentation & Progress tracking:
    • Added a section "Error tracking" in README.md documenting how to enable and configure Sentry.
    • Logged the work inside the progress-tracker.md file.
    • Verified that npm run build compiles with zero compiler warnings or errors.

@EmeditWeb EmeditWeb merged commit 58848c1 into StepFi-app:main Jun 19, 2026
1 check passed
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.

[20] Add Sentry error tracking to all modules

2 participants