Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to integrate gatsby.js with Sentry.io? #3028

Closed
calpa opened this issue Nov 26, 2017 · 5 comments
Closed

How to integrate gatsby.js with Sentry.io? #3028

calpa opened this issue Nov 26, 2017 · 5 comments
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@calpa
Copy link
Contributor

calpa commented Nov 26, 2017

I have tried to install sentry.io with raven.js in two ways, but none of them seems to catch the errors correctly...

  1. Add the raven.js script tag into page
<script src="https://cdn.ravenjs.com/3.20.1/raven.min.js" crossorigin="anonymous"></script>
  1. Use raven-js via npm

I wonder what kinds of error catching methods or utilities I can use in gatsby.js.

I can report the error manually using Raven.captureException(e), which is stated at https://docs.sentry.io/clients/javascript/usage/#raven-js-reporting-errors

The official documentation is available at https://docs.sentry.io/clients/javascript/integrations/react/

@abumalick
Copy link
Contributor

you can could instegrate an error boundary in src/HTML.js and log the error to sentry there.

@abumalick
Copy link
Contributor

@calcsam
Copy link
Contributor

calcsam commented Nov 27, 2017

Take a look into how Gatsby plugins for Google Analytics and Intercom.io work. You'll probably want to modify the onRenderBody hook of gatsby-ssr.js and cut-and-paste the JS in your raven.min.js file there so it is called before the page loads.

Eg, https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-google-analytics/src/gatsby-ssr.js

@octalmage
Copy link
Contributor

I actually made a plugin for this, you can find it here:

https://www.npmjs.com/package/gatsby-plugin-sentry

@KyleAMathews
Copy link
Contributor

@octalmage awesome thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

6 participants