feat: sentry integration (#385)

* feat: sentry support

* ci: depscheck
This commit is contained in:
Adam Uhlíř
2022-06-16 20:32:53 +02:00
committed by GitHub
parent 2edf99c323
commit 109e07b097
13 changed files with 406 additions and 70 deletions
+31 -14
View File
@@ -1,9 +1,12 @@
import { CircularProgress, Container } from '@material-ui/core'
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'
import { ReactElement, useContext } from 'react'
import React, { ReactElement, useContext } from 'react'
import ErrorBoundary from '../components/ErrorBoundary'
import SideBar from '../components/SideBar'
import { Context } from '../providers/Bee'
import config from '../config'
import * as Sentry from '@sentry/react'
import ItsBroken from './ItsBroken'
const useStyles = makeStyles((theme: Theme) =>
createStyles({
@@ -22,23 +25,37 @@ const Dashboard = (props: Props): ReactElement => {
const classes = useStyles()
const { isLoading } = useContext(Context)
const content = (
<>
{isLoading ? (
<div style={{ textAlign: 'center', width: '100%' }}>
<CircularProgress />
</div>
) : (
props.children
)}
</>
)
let errorBoundaryWithContent
if (config.SENTRY_KEY) {
errorBoundaryWithContent = (
<Sentry.ErrorBoundary
showDialog
fallback={({ error, componentStack, resetError }) => <ItsBroken message={error.message} />}
>
{content}
</Sentry.ErrorBoundary>
)
} else {
errorBoundaryWithContent = <ErrorBoundary>{content}</ErrorBoundary>
}
return (
<div style={{ display: 'flex' }}>
<SideBar />
<Container className={classes.content}>
<ErrorBoundary>
<>
{isLoading ? (
<div style={{ textAlign: 'center', width: '100%' }}>
<CircularProgress />
</div>
) : (
props.children
)}
</>
</ErrorBoundary>
</Container>
<Container className={classes.content}>{errorBoundaryWithContent}</Container>
</div>
)
}
+36
View File
@@ -0,0 +1,36 @@
import { Container } from '@material-ui/core'
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'
import { ReactElement } from 'react'
const useStyles = makeStyles((theme: Theme) =>
createStyles({
content: {
backgroundColor: theme.palette.background.default,
minHeight: '100vh',
textAlign: 'center',
},
errorMsg: {
marginTop: '30px',
},
}),
)
interface Props {
message: string
}
// TODO: Provide some nicer design
const ItsBroken = ({ message }: Props): ReactElement => {
const classes = useStyles()
return (
<div>
<Container className={classes.content}>
<h1>Ups, there was a problem 😅</h1>
<h3 className={classes.errorMsg}>Error: {message}</h3>
</Container>
</div>
)
}
export default ItsBroken