re-enable sentry for web
This commit is contained in:
parent
87681c4fae
commit
cee44b47ea
4 changed files with 58 additions and 44 deletions
|
@ -955,5 +955,6 @@
|
||||||
"After submitting, you will not see the changes immediately. Please check back in a few minutes.": "After submitting, you will not see the changes immediately. Please check back in a few minutes.",
|
"After submitting, you will not see the changes immediately. Please check back in a few minutes.": "After submitting, you will not see the changes immediately. Please check back in a few minutes.",
|
||||||
"Thumbnail Recommended ratio is 1:1": "Thumbnail Recommended ratio is 1:1",
|
"Thumbnail Recommended ratio is 1:1": "Thumbnail Recommended ratio is 1:1",
|
||||||
"Cover Recommended ratio is 6.25:1": "Cover Recommended ratio is 6.25:1",
|
"Cover Recommended ratio is 6.25:1": "Cover Recommended ratio is 6.25:1",
|
||||||
"You already have a claim with this name.": "You already have a claim with this name."
|
"You already have a claim with this name.": "You already have a claim with this name.",
|
||||||
|
"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."
|
||||||
}
|
}
|
|
@ -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,8 +22,8 @@ ElectronCookies.enable({
|
||||||
// @endif
|
// @endif
|
||||||
|
|
||||||
type Analytics = {
|
type Analytics = {
|
||||||
// error: ({}, {}) => Promise<any>,
|
error: string => Promise<any>,
|
||||||
error: string => void,
|
sentryError: ({}, {}) => Promise<any>,
|
||||||
pageView: string => void,
|
pageView: string => void,
|
||||||
setUser: Object => void,
|
setUser: Object => void,
|
||||||
toggle: (boolean, ?boolean) => void,
|
toggle: (boolean, ?boolean) => void,
|
||||||
|
@ -51,22 +51,28 @@ let analyticsEnabled: boolean = isProduction;
|
||||||
|
|
||||||
const analytics: Analytics = {
|
const analytics: Analytics = {
|
||||||
error: message => {
|
error: message => {
|
||||||
if (analyticsEnabled && isProduction) {
|
return new Promise(resolve => {
|
||||||
Lbryio.call('event', 'desktop_error', { error_message: message });
|
if (analyticsEnabled && isProduction) {
|
||||||
}
|
return Lbryio.call('event', 'desktop_error', { error_message: message }).then(() => {
|
||||||
// Temporarily disabling sentry
|
resolve(true);
|
||||||
// error: (error, errorInfo) => {
|
});
|
||||||
// return new Promise(resolve => {
|
} else {
|
||||||
// if (analyticsEnabled && isProduction) {
|
resolve(false);
|
||||||
// Sentry.withScope(scope => {
|
}
|
||||||
// scope.setExtras(errorInfo);
|
});
|
||||||
// const eventId = Sentry.captureException(error);
|
},
|
||||||
// resolve(eventId);
|
sentryError: (error, errorInfo) => {
|
||||||
// });
|
return new Promise(resolve => {
|
||||||
// } else {
|
if (analyticsEnabled && isProduction) {
|
||||||
// resolve(null);
|
Sentry.withScope(scope => {
|
||||||
// }
|
scope.setExtras(errorInfo);
|
||||||
// });
|
const eventId = Sentry.captureException(error);
|
||||||
|
resolve(eventId);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
resolve(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
pageView: path => {
|
pageView: path => {
|
||||||
if (analyticsEnabled) {
|
if (analyticsEnabled) {
|
||||||
|
|
|
@ -18,13 +18,14 @@ type Props = {
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
hasError: boolean,
|
hasError: boolean,
|
||||||
eventId: ?string,
|
sentryEventId: ?string,
|
||||||
|
desktopErrorReported: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ErrorBoundary extends React.Component<Props, State> {
|
class ErrorBoundary extends React.Component<Props, State> {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.state = { hasError: false, eventId: undefined };
|
this.state = { hasError: false, sentryEventId: undefined, desktopErrorReported: false };
|
||||||
|
|
||||||
(this: any).refresh = this.refresh.bind(this);
|
(this: any).refresh = this.refresh.bind(this);
|
||||||
}
|
}
|
||||||
|
@ -34,26 +35,23 @@ class ErrorBoundary extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidCatch(error, errorInfo) {
|
componentDidCatch(error, errorInfo) {
|
||||||
// analytics.error(error, errorInfo).then(eventId => {
|
|
||||||
// this.setState({ eventId });
|
|
||||||
// });
|
|
||||||
let errorMessage = 'Uncaught error\n';
|
|
||||||
|
|
||||||
// @if TARGET='web'
|
// @if TARGET='web'
|
||||||
errorMessage += 'lbry.tv\n';
|
analytics.sentryError(error, errorInfo).then(sentryEventId => {
|
||||||
errorMessage += `page: ${window.location.pathname + window.location.search}\n`;
|
this.setState({ sentryEventId });
|
||||||
errorMessage += error.stack;
|
});
|
||||||
analytics.error(errorMessage);
|
|
||||||
|
|
||||||
// @endif
|
// @endif
|
||||||
|
|
||||||
// @if TARGET='app'
|
// @if TARGET='app'
|
||||||
|
let errorMessage = 'Uncaught error\n';
|
||||||
Native.getAppVersionInfo().then(({ localVersion }) => {
|
Native.getAppVersionInfo().then(({ localVersion }) => {
|
||||||
Lbry.version().then(({ lbrynet_version: sdkVersion }) => {
|
Lbry.version().then(({ lbrynet_version: sdkVersion }) => {
|
||||||
errorMessage += `app version: ${localVersion}\n`;
|
errorMessage += `app version: ${localVersion}\n`;
|
||||||
errorMessage += `sdk version: ${sdkVersion}\n`;
|
errorMessage += `sdk version: ${sdkVersion}\n`;
|
||||||
errorMessage += `page: ${window.location.href.split('.html')[1]}\n`;
|
errorMessage += `page: ${window.location.href.split('.html')[1]}\n`;
|
||||||
errorMessage += `${error.stack}`;
|
errorMessage += `${error.stack}`;
|
||||||
analytics.error(errorMessage);
|
analytics.error(errorMessage).then(isSharingData => {
|
||||||
|
this.setState({ desktopErrorReported: isSharingData });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// @endif
|
// @endif
|
||||||
|
@ -69,6 +67,9 @@ class ErrorBoundary extends React.Component<Props, State> {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { hasError } = this.state;
|
const { hasError } = this.state;
|
||||||
|
const { sentryEventId, desktopErrorReported } = this.state;
|
||||||
|
|
||||||
|
const errorWasReported = IS_WEB ? sentryEventId !== null : desktopErrorReported;
|
||||||
|
|
||||||
if (hasError) {
|
if (hasError) {
|
||||||
return (
|
return (
|
||||||
|
@ -94,18 +95,24 @@ class ErrorBoundary extends React.Component<Props, State> {
|
||||||
</I18nMessage>
|
</I18nMessage>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{/* {eventId === null && (
|
{!errorWasReported && (
|
||||||
<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.')}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{eventId && (
|
|
||||||
|
{errorWasReported && (
|
||||||
<div className="error-wrapper">
|
<div className="error-wrapper">
|
||||||
<span className="error-text">{__('Error ID: %eventId%', { eventId })}</span>
|
{/* @if TARGET='web' */}
|
||||||
|
<span className="error-text">{__('Error ID: %sentryEventId%', { sentryEventId })}</span>
|
||||||
|
{/* @endif */}
|
||||||
|
{/* @if TARGET='app' */}
|
||||||
|
<span className="error-text">{__('This error was reported and will be fixed.')}</span>
|
||||||
|
{/* @endif */}
|
||||||
</div>
|
</div>
|
||||||
)} */}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
14
ui/index.jsx
14
ui/index.jsx
|
@ -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://1f3c88e2e4b341328a638e138a60fb73@sentry.lbry.tech/2',
|
||||||
// blacklistUrls: ['assets.revcontent.com'],
|
whitelistUrls: [/\/public\/ui.js/],
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
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}`;
|
||||||
|
|
Loading…
Reference in a new issue