disable sentry

This commit is contained in:
Sean Yesmunt 2020-02-05 09:45:20 -05:00
parent e69703436a
commit 2eb822b33e
3 changed files with 54 additions and 26 deletions

View file

@ -1,7 +1,7 @@
// @flow // @flow
import { Lbryio } from 'lbryinc'; import { Lbryio } from 'lbryinc';
import ReactGA from 'react-ga'; import ReactGA from 'react-ga';
import * as Sentry from '@sentry/browser'; // import * as Sentry from '@sentry/browser';
import { history } from './store'; import { history } from './store';
// @if TARGET='app' // @if TARGET='app'
import Native from 'native'; import Native from 'native';
@ -22,7 +22,8 @@ ElectronCookies.enable({
// @endif // @endif
type Analytics = { type Analytics = {
error: ({}, {}) => Promise<any>, // error: ({}, {}) => Promise<any>,
error: string => void,
pageView: string => void, pageView: string => void,
setUser: Object => void, setUser: Object => void,
toggle: (boolean, ?boolean) => void, toggle: (boolean, ?boolean) => void,
@ -49,18 +50,23 @@ type LogPublishParams = {
let analyticsEnabled: boolean = isProduction; let analyticsEnabled: boolean = isProduction;
const analytics: Analytics = { const analytics: Analytics = {
error: (error, errorInfo) => { error: message => {
return new Promise(resolve => { if (analyticsEnabled && isProduction) {
if (analyticsEnabled && isProduction) { Lbryio.call('event', 'desktop_error', { error_message: message });
Sentry.withScope(scope => { }
scope.setExtras(errorInfo); // Temporarily disabling sentry
const eventId = Sentry.captureException(error); // error: (error, errorInfo) => {
resolve(eventId); // return new Promise(resolve => {
}); // if (analyticsEnabled && isProduction) {
} else { // Sentry.withScope(scope => {
resolve(null); // scope.setExtras(errorInfo);
} // const eventId = Sentry.captureException(error);
}); // resolve(eventId);
// });
// } else {
// resolve(null);
// }
// });
}, },
pageView: path => { pageView: path => {
if (analyticsEnabled) { if (analyticsEnabled) {

View file

@ -6,6 +6,8 @@ import Button from 'component/button';
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
import analytics from 'analytics'; import analytics from 'analytics';
import I18nMessage from 'component/i18nMessage'; import I18nMessage from 'component/i18nMessage';
import Native from 'native';
import { Lbry } from 'lbry-redux';
type Props = { type Props = {
children: Node, children: Node,
@ -32,9 +34,29 @@ class ErrorBoundary extends React.Component<Props, State> {
} }
componentDidCatch(error, errorInfo) { componentDidCatch(error, errorInfo) {
analytics.error(error, errorInfo).then(eventId => { // analytics.error(error, errorInfo).then(eventId => {
this.setState({ 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() { refresh() {
@ -46,7 +68,7 @@ class ErrorBoundary extends React.Component<Props, State> {
} }
render() { render() {
const { hasError, eventId } = this.state; const { hasError } = this.state;
if (hasError) { if (hasError) {
return ( return (
@ -72,7 +94,7 @@ class ErrorBoundary extends React.Component<Props, State> {
</I18nMessage> </I18nMessage>
} }
/> />
{eventId === null && ( {/* {eventId === null && (
<div className="error-wrapper"> <div className="error-wrapper">
<span className="error-text"> <span className="error-text">
{__('You are not currently sharing diagnostic data so this error was not reported.')} {__('You are not currently sharing diagnostic data so this error was not reported.')}
@ -83,7 +105,7 @@ class ErrorBoundary extends React.Component<Props, State> {
<div className="error-wrapper"> <div className="error-wrapper">
<span className="error-text">{__('Error ID: %eventId%', { eventId })}</span> <span className="error-text">{__('Error ID: %eventId%', { eventId })}</span>
</div> </div>
)} )} */}
</div> </div>
); );
} }

View file

@ -1,5 +1,5 @@
import 'babel-polyfill'; import 'babel-polyfill';
import * as Sentry from '@sentry/browser'; // import * as Sentry from '@sentry/browser';
import ErrorBoundary from 'component/errorBoundary'; import ErrorBoundary from 'component/errorBoundary';
import App from 'component/app'; import App from 'component/app';
import SnackBar from 'component/snackBar'; 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 // 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 // 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 it's caught by componentDidCatch in component/errorBoundary, it will not bubble up to this error reporter
if (process.env.NODE_ENV === 'production') { // if (process.env.NODE_ENV === 'production') {
Sentry.init({ // Sentry.init({
dsn: 'https://f93af3fa9c94470d9a0a22602cce3154@sentry.io/1877677', // dsn: 'https://f93af3fa9c94470d9a0a22602cce3154@sentry.io/1877677',
blacklistUrls: ['assets.revcontent.com'], // blacklistUrls: ['assets.revcontent.com'],
}); // });
} // }
const PROXY_PATH = 'api/v1/proxy'; const PROXY_PATH = 'api/v1/proxy';
export const SDK_API_URL = `${process.env.SDK_API_URL}/${PROXY_PATH}` || `https://api.lbry.tv/${PROXY_PATH}`; export const SDK_API_URL = `${process.env.SDK_API_URL}/${PROXY_PATH}` || `https://api.lbry.tv/${PROXY_PATH}`;