gatsby-plugin-sentry
Gatsby plugin to add Sentry error tracking to your site.
Learn more about Sentry here.
Install
npm install --save gatsby-plugin-sentry
How to use
// In your gatsby-config.jsplugins: resolve: "gatsby-plugin-sentry" options: dsn: "YOUR_SENTRY_DSN_URL" // Optional settings, see https://docs.sentry.io/clients/node/config/#optional-settings environment: processenvNODE_ENV enabled: "production" "stage" !== -1 ;
Now Sentry
is available in global window object. so you can use it in react 16
like:
Component { superprops; thisstate = error: null ; } { this; Sentry; Sentry; } { if thisstateerror // render fallback UI return <h1>Something went wrong!</h1>; else // when there's not an error, render children untouched return thispropschildren; }