Source Maps
Upload your source maps to Sentry to enable readable stack traces in your errors.
@sentry/nitro automatically generates and uploads source maps when you build your Nitro application for production, so that errors in Sentry contain readable stack traces.
Make sure you add your auth token to your CI, if you are using one to deploy your application.
Add your auth token to your environment:
.envSENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
To configure source map uploads, provide your Sentry auth token, organization, and project slugs to the withSentryConfig wrapper:
nitro.config.tsimport { defineNitroConfig } from "nitro/config";
import { withSentryConfig } from "@sentry/nitro";
const config = defineNitroConfig({
// your Nitro options...
});
export default withSentryConfig(config, {
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",
authToken: process.env.SENTRY_AUTH_TOKEN,
});
import { defineNitroConfig } from "nitro/config";
import { withSentryConfig } from "@sentry/nitro";
const config = defineNitroConfig({
// your Nitro options...
});
export default withSentryConfig(config, {
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",
authToken: process.env.SENTRY_AUTH_TOKEN,
});
Source maps are only uploaded during production builds. Development builds (nitro dev) skip the upload.
See how uploading source maps lets you see the exact line of code that caused an error:
When you wrap your config with withSentryConfig, the SDK:
- Enables source map generation if you haven't set the
sourcemapoption yourself - Injects debug IDs into your build output
- Uploads source maps to Sentry after each production build
- Deletes
.mapfiles from the build output to avoid exposing them publicly
Source maps are only uploaded during production builds. Development builds (nitro dev) skip the upload.
If you already set sourcemap in your Nitro config, the SDK respects your setting:
true: the SDK uploads the generated mapsfalse: the SDK warns that errors won't be unminified and skips the upload
You can customize source map behavior in the Sentry options:
nitro.config.tsimport { defineNitroConfig } from "nitro/config";
import { withSentryConfig } from "@sentry/nitro";
const config = defineNitroConfig({
// your Nitro options...
});
export default withSentryConfig(config, {
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",
authToken: process.env.SENTRY_AUTH_TOKEN,
sourcemaps: {
// Glob pattern for source map files to upload
assets: [".output/server/**"],
// Glob pattern for files to exclude from upload
ignore: ["node_modules/**"],
// Delete source maps after upload to avoid exposing them publicly
filesToDeleteAfterUpload: [".output/server/**/*.map"],
},
});
import { defineNitroConfig } from "nitro/config";
import { withSentryConfig } from "@sentry/nitro";
const config = defineNitroConfig({
// your Nitro options...
});
export default withSentryConfig(config, {
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",
authToken: process.env.SENTRY_AUTH_TOKEN,
sourcemaps: {
// Glob pattern for source map files to upload
assets: [".output/server/**"],
// Glob pattern for files to exclude from upload
ignore: ["node_modules/**"],
// Delete source maps after upload to avoid exposing them publicly
filesToDeleteAfterUpload: [".output/server/**/*.map"],
},
});
To disable source map uploads entirely, set sourcemaps.disable to true:
nitro.config.tsexport default withSentryConfig(config, {
sourcemaps: {
disable: true,
},
});
export default withSentryConfig(config, {
sourcemaps: {
disable: true,
},
});
To generate and inject debug IDs without uploading (useful if you upload maps separately), set sourcemaps.disable to "disable-upload":
nitro.config.tsexport default withSentryConfig(config, {
sourcemaps: {
disable: "disable-upload",
},
});
export default withSentryConfig(config, {
sourcemaps: {
disable: "disable-upload",
},
});
If you're experiencing issues with source maps, see Troubleshooting Source Maps.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").