Skip to content

Files

Latest commit

6e775c6 · Apr 16, 2025

History

History
This branch is 10 commits behind develop.

gatsby

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 25, 2025
Nov 28, 2024
Feb 25, 2025
Feb 25, 2025
Jan 23, 2025
Feb 15, 2025
Jan 15, 2025
Apr 16, 2025
Dec 20, 2023
Jul 10, 2024
Mar 26, 2025
Feb 25, 2025
Mar 18, 2022
Feb 25, 2025

Sentry

Official Sentry SDK for GatsbyJS

First register the package as a plugin in gatsby-config.js:

module.exports = {
  // ...
  plugins: [
    {
      resolve: '@sentry/gatsby',
      options: {
        dsn: process.env.SENTRY_DSN, // this is the default
      },
    },
    // ...
  ],
};

Then configure your Sentry.init call:

import * as Sentry from '@sentry/gatsby';

Sentry.init({
  dsn: '__PUBLIC_DSN__',
  integrations: [Sentry.browserTracingIntegration(), Sentry.replayIntegration()],

  // Set tracesSampleRate to 1.0 to capture 100%
  // of transactions for performance monitoring.
  // We recommend adjusting this value in production
  tracesSampleRate: 1.0,

  // Capture Replay for 10% of all sessions,
  // plus for 100% of sessions with an error
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,

  // Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
  tracePropagationTargets: ['localhost', /^https:\/\/yourserver\.io\/api/],
});

The Gatsby SDK also automatically sets up sourcemaps uploading for you. To disable this functionality, set the enableClientWebpackPlugin option to be false.

module.exports = {
  // ...
  plugins: [
    {
      resolve: '@sentry/gatsby',
      options: {
        enableClientWebpackPlugin: false,
      },
    },
    // ...
  ],
};

Additionally, you can delete source map files after they have been uploaded by setting the deleteSourcemapsAfterUpload option to be true.

module.exports = {
  // ...
  plugins: [
    {
      resolve: '@sentry/gatsby',
      options: {
        deleteSourcemapsAfterUpload: true,
      },
    },
    // ...
  ],
};

Links