From 6fe27f769151abffb671c81d2a9b035349fb2719 Mon Sep 17 00:00:00 2001 From: Paul Kaplan <pkaplan@media.mit.edu> Date: Thu, 20 Dec 2018 13:19:44 -0500 Subject: [PATCH] Remove the error logging to GA, augment Sentry with the action prop --- src/containers/error-boundary.jsx | 37 +++++++++---------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/src/containers/error-boundary.jsx b/src/containers/error-boundary.jsx index 4a2114a0f..3c8b26fee 100644 --- a/src/containers/error-boundary.jsx +++ b/src/containers/error-boundary.jsx @@ -1,12 +1,10 @@ import React from 'react'; import PropTypes from 'prop-types'; import {connect} from 'react-redux'; -import bowser from 'bowser'; import BrowserModalComponent from '../components/browser-modal/browser-modal.jsx'; import CrashMessageComponent from '../components/crash-message/crash-message.jsx'; import log from '../lib/log.js'; import supportedBrowser from '../lib/supported-browser'; -import analytics from '../lib/analytics'; class ErrorBoundary extends React.Component { constructor (props) { @@ -24,36 +22,23 @@ class ErrorBoundary extends React.Component { message: 'Unknown error' }; + // Log errors to analytics, leaving out supported browsers from unsupported. + if (supportedBrowser() && window.Sentry) { + window.Sentry.withScope(scope => { + Object.keys(info).forEach(key => { + scope.setExtra(key, info[key]); + }); + scope.setExtra('action', this.props.action); + window.Sentry.captureException(error); + }); + } + // Display fallback UI this.setState({ hasError: true, errorId: window.Sentry ? window.Sentry.lastEventId() : null }); - // Log errors to analytics, separating supported browsers from unsupported. - if (supportedBrowser()) { - analytics.event({ - category: 'error', - action: this.props.action, - label: error.message - }); - if (window.Sentry) { - window.Sentry.withScope(scope => { - Object.keys(info).forEach(key => { - scope.setExtra(key, info[key]); - }); - scope.setExtra('action', this.props.action); - window.Sentry.captureException(error); - }); - } - } else { - analytics.event({ - category: 'Unsupported Browser Error', - action: `(Unsupported Browser) ${this.props.action}`, - label: `${bowser.name} ${error.message}` - }); - } - // Log error locally for debugging as well. log.error(`Unhandled Error: ${error.stack}\nComponent stack: ${info.componentStack}`); } -- GitLab