Guest User

Untitled

a guest
May 26th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import React from 'react'
  2. import { connect } from 'react-redux'
  3. import Raven from 'raven-js';
  4.  
  5. Raven.config(process.env.SENTRY_URL).install()
  6.  
  7. type Props = {
  8. children: any,
  9. user: any
  10. }
  11.  
  12. class SentryErrorBoundary extends React.Component<Props> {
  13. componentDidCatch = (error, info) => {
  14. const { user } = this.props
  15.  
  16. if (process.env.SENTRY_ENABLED === 'true') {
  17. if (user) {
  18. console.log(user)
  19. Raven.setUserContext({
  20. id: user._id,
  21. email: user.email,
  22. })
  23. }
  24. Raven.captureException(error, { extra: info })
  25. }
  26. }
  27.  
  28. render() {
  29. return this.props.children
  30. }
  31. }
  32.  
  33. const mapStateToProps = state => ({
  34. user: state.auth.user
  35. })
  36.  
  37. export default connect(mapStateToProps)(SentryErrorBoundary)
Add Comment
Please, Sign In to add comment