---
title: "Source Maps and Releases"
description: "Associate Sentry releases with source maps to display original TypeScript code in stack traces."
canonical_url: "https://eienjs.com/packages/adonisjs-sentry/advanced/source-maps-and-releases"
---

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

In production, AdonisJS applications run compiled JavaScript located in the `build/` directory. By associating errors with a specific release and uploading source maps to Sentry, your Sentry dashboard will display original TypeScript filenames and line numbers instead of minified build artifacts.

## Setting the Release Identifier

Define the `SENTRY_RELEASE` environment variable in your production environment. A common practice is using the Git commit SHA or a release tag:

```dotenv [.env]
SENTRY_RELEASE=a8f42d87e1a3d90f230234
```

In automated CI/CD pipelines (e.g. GitHub Actions), you can set this dynamically:

```bash
export SENTRY_RELEASE=${GITHUB_SHA}
```

The default `config/sentry.ts` stub automatically passes `env.get('SENTRY_RELEASE')` to Sentry:

```ts [config/sentry.ts]
export default defineConfig({
  // ...
  release: env.get('SENTRY_RELEASE'),
});
```

## Generating Source Maps

Ensure that TypeScript emits source maps during the build by checking your `tsconfig.json`:

```json [tsconfig.json]
{
  "compilerOptions": {
    "sourceMap": true
  }
}
```

When you build your application using `node ace build`, source map files (`.js.map`) will be emitted alongside compiled JavaScript files in the `build/` folder.

## Uploading Source Maps via Sentry CLI

Install `@sentry/cli` as a development dependency or run it via `npx`:

```bash
npm install --save-dev @sentry/cli
```

### Authentication Environment Variables

Set the required Sentry CLI authentication variables in your CI/CD runner:

- `SENTRY_AUTH_TOKEN`: Sentry user or internal integration authentication token.
- `SENTRY_ORG`: Your Sentry organization slug.
- `SENTRY_PROJECT`: Your Sentry project slug.

### Upload Script

Add a deployment or build step that uploads the generated source maps:

```bash
# 1. Build the AdonisJS application
node ace build

# 2. Upload source maps for the current release
npx @sentry/cli sourcemaps upload \
  --release="${SENTRY_RELEASE}" \
  ./build

# 3. (Optional) Delete .map files if you prefer not to include them in production docker images
find ./build -name "*.map" -type f -delete
```

<tip>

Deleting `.map` files after uploading them to Sentry prevents exposing your original source maps publicly while allowing Sentry to accurately de-minify stack traces.

</tip>

## Sitemap

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