Skip to content

Gatsby: Sentry.captureException() doesn't work unless reinitialized #5727

Closed as not planned
@JordanVincent

Description

@JordanVincent

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/gatsby

SDK Version

7.12.1

Framework Version

Gatsby 4.14.1

Link to Sentry event

No response

Steps to Reproduce

Initialize the plugin in gatsby-config.js:

module.exports = {
  plugins: [
    {
      resolve: '@sentry/gatsby',
      options: {
        dsn: 'XXXX',
      },
    },
  ],
}

On the client (e.g. inside a component):

import * as Sentry from '@sentry/gatsby';
Sentry.captureException(new Error('error');

Expected Result

An exception should be sent to Sentry.

Actual Result

Nothing is sent to Sentry (nothing at sentry.io or in the browser's network tab) unless calling Sentry.init({ dns: 'XXXX' }) before calling Sentry.captureException(). Unhandled exceptions are properly captured, but not manual calls to Sentry.captureException().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions