---
title: "Configuration"
description: "Customize Sentry options, sampling rates, PII settings, and exception ignore lists in config/sentry.ts."
canonical_url: "https://eienjs.com/packages/adonisjs-sentry/getting-started/configuration"
---

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

The configuration for `@eienjs/adonisjs-sentry` is located in `config/sentry.ts`. It uses the `defineConfig` helper to ensure type safety and validate essential options before the application boots.

## Default Configuration

```ts [config/sentry.ts]
import app from '@adonisjs/core/services/app';
import { defineConfig } from '@eienjs/adonisjs-sentry';
import env from '#start/env';

const sentryConfig = defineConfig({
  /**
   * Enable or disable Sentry
   */
  enabled: app.inProduction,

  /**
   * The environment Sentry is running in
   */
  environment: app.nodeEnvironment,

  /**
   * The DSN of the project
   */
  dsn: env.get('SENTRY_DSN'),

  /**
   * The release identifier, used to match events with source maps
   * @see https://docs.sentry.io/platforms/javascript/guides/node/configuration/releases
   */
  release: env.get('SENTRY_RELEASE'),

  /**
   * Additional integrations to use with the Sentry SDK
   * @see https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/#available-integrations
   */
  integrations: [],

  /**
   * Do not send personally identifiable information (email, IP) by default
   * @see https://docs.sentry.io/platforms/javascript/guides/node/configuration/options/#dataCollection
   */
  dataCollection: {
    userInfo: false,
  },

  /**
   * The sample rate of traces to send to Sentry
   * @see https://docs.sentry.io/platforms/javascript/guides/node/configuration/sampling
   */
  tracesSampleRate: 0.2,

  /**
   * Control which exceptions are reported to Sentry.
   */
  report: {
    ignoreStatuses: [],
    ignoreCodes: [],
    ignoreExceptions: [],
    captureUser: true,
    fingerprintByCode: true,
  },
});

export default sentryConfig;
```

## Validation Rules

When `defineConfig` evaluates your configuration object, it performs two critical runtime checks:

1. **environment is required**: If missing or empty, `RuntimeException` is thrown.
2. **dsn is required when enabled is true**: If `enabled: true` and `dsn` is missing or undefined, `RuntimeException` is thrown.
3. If `enabled` is `false`, `dsn` can safely be omitted or left blank.

## Configuration Options

### Top-Level Options

