Source Maps
Learn how to enable readable stack traces in your Sentry errors.
The Sentry Astro SDK will generate and upload source maps automatically during a production build, so that errors in Sentry contain readable stack traces.
The Astro SDK uses the Sentry Vite Plugin to upload source maps. See the Manual Configuration page and the Sentry Vite plugin documentation for more details.
Source maps upload should work if you followed the Astro CLI installation guide. However, there are some options to configure source maps upload for your production builds for other configurations.
To automatically upload source maps during production builds, add the SENTRY_AUTH_TOKEN
environment variable to your environment, for example in a .env.sentry-build-plugin
file or in your CI setup.
.env.sentry-build-plugin
SENTRY_AUTH_TOKEN=sntrys_YOUR_TOKEN_HERE
Next, add your project slug to the sourceMapsUploadOptions
in your Astro config:
astro.config.mjs
export default defineConfig({
integrations: [
sentry({
// Other Sentry options
sourceMapsUploadOptions: {
project: 'example-project',
authToken: process.env.SENTRY_AUTH_TOKEN,
},
}),
],
});
You can disable automatic source maps upload in your Astro configuration with enabled: false
under sourceMapsUploadOptions
By default, the Sentry Astro integration will look for source maps in sensible default directories, depending on your outDir
, rootDir
and adapter
configuration. If these defaults don't work for you (for example, due to an advanced customized build setup or an unsupported adapter), you can specify the assets
option to point to the folder(s) where your source maps are located:
astro.config.mjs
export default defineConfig({
integrations: [
sentry({
sourceMapsUploadOptions: {
assets: ['.clientOut/**/*', '.serverOut/**/*'],
},
}),
],
});
The specified patterns must follow the glob syntax.
Source maps work best with organization-scoped auth tokens. If you are using an old self-hosted Sentry version that doesn't yet support org-based tokens or you're using a different type of Sentry auth token, refer to our legacy upload methods for more information.
The Astro SDK uses the Sentry Vite plugin to upload source maps. This plugin collects telemetry data to help us improve the source map uploading experience. Read more about this in our Vite plugin documentation. You can disable telemetry collection by setting telemetry:false
under sourceMapsUploadOptions
.
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").