From 5c582427366a30a21df64db393ecb9e4d1379439 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Mon, 17 May 2021 17:32:00 +0200 Subject: ui: Re-add support for Sentry This change re-adds the support for Sentry. This was lost during the migration from CRA to Next.js. --- opendc-web/opendc-web-ui/src/pages/_app.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'opendc-web/opendc-web-ui/src/pages') diff --git a/opendc-web/opendc-web-ui/src/pages/_app.js b/opendc-web/opendc-web-ui/src/pages/_app.js index f9727a7a..4ef4445c 100644 --- a/opendc-web/opendc-web-ui/src/pages/_app.js +++ b/opendc-web/opendc-web-ui/src/pages/_app.js @@ -25,6 +25,8 @@ import { Provider } from 'react-redux' import { useStore } from '../redux' import '../index.scss' import { AuthProvider, useAuth } from '../auth' +import * as Sentry from '@sentry/react' +import { Integrations } from '@sentry/tracing' // This setup is necessary to forward the Auth0 context to the Redux context const Inner = ({ Component, pageProps }) => { @@ -37,6 +39,19 @@ const Inner = ({ Component, pageProps }) => { ) } +const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN +// Initialize Sentry if the user has configured a DSN +if (process.browser && dsn) { + if (dsn) { + Sentry.init({ + environment: process.env.NODE_ENV, + dsn: dsn, + integrations: [new Integrations.BrowserTracing()], + tracesSampleRate: 0.1, + }) + } +} + export default function App(props) { return ( <> @@ -44,9 +59,11 @@ export default function App(props) { - - - + + + + + ) } -- cgit v1.2.3