<table>
<thead>
  <tr>
    <th align="left">
      Option
    </th>
    
    <th align="left">
      Type
    </th>
    
    <th align="left">
      Default
    </th>
    
    <th align="left">
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td align="left">
      <code>
        enabled
      </code>
    </td>
    
    <td align="left">
      <code>
        boolean
      </code>
    </td>
    
    <td align="left">
      <code>
        app.inProduction
      </code>
    </td>
    
    <td align="left">
      Toggles Sentry SDK initialization and exception reporting.
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        environment
      </code>
    </td>
    
    <td align="left">
      <code>
        string
      </code>
    </td>
    
    <td align="left">
      <code>
        app.nodeEnvironment
      </code>
    </td>
    
    <td align="left">
      The environment name (e.g. <code>
        production
      </code>
      
      , <code>
        staging
      </code>
      
      , <code>
        development
      </code>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        dsn
      </code>
    </td>
    
    <td align="left">
      <code>
        string
      </code>
    </td>
    
    <td align="left">
      <code>
        env.get('SENTRY_DSN')
      </code>
    </td>
    
    <td align="left">
      The Sentry Data Source Name. Required when <code>
        enabled
      </code>
      
       is <code>
        true
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        release
      </code>
    </td>
    
    <td align="left">
      <code>
        string
      </code>
    </td>
    
    <td align="left">
      <code>
        env.get('SENTRY_RELEASE')
      </code>
    </td>
    
    <td align="left">
      Release identifier matching events with uploaded source maps.
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        integrations
      </code>
    </td>
    
    <td align="left">
      <code>
        Integration[]
      </code>
    </td>
    
    <td align="left">
      <code>
        []
      </code>
    </td>
    
    <td align="left">
      Additional integrations from <code>
        @sentry/node
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        dataCollection
      </code>
    </td>
    
    <td align="left">
      <code>
        { userInfo: boolean }
      </code>
    </td>
    
    <td align="left">
      <code>
        { userInfo: false }
      </code>
    </td>
    
    <td align="left">
      When <code>
        userInfo: false
      </code>
      
      , user email and IP addresses are stripped for PII compliance.
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        tracesSampleRate
      </code>
    </td>
    
    <td align="left">
      <code>
        number
      </code>
    </td>
    
    <td align="left">
      <code>
        0.2
      </code>
    </td>
    
    <td align="left">
      Percentage of performance traces captured (between <code>
        0.0
      </code>
      
       and <code>
        1.0
      </code>
      
      ).
    </td>
  </tr>
</tbody>
</table>

<note>

`SentryConfig` extends Sentry's native `NodeOptions` (omitting `dsn` and `environment`). You can pass any standard Sentry Node configuration option here, such as `beforeSend`, `maxBreadcrumbs`, `debug`, or `sampleRate`.

</note>

### `report` Options

The `report` property controls exception capture behavior when invoking `reportException(error, ctx)`:

<table>
<thead>
  <tr>
    <th align="left">
      Option
    </th>
    
    <th align="left">
      Type
    </th>
    
    <th align="left">
      Default
    </th>
    
    <th align="left">
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td align="left">
      <code>
        report.ignoreStatuses
      </code>
    </td>
    
    <td align="left">
      <code>
        number[]
      </code>
    </td>
    
    <td align="left">
      <code>
        []
      </code>
    </td>
    
    <td align="left">
      HTTP status codes that will not be sent to Sentry (e.g. <code>
        [404, 422]
      </code>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        report.ignoreCodes
      </code>
    </td>
    
    <td align="left">
      <code>
        string[]
      </code>
    </td>
    
    <td align="left">
      <code>
        []
      </code>
    </td>
    
    <td align="left">
      Adonis error codes that will not be sent to Sentry (e.g. <code>
        ['E_ROUTE_NOT_FOUND']
      </code>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        report.ignoreExceptions
      </code>
    </td>
    
    <td align="left">
      <code>
        ExceptionConstructor[]
      </code>
    </td>
    
    <td align="left">
      <code>
        []
      </code>
    </td>
    
    <td align="left">
      Exception classes checked via <code>
        instanceof
      </code>
      
       to ignore.
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        report.captureUser
      </code>
    </td>
    
    <td align="left">
      <code>
        boolean
      </code>
    </td>
    
    <td align="left">
      <code>
        true
      </code>
    </td>
    
    <td align="left">
      Whether to attach <code>
        ctx.auth.user
      </code>
      
       to the Sentry event scope.
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        report.fingerprintByCode
      </code>
    </td>
    
    <td align="left">
      <code>
        boolean
      </code>
    </td>
    
    <td align="left">
      <code>
        true
      </code>
    </td>
    
    <td align="left">
      Group Sentry issues by Adonis error code (<code>
        E_*
      </code>
      
      ) instead of raw error message.
    </td>
  </tr>
</tbody>
</table>

### Example: Ignoring Common HTTP Errors

In production, you usually want to avoid filling your Sentry quota with client-side validation errors (`422`) or missing routes (`404`):

```ts [config/sentry.ts]
import { errors as authErrors } from '@adonisjs/auth';
import { errors as coreErrors } from '@adonisjs/core';
import { defineConfig } from '@eienjs/adonisjs-sentry';

export default defineConfig({
  // ... other options
  report: {
    ignoreStatuses: [404, 422],
    ignoreCodes: [
      'E_ROUTE_NOT_FOUND',
      'E_VALIDATION_ERROR',
      'E_INVALID_AUTH_SESSION',
    ],
    ignoreExceptions: [
      coreErrors.E_ROUTE_NOT_FOUND,
      authErrors.E_UNAUTHORIZED_ACCESS,
    ],
    captureUser: true,
    fingerprintByCode: true,
  },
});
```

To learn more about how reporting works under the hood, see [Exception Reporting](https://eienjs.com/packages/adonisjs-sentry/usage/exception-reporting).

## Sitemap

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