fix app crash and log weird error to help track down issue with license changing
This commit is contained in:
parent
8331e0ecf9
commit
5fc6dd9b3d
5 changed files with 33 additions and 17 deletions
|
@ -21,6 +21,7 @@ ElectronCookies.enable({
|
||||||
// @endif
|
// @endif
|
||||||
|
|
||||||
type Analytics = {
|
type Analytics = {
|
||||||
|
error: string => void,
|
||||||
pageView: string => void,
|
pageView: string => void,
|
||||||
setUser: Object => void,
|
setUser: Object => void,
|
||||||
toggle: (boolean, ?boolean) => void,
|
toggle: (boolean, ?boolean) => void,
|
||||||
|
@ -44,6 +45,11 @@ type LogPublishParams = {
|
||||||
|
|
||||||
let analyticsEnabled: boolean = true;
|
let analyticsEnabled: boolean = true;
|
||||||
const analytics: Analytics = {
|
const analytics: Analytics = {
|
||||||
|
error: message => {
|
||||||
|
if (analyticsEnabled) {
|
||||||
|
Lbryio.call('event', 'desktop_error', { error_message: message });
|
||||||
|
}
|
||||||
|
},
|
||||||
pageView: path => {
|
pageView: path => {
|
||||||
if (analyticsEnabled) {
|
if (analyticsEnabled) {
|
||||||
ReactGA.pageview(path, [SECOND_TRACKER_NAME]);
|
ReactGA.pageview(path, [SECOND_TRACKER_NAME]);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
// @flow
|
// @flow
|
||||||
import type { Node } from 'react';
|
import type { Node } from 'react';
|
||||||
import { Lbryio } from 'lbryinc';
|
|
||||||
import React, { Fragment } from 'react';
|
import React, { Fragment } 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';
|
import Native from 'native';
|
||||||
import { Lbry } from 'lbry-redux';
|
import { Lbry } from 'lbry-redux';
|
||||||
|
import analytics from 'analytics';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
children: Node,
|
children: Node,
|
||||||
|
@ -38,7 +38,8 @@ class ErrorBoundary extends React.Component<Props, State> {
|
||||||
errorMessage += 'lbry.tv\n';
|
errorMessage += 'lbry.tv\n';
|
||||||
errorMessage += `page: ${window.location.pathname + window.location.search}\n`;
|
errorMessage += `page: ${window.location.pathname + window.location.search}\n`;
|
||||||
errorMessage += error.stack;
|
errorMessage += error.stack;
|
||||||
this.log(errorMessage);
|
analytics.error(errorMessage);
|
||||||
|
|
||||||
// @endif
|
// @endif
|
||||||
// @if TARGET='app'
|
// @if TARGET='app'
|
||||||
Native.getAppVersionInfo().then(({ localVersion }) => {
|
Native.getAppVersionInfo().then(({ localVersion }) => {
|
||||||
|
@ -47,19 +48,12 @@ class ErrorBoundary extends React.Component<Props, State> {
|
||||||
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}`;
|
||||||
this.log(errorMessage);
|
analytics.error(errorMessage);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// @endif
|
// @endif
|
||||||
}
|
}
|
||||||
|
|
||||||
log(message) {
|
|
||||||
declare var app: { env: string };
|
|
||||||
if (app.env === 'production') {
|
|
||||||
Lbryio.call('event', 'desktop_error', { error_message: message });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
const { history } = this.props;
|
const { history } = this.props;
|
||||||
// use history.replace instead of history.push so the user can't click back to the errored page
|
// use history.replace instead of history.push so the user can't click back to the errored page
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectPublishFormValues, doUpdatePublishForm } from 'lbry-redux';
|
import { selectPublishFormValues, doUpdatePublishForm, doToast } from 'lbry-redux';
|
||||||
import PublishPage from './view';
|
import PublishPage from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
|
@ -8,6 +8,7 @@ const select = state => ({
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
|
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
|
||||||
|
showToast: message => dispatch(doToast({ isError: true, message })),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { FormField } from 'component/common/form';
|
import { FormField } from 'component/common/form';
|
||||||
import { CC_LICENSES, LEGACY_CC_LICENSES, COPYRIGHT, OTHER, PUBLIC_DOMAIN, NONE } from 'constants/licenses';
|
import { CC_LICENSES, LEGACY_CC_LICENSES, COPYRIGHT, OTHER, PUBLIC_DOMAIN, NONE } from 'constants/licenses';
|
||||||
|
import analytics from 'analytics';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
licenseType: ?string,
|
licenseType: ?string,
|
||||||
|
@ -10,6 +11,7 @@ type Props = {
|
||||||
handleLicenseChange: (string, string) => void,
|
handleLicenseChange: (string, string) => void,
|
||||||
handleLicenseDescriptionChange: (SyntheticInputEvent<*>) => void,
|
handleLicenseDescriptionChange: (SyntheticInputEvent<*>) => void,
|
||||||
handleLicenseUrlChange: (SyntheticInputEvent<*>) => void,
|
handleLicenseUrlChange: (SyntheticInputEvent<*>) => void,
|
||||||
|
showToast: string => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
class LicenseType extends React.PureComponent<Props> {
|
class LicenseType extends React.PureComponent<Props> {
|
||||||
|
@ -20,15 +22,26 @@ class LicenseType extends React.PureComponent<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLicenseOnChange(event: SyntheticInputEvent<*>) {
|
handleLicenseOnChange(event: SyntheticInputEvent<*>) {
|
||||||
const { handleLicenseChange } = this.props;
|
const { handleLicenseChange, showToast } = this.props;
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
const { options, selectedIndex } = event.target;
|
const { options, selectedIndex } = event.target;
|
||||||
|
|
||||||
|
if (options !== null) {
|
||||||
const selectedOption = options[selectedIndex];
|
const selectedOption = options[selectedIndex];
|
||||||
const licenseType = selectedOption.value;
|
const licenseType = selectedOption.value;
|
||||||
const licenseUrl = selectedOption.getAttribute('data-url');
|
const licenseUrl = selectedOption.getAttribute('data-url');
|
||||||
|
|
||||||
handleLicenseChange(licenseType, licenseUrl);
|
handleLicenseChange(licenseType, licenseUrl);
|
||||||
|
} else {
|
||||||
|
// There were users where this options were null for some reason
|
||||||
|
// This will at least make it so the app doesn't crash
|
||||||
|
// Hopefully this helps figure it out
|
||||||
|
analytics.error('Error changing the publish license\n' + JSON.stringify(this.props));
|
||||||
|
|
||||||
|
showToast(
|
||||||
|
__('There was an error updating the license type. If it continues to happen send an email to help@lbry.com.')
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -15,10 +15,11 @@ type Props = {
|
||||||
licenseUrl: ?string,
|
licenseUrl: ?string,
|
||||||
disabled: boolean,
|
disabled: boolean,
|
||||||
updatePublishForm: ({}) => void,
|
updatePublishForm: ({}) => void,
|
||||||
|
showToast: string => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
function PublishAdvanced(props: Props) {
|
function PublishAdvanced(props: Props) {
|
||||||
const { language, name, licenseType, otherLicenseDescription, licenseUrl, updatePublishForm } = props;
|
const { language, name, licenseType, otherLicenseDescription, licenseUrl, updatePublishForm, showToast } = props;
|
||||||
const [hideSection, setHideSection] = usePersistedState('publish-advanced-options', true);
|
const [hideSection, setHideSection] = usePersistedState('publish-advanced-options', true);
|
||||||
|
|
||||||
function toggleHideSection() {
|
function toggleHideSection() {
|
||||||
|
@ -66,6 +67,7 @@ function PublishAdvanced(props: Props) {
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
<LicenseType
|
<LicenseType
|
||||||
|
showToast={showToast}
|
||||||
licenseType={licenseType}
|
licenseType={licenseType}
|
||||||
otherLicenseDescription={otherLicenseDescription}
|
otherLicenseDescription={otherLicenseDescription}
|
||||||
licenseUrl={licenseUrl}
|
licenseUrl={licenseUrl}
|
||||||
|
|
Loading…
Reference in a new issue