Adding Sentry

This commit is contained in:
Jeff Avallone
2019-01-03 21:33:13 -05:00
parent c26bf26bd1
commit 6cff032efb
8 changed files with 146 additions and 5 deletions
+39
View File
@@ -0,0 +1,39 @@
import React from 'react';
import PropTypes from 'prop-types';
import * as Sentry from '@sentry/browser';
import SentryError from 'components/SentryError';
class SentryBoundary extends React.Component {
state = {
hasError: false
}
static getDerivedStateFromError() {
return { hasError: true };
}
componentDidCatch(error, errorInfo) {
Sentry.captureException(error, errorInfo);
}
render() {
const { hasError } = this.state;
const { children } = this.props;
if (hasError) {
return <SentryError />;
} else {
return children;
}
}
}
SentryBoundary.propTypes = {
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node
]).isRequired
};
export default SentryBoundary;