Gatsby
To use Sentry with your Gatsby application, you will need to use @sentry/gatsby (Sentry’s Gatsby SDK):
npm install --save @sentry/gatsby@sentry/gatsby is a wrapper around the @sentry/react package, with added functionality related to Gatsby. All methods available in the @sentry/react package can also be imported from @sentry/gatsby.
Connecting the SDK to Sentry
Register the plugin in your Gatsby configuration file (typically gatsby-config.js).
gatsby-config.js{
// ...
plugins: [
{
resolve: "@sentry/gatsby",
options: {
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
},
},
// ...
];
}Options
The options field in the plugin configuration is passed directly to Sentry.init. Check our configuration docs for a full list of the available options.
For example, the configuration below adjusts the sampleRate and maxBreadcrumbs options.
{
// ...
plugins: [
{
resolve: "@sentry/gatsby",
options: {
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
maxBreadcrumbs: 80,
sampleRate: 0.7,
},
},
// ...
];
}The Gatsby SDK will set certain options automatically based on environmental variables, but these can be overridden by setting custom options in the plugin configuration.
environment(string)- Defaults to
process.env.NODE_ENVordevelopment
release(string)- Defaults to certain environmental variables based on the platform
- GitHub Actions:
process.env.GITHUB_SHA - Netlify:
process.env.COMMIT_REF - Vercel:
process.env.VERCEL_GITHUB_COMMIT_SHAorprocess.env.VERCEL_GITLAB_COMMIT_SHAorprocess.env.VERCEL_BITBUCKET_COMMIT_SHA
- Package:
- npm:@sentry/gatsby
- Version:
- 5.25.0
- Repository:
- https://github.com/getsentry/sentry-javascript