Gatsby
To use Sentry with your Gatsby application, you will need to use @sentry/gatsby
(Sentry’s Gatsby SDK):
Copied
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
.
First add @sentry/gatsby
as a plugin to your gatsby-config.js
.
gatsby-config.js
Copied
module.exports = {
plugins: [
{
resolve: "@sentry/gatsby",
},
],
};
Then, configure your Sentry.init
:
sentry.config.js
Copied
import * as Sentry from "@sentry/gatsby";
Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
tracesSampleRate: 1.0, // Adjust this value in production
beforeSend(event) {
// Modify the event here
if (event.user) {
// Don't send user's email address
delete event.user.email;
}
return event;
},
// ...
});
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.36.0
- Repository:
- https://github.com/getsentry/sentry-javascript