Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react'
- import { connect } from 'react-redux'
- import Raven from 'raven-js';
- Raven.config(process.env.SENTRY_URL).install()
- type Props = {
- children: any,
- user: any
- }
- class SentryErrorBoundary extends React.Component<Props> {
- componentDidCatch = (error, info) => {
- const { user } = this.props
- if (process.env.SENTRY_ENABLED === 'true') {
- if (user) {
- console.log(user)
- Raven.setUserContext({
- id: user._id,
- email: user.email,
- })
- }
- Raven.captureException(error, { extra: info })
- }
- }
- render() {
- return this.props.children
- }
- }
- const mapStateToProps = state => ({
- user: state.auth.user
- })
- export default connect(mapStateToProps)(SentryErrorBoundary)
Add Comment
Please, Sign In to add comment