add page and app version to error logs
This commit is contained in:
parent
60c1580ac5
commit
f7129c58bb
1 changed files with 21 additions and 7 deletions
|
@ -4,6 +4,7 @@ import * as React from 'react';
|
||||||
import Yrbl from 'component/yrbl';
|
import Yrbl from 'component/yrbl';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import { withRouter } from 'react-router';
|
import { withRouter } from 'react-router';
|
||||||
|
import Native from 'native';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
children: React.Node,
|
children: React.Node,
|
||||||
|
@ -29,15 +30,28 @@ class ErrorBoundary extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidCatch(error: { stack: string }) {
|
componentDidCatch(error: { stack: string }) {
|
||||||
|
let errorMessage = '\n';
|
||||||
|
|
||||||
|
// @if TARGET='web'
|
||||||
|
errorMessage += 'lbry.tv error\n';
|
||||||
|
errorMessage += window.location.pathname + window.location.search;
|
||||||
|
this.log(errorMessage);
|
||||||
|
// @endif
|
||||||
|
// @if TARGET='app'
|
||||||
|
Native.getAppVersionInfo().then(({ localVersion }) => {
|
||||||
|
errorMessage += `version: ${localVersion}\n`;
|
||||||
|
errorMessage += `page: ${window.location.href.split('.html')[1]}\n`;
|
||||||
|
errorMessage += `${error.stack}`;
|
||||||
|
|
||||||
|
this.log(errorMessage);
|
||||||
|
});
|
||||||
|
// @endif
|
||||||
|
}
|
||||||
|
|
||||||
|
log(message) {
|
||||||
declare var app: { env: string };
|
declare var app: { env: string };
|
||||||
|
|
||||||
const errorMessage = `
|
|
||||||
${window.location.pathname + window.location.search}\n
|
|
||||||
${error.stack}
|
|
||||||
`;
|
|
||||||
|
|
||||||
if (app.env === 'production') {
|
if (app.env === 'production') {
|
||||||
Lbryio.call('event', 'desktop_error', { error_message: errorMessage });
|
Lbryio.call('event', 'desktop_error', { error_message: message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue