---
title: "Installation"
description: "Install and configure @eienjs/adonisjs-sentry in your AdonisJS v7 application."
canonical_url: "https://eienjs.com/packages/adonisjs-sentry/getting-started/installation"
---

> Index of every page on this site: [llms.txt](https://eienjs.com/llms.txt)

## Requirements

Ensure your environment satisfies the peer dependencies:

- **Node.js**: `>= 24.0.0`
- **AdonisJS Core** (`@adonisjs/core`): `^7.6.0`
- **Sentry Node SDK** (`@sentry/node`): `^11.12.0`

## Automated Installation

The fastest way to install and configure `@eienjs/adonisjs-sentry` is using the AdonisJS `ace add` command:

```bash
node ace add @eienjs/adonisjs-sentry
```

This single command will:

1. Install `@eienjs/adonisjs-sentry` and `@sentry/node` using your project's package manager.
2. Publish the `config/sentry.ts` configuration file.
3. Append `SENTRY_DSN` and `SENTRY_RELEASE` to your `.env` and `.env.example` files.
4. Define environment validation rules in `start/env.ts`.
5. Register `@eienjs/adonisjs-sentry/middleware/sentry_middleware` in your router middleware stack.
6. Register the provider and commands in your `adonisrc.ts` file.

## Manual Installation

If you prefer installing packages manually, install `@eienjs/adonisjs-sentry` and its peer dependency `@sentry/node`:

<code-group>

```bash [pnpm]
pnpm add @eienjs/adonisjs-sentry @sentry/node
```

```bash [npm]
npm install @eienjs/adonisjs-sentry @sentry/node
```

```bash [yarn]
yarn add @eienjs/adonisjs-sentry @sentry/node
```

</code-group>

Then run the `configure` command:

```bash
node ace configure @eienjs/adonisjs-sentry
```

## Step-by-Step Setup

<steps>

### 1. Configure the Exception Handler

Open `app/exceptions/handler.ts` and call `reportException` inside the `report` method:

```ts [app/exceptions/handler.ts]
import type { HttpContext } from '@adonisjs/core/http';
import { ExceptionHandler } from '@adonisjs/core/http';
import { reportException } from '@eienjs/adonisjs-sentry';

export default class HttpExceptionHandler extends ExceptionHandler {
  async report(error: unknown, ctx: HttpContext) {
    reportException(error, ctx);

    await super.report(error, ctx);
  }
}
```

<note>

`reportException` automatically checks whether Sentry is initialized and skips reporting if the exception matches any configured ignore lists.

</note>

### 2. Set Your Environment Variables

Add your Sentry project DSN to your `.env` file:

```dotenv [.env]
SENTRY_DSN=https://examplePublicKey@o0.ingest.sentry.io/0
SENTRY_RELEASE=
```

<tip>

`SENTRY_DSN` is only required when Sentry is enabled (by default in production). You can safely omit it in development or testing environments.

</tip>

### 3. Verify the Integration

Execute the Ace verification command to test whether your application can deliver an event to Sentry:

```bash
node ace sentry:verify
```

If successful, the command prints the generated Sentry event ID. For more details on the verification command, see the [Verify Command](https://eienjs.com/packages/adonisjs-sentry/usage/verify-command) documentation.

</steps>

## What's Next?

Check out the [Configuration](https://eienjs.com/packages/adonisjs-sentry/getting-started/configuration) guide to customize sampling rates, ignore filters, release tags, and privacy settings.

## Sitemap

See the full [sitemap](https://eienjs.com/sitemap.md) for all pages.
