Skip to content

Use sentry #4599

Answered by RomainLanz
rutonyru asked this question in Help
May 31, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hey @rutonyru! 👋🏻

There is no need to use a dedicated library to use Sentry with AdonisJS.
You can directly install their SDK and start working from there.

Here is an example I have in production. It is a middleware that is executed to encapsulate the request and send telemetry information about it to Sentry (if you activate it inside Sentry).

import * as Sentry from '@sentry/node';
import type { HttpContext } from '@adonisjs/core/http';
import type { NextFn } from '@adonisjs/core/types/http';

export default class MonitoringMiddleware {
  async handle(ctx: HttpContext, next: NextFn) {
    const client = Sentry.getClient();
    const scope = new Sentry.Scope();
    scope.setClient(client);

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rutonyru
Comment options

@RomainLanz
Comment options

Answer selected by rutonyru
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants