Source Maps
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.
Configure Source Maps Upload
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.
Enable Source Maps Upload
To automatically upload source maps during production builds, add the SENTRY_AUTH_TOKEN
environment variable to your environment, for example in a .env
file or in your CI setup.
.env
SENTRY_AUTH_TOKEN=sntrys_YOUR_TOKEN_HERE
Next, add your
sourceMapsUploadOptions
in your Astro config:astro.config.mjs
export default defineConfig({
integrations: [
sentryAstro({
// Other Sentry options
sourceMapsUploadOptions: {
project: "example-project",
authToken: process.env.SENTRY_AUTH_TOKEN,
},
}),
],
});
Working With Old Authentication Tokens
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
org
slug in your sourceMapsUploadOptions
:astro.config.mjs
export default defineConfig({
integrations: [
sentryAstro({
// Other Sentry options
sourceMapsUploadOptions: {
project: "example-project",
org: "example-org",
authToken: process.env.SENTRY_AUTH_TOKEN,
},
}),
],
});
Disable Source Maps Upload
You can disable automatic source maps upload in your Astro config:
astro.config.mjs
export default defineConfig({
integrations: [
sentryAstro({
// Other Sentry options
sourceMapsUploadOptions: {
enabled: false,
},
}),
],
});
Disabeling Telemetry Data Collection
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
to false
:
astro.config.mjs
export default defineConfig({
integrations: [
sentryAstro({
// Other Sentry options
sourceMapsUploadOptions: {
telemetry: false,
},
}),
],
});
Additional Resources
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").
- Package:
- npm:@sentry/astro
- Version:
- 7.74.1
- Repository:
- https://github.com/getsentry/sentry-javascript