sentry-javascript
sentry-javascript copied to clipboard
Gatsby: Sentry.captureException() doesn't work unless reinitialized
Is there an existing issue for this?
- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- [X] I have reviewed the documentation https://docs.sentry.io/
- [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
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()
.
Hey, thanks for writing in! Does this also happen when using a sentry.config.js
file as per https://docs.sentry.io/platforms/javascript/guides/gatsby/#sentry-configuration-file?
Same thing with sentry.config.js
. However, I tried downgrading to 6.19.7
and it worked! So version 7 may have introduced a breaking change.
Ah yes we did do this - https://github.com/getsentry/sentry-javascript/pull/4857, but not sure why manual calls are not working.
Will backlog, but PRs are welcome for anyone who would like to help out!
I can't reproduce it. Can I get detailed configuration files?
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog
or Status: In Progress
, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
Same thing is happening with Next.js.
@moy2010, please open a GH issue and fill out a new bug report, we'll take a look!