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

Connecting the SDK to Sentry

Register the plugin in your Gatsby configuration file (typically gatsby-config.js).

gatsby-config.js
Copied
{
  // ...
  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.

Copied
{
  // ...
  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_ENV or development

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_SHA or process.env.VERCEL_GITLAB_COMMIT_SHA or process.env.VERCEL_BITBUCKET_COMMIT_SHA
You can edit this page on GitHub.