From 2eb822b33ea37fd10c9f7dc7f87097b5397286a9 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Wed, 5 Feb 2020 09:45:20 -0500 Subject: [PATCH] disable sentry --- ui/analytics.js | 34 +++++++++++++++++------------ ui/component/errorBoundary/view.jsx | 32 ++++++++++++++++++++++----- ui/index.jsx | 14 ++++++------ 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/ui/analytics.js b/ui/analytics.js index 4e645deb2..7e02b3660 100644 --- a/ui/analytics.js +++ b/ui/analytics.js @@ -1,7 +1,7 @@ // @flow import { Lbryio } from 'lbryinc'; import ReactGA from 'react-ga'; -import * as Sentry from '@sentry/browser'; +// import * as Sentry from '@sentry/browser'; import { history } from './store'; // @if TARGET='app' import Native from 'native'; @@ -22,7 +22,8 @@ ElectronCookies.enable({ // @endif type Analytics = { - error: ({}, {}) => Promise, + // error: ({}, {}) => Promise, + error: string => void, pageView: string => void, setUser: Object => void, toggle: (boolean, ?boolean) => void, @@ -49,18 +50,23 @@ type LogPublishParams = { let analyticsEnabled: boolean = isProduction; const analytics: Analytics = { - error: (error, errorInfo) => { - return new Promise(resolve => { - if (analyticsEnabled && isProduction) { - Sentry.withScope(scope => { - scope.setExtras(errorInfo); - const eventId = Sentry.captureException(error); - resolve(eventId); - }); - } else { - resolve(null); - } - }); + error: message => { + if (analyticsEnabled && isProduction) { + Lbryio.call('event', 'desktop_error', { error_message: message }); + } + // Temporarily disabling sentry + // error: (error, errorInfo) => { + // return new Promise(resolve => { + // if (analyticsEnabled && isProduction) { + // Sentry.withScope(scope => { + // scope.setExtras(errorInfo); + // const eventId = Sentry.captureException(error); + // resolve(eventId); + // }); + // } else { + // resolve(null); + // } + // }); }, pageView: path => { if (analyticsEnabled) { diff --git a/ui/component/errorBoundary/view.jsx b/ui/component/errorBoundary/view.jsx index bb0876351..ea2732f53 100644 --- a/ui/component/errorBoundary/view.jsx +++ b/ui/component/errorBoundary/view.jsx @@ -6,6 +6,8 @@ import Button from 'component/button'; import { withRouter } from 'react-router'; import analytics from 'analytics'; import I18nMessage from 'component/i18nMessage'; +import Native from 'native'; +import { Lbry } from 'lbry-redux'; type Props = { children: Node, @@ -32,9 +34,29 @@ class ErrorBoundary extends React.Component { } componentDidCatch(error, errorInfo) { - analytics.error(error, errorInfo).then(eventId => { - this.setState({ eventId }); + // analytics.error(error, errorInfo).then(eventId => { + // this.setState({ eventId }); + // }); + let errorMessage = 'Uncaught error\n'; + + // @if TARGET='web' + errorMessage += 'lbry.tv\n'; + errorMessage += `page: ${window.location.pathname + window.location.search}\n`; + errorMessage += error.stack; + analytics.error(errorMessage); + + // @endif + // @if TARGET='app' + Native.getAppVersionInfo().then(({ localVersion }) => { + Lbry.version().then(({ lbrynet_version: sdkVersion }) => { + errorMessage += `app version: ${localVersion}\n`; + errorMessage += `sdk version: ${sdkVersion}\n`; + errorMessage += `page: ${window.location.href.split('.html')[1]}\n`; + errorMessage += `${error.stack}`; + analytics.error(errorMessage); + }); }); + // @endif } refresh() { @@ -46,7 +68,7 @@ class ErrorBoundary extends React.Component { } render() { - const { hasError, eventId } = this.state; + const { hasError } = this.state; if (hasError) { return ( @@ -72,7 +94,7 @@ class ErrorBoundary extends React.Component { } /> - {eventId === null && ( + {/* {eventId === null && (
{__('You are not currently sharing diagnostic data so this error was not reported.')} @@ -83,7 +105,7 @@ class ErrorBoundary extends React.Component {
{__('Error ID: %eventId%', { eventId })}
- )} + )} */}
); } diff --git a/ui/index.jsx b/ui/index.jsx index ca46d206a..6579a2193 100644 --- a/ui/index.jsx +++ b/ui/index.jsx @@ -1,5 +1,5 @@ import 'babel-polyfill'; -import * as Sentry from '@sentry/browser'; +// import * as Sentry from '@sentry/browser'; import ErrorBoundary from 'component/errorBoundary'; import App from 'component/app'; import SnackBar from 'component/snackBar'; @@ -47,12 +47,12 @@ import apiPublishCallViaWeb from 'lbrytv/setup/publish'; // Will only work if you have a SENTRY_AUTH_TOKEN env // We still add code in analytics.js to send the error to sentry manually // If it's caught by componentDidCatch in component/errorBoundary, it will not bubble up to this error reporter -if (process.env.NODE_ENV === 'production') { - Sentry.init({ - dsn: 'https://f93af3fa9c94470d9a0a22602cce3154@sentry.io/1877677', - blacklistUrls: ['assets.revcontent.com'], - }); -} +// if (process.env.NODE_ENV === 'production') { +// Sentry.init({ +// dsn: 'https://f93af3fa9c94470d9a0a22602cce3154@sentry.io/1877677', +// blacklistUrls: ['assets.revcontent.com'], +// }); +// } const PROXY_PATH = 'api/v1/proxy'; export const SDK_API_URL = `${process.env.SDK_API_URL}/${PROXY_PATH}` || `https://api.lbry.tv/${PROXY_PATH}`;