Webpack
Sentry uses releases to match the correct source maps to your events. You can use the Sentry Webpack plugin to automatically create releases and upload source maps to Sentry when bundling your app.
Installation
Copied
npm install --save-dev @sentry/webpack-plugin
Configuration
Learn more about configuring the plugin in our Sentry Webpack Plugin documentation.
Example:
gatsby-node.js
Copied
const SentryWebpackPlugin = require("@sentry/webpack-plugin");
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
plugins: [
new SentryWebpackPlugin({
org: "example-org",
project: "example-project",
ignore: ["app-*", "polyfill-*", "framework-*", "webpack-runtime-*"],
// Specify the directory containing build artifacts
include: "public",
// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and needs the `project:releases` and `org:read` scopes
authToken: process.env.SENTRY_AUTH_TOKEN,
// Optionally uncomment the line below to override automatic release name detection
// release: process.env.RELEASE,
}),
],
});
};
If you use SourceMapDevToolPlugin for more fine-grained control of source map generation, turn off noSources
so Sentry can display proper source code context in event stack traces.
The Sentry Webpack plugin will automatically inject a release value into the SDK so you must either omit the release
option from Sentry.init
or make sure Sentry.init
's release
option matches the plugin's release
option exactly:
Copied
Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
// When using the plugin, either remove the `release`` property here entirely or
// make sure that the plugin's release option and the Sentry.init()'s release
// option match exactly.
// release: "my-example-release-1"
});
Help improve this content
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").
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/gatsby
- Version:
- 7.46.0
- Repository:
- https://github.com/getsentry/sentry-javascript