From 6cff032efb572160b2b6f7bc9c40079f4915e1f9 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Thu, 3 Jan 2019 21:33:13 -0500 Subject: [PATCH] Adding Sentry --- .eslintrc.json | 1 + gatsby-browser.js | 9 +++- gatsby-config.js | 9 ++++ package.json | 1 + src/components/Layout/index.js | 9 ++-- src/components/SentryBoundary/index.js | 39 ++++++++++++++++ src/components/SentryError/index.js | 22 ++++++++++ yarn.lock | 61 +++++++++++++++++++++++++- 8 files changed, 146 insertions(+), 5 deletions(-) create mode 100644 src/components/SentryBoundary/index.js create mode 100644 src/components/SentryError/index.js diff --git a/.eslintrc.json b/.eslintrc.json index 4ec6a87..6d950a3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,6 +8,7 @@ "eslint:recommended", "plugin:react/recommended" ], + "parser": "babel-eslint", "parserOptions": { "ecmaFeatures": { "jsx": true diff --git a/gatsby-browser.js b/gatsby-browser.js index b83ed98..09a1cf8 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -1 +1,8 @@ -require('./src/site.css'); +import * as Sentry from '@sentry/browser'; + +import 'site.css'; + +export const onClientEntry = () => { + Sentry.getCurrentHub().getClient().getOptions().enabled = + (navigator.doNotTrack !== '1' && window.doNotTrack !== '1'); +}; diff --git a/gatsby-config.js b/gatsby-config.js index 6b194ba..4ed2f98 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -19,6 +19,15 @@ module.exports = { anonymize: true, respectDNT: true } + }, + { + resolve: 'gatsby-plugin-sentry', + options: { + dsn: process.env.SENTRY_DSN, + environment: process.env.DEPLOY_ENV || process.env.NODE_ENV, + debug: (process.env.NODE_ENV !== 'production'), + release: buildId + } } ] }; diff --git a/package.json b/package.json index dffb3c4..7264d0f 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "gatsby-plugin-google-analytics": "^2.0.8", "gatsby-plugin-postcss": "^2.0.2", "gatsby-plugin-react-helmet": "^3.0.5", + "gatsby-plugin-sentry": "^1.0.0", "postcss-cssnext": "^3.1.0", "postcss-import": "^12.0.1", "prop-types": "^15.6.2", diff --git a/src/components/Layout/index.js b/src/components/Layout/index.js index d4361f1..a64c2eb 100644 --- a/src/components/Layout/index.js +++ b/src/components/Layout/index.js @@ -2,17 +2,20 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Helmet } from 'react-helmet'; +import SentryBoundary from 'components/SentryBoundary'; import Header from 'components/Header'; import Footer from 'components/Footer'; -const Layout = ({ title, children }) => +const Layout = ({ title, children }) => { title ? `Regexper - ${ title }` : 'Regexper' }
- { children } + + { children } +