From 5750e4f4eb360ecda39b1568d903e71ae09e141f Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 10 Nov 2020 22:32:21 +0100 Subject: Add support for frontend error reporting via Sentry This change sets up Sentry to collect errors that occur at the frontend. --- frontend/src/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'frontend/src/index.js') diff --git a/frontend/src/index.js b/frontend/src/index.js index 0971b1e6..fe119dfb 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -1,5 +1,7 @@ import React from 'react' import ReactDOM from 'react-dom' +import * as Sentry from '@sentry/react' +import { Integrations } from '@sentry/tracing' import { Provider } from 'react-redux' import { setupSocketConnection } from './api/socket' import './index.sass' @@ -9,6 +11,16 @@ import configureStore from './store/configure-store' setupSocketConnection(() => { const store = configureStore() + // Initialize Sentry if the user has configured a DSN + if (process.env.REACT_APP_SENTRY_DSN) { + Sentry.init({ + environment: process.env.NODE_ENV, + dsn: process.env.REACT_APP_SENTRY_DSN, + integrations: [new Integrations.BrowserTracing()], + tracesSampleRate: 0.5, + }) + } + ReactDOM.render( -- cgit v1.2.3