feat: add error reporting
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
declare const __VERSION__: string;
|
declare const __VERSION__: string;
|
||||||
declare const __WEB__: boolean;
|
declare const __WEB__: boolean;
|
||||||
|
|
||||||
|
import { SNLog } from 'snjs';
|
||||||
import angular from 'angular';
|
import angular from 'angular';
|
||||||
import { configRoutes } from './routes';
|
import { configRoutes } from './routes';
|
||||||
|
|
||||||
@@ -64,11 +65,14 @@ if (__WEB__) {
|
|||||||
(window as any).startApplication = startApplication;
|
(window as any).startApplication = startApplication;
|
||||||
}
|
}
|
||||||
|
|
||||||
function startApplication(
|
async function startApplication(
|
||||||
defaultSyncServerHost: string,
|
defaultSyncServerHost: string,
|
||||||
bridge: Bridge
|
bridge: Bridge
|
||||||
) {
|
) {
|
||||||
startErrorReporting();
|
|
||||||
|
SNLog.onLog = console.log;
|
||||||
|
await startErrorReporting();
|
||||||
|
|
||||||
angular.module('app', ['ngSanitize']);
|
angular.module('app', ['ngSanitize']);
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
@@ -142,4 +146,6 @@ function startApplication(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
angular.bootstrap(document, ['app']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import { PasswordWizardType } from '@/types';
|
|||||||
import { BackupFile } from 'snjs/dist/@types/services/protocol_service';
|
import { BackupFile } from 'snjs/dist/@types/services/protocol_service';
|
||||||
import { confirmDialog, alertDialog } from '@/services/alertService';
|
import { confirmDialog, alertDialog } from '@/services/alertService';
|
||||||
import { autorun, IReactionDisposer } from 'mobx';
|
import { autorun, IReactionDisposer } from 'mobx';
|
||||||
|
import { storage, StorageKey } from '@/services/localStorage';
|
||||||
|
|
||||||
const ELEMENT_ID_IMPORT_PASSWORD_INPUT = 'import-password-request';
|
const ELEMENT_ID_IMPORT_PASSWORD_INPUT = 'import-password-request';
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ type AccountMenuState = {
|
|||||||
encryptionEnabled: boolean;
|
encryptionEnabled: boolean;
|
||||||
selectedAutoLockInterval: any;
|
selectedAutoLockInterval: any;
|
||||||
showBetaWarning: boolean;
|
showBetaWarning: boolean;
|
||||||
|
errorReportingEnabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AccountMenuCtrl extends PureViewCtrl<{}, AccountMenuState> {
|
class AccountMenuCtrl extends PureViewCtrl<{}, AccountMenuState> {
|
||||||
@@ -96,6 +98,7 @@ class AccountMenuCtrl extends PureViewCtrl<{}, AccountMenuState> {
|
|||||||
},
|
},
|
||||||
mutable: {},
|
mutable: {},
|
||||||
showBetaWarning: false,
|
showBetaWarning: false,
|
||||||
|
errorReportingEnabled: !storage.get(StorageKey.DisableErrorReporting),
|
||||||
} as AccountMenuState;
|
} as AccountMenuState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,6 +590,31 @@ class AccountMenuCtrl extends PureViewCtrl<{}, AccountMenuState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openErrorReportingDialog() {
|
||||||
|
alertDialog({
|
||||||
|
title: 'Data sent during automatic error reporting',
|
||||||
|
text: `
|
||||||
|
We use <a target="_blank" href="https://www.bugsnag.com/">Bugsnag</a> to automatically
|
||||||
|
reports errors that occur while the app is running.
|
||||||
|
<a target="_blank" href="https://docs.bugsnag.com/platforms/javascript/#sending-diagnostic-data">
|
||||||
|
See this article, paragraph 'Browser' under 'Sending diagnostic data',
|
||||||
|
</a>
|
||||||
|
to know what data is automatically captured.
|
||||||
|
`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleErrorReportingEnabled() {
|
||||||
|
if (this.state.errorReportingEnabled) {
|
||||||
|
storage.set(StorageKey.DisableErrorReporting, true);
|
||||||
|
} else {
|
||||||
|
storage.set(StorageKey.DisableErrorReporting, false);
|
||||||
|
}
|
||||||
|
if (!this.application.getSyncStatus().syncInProgress) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
isDesktopApplication() {
|
isDesktopApplication() {
|
||||||
return isDesktopApplication();
|
return isDesktopApplication();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
|
import { SNLog } from 'snjs';
|
||||||
import { isDesktopApplication, isDev } from '@/utils';
|
import { isDesktopApplication, isDev } from '@/utils';
|
||||||
import { storage, StorageKey } from './localStorage';
|
import { storage, StorageKey } from './localStorage';
|
||||||
import Bugsnag from '@bugsnag/js';
|
|
||||||
|
|
||||||
declare const __VERSION__: string;
|
declare const __VERSION__: string;
|
||||||
|
|
||||||
export async function startErrorReporting() {
|
export async function startErrorReporting() {
|
||||||
if (storage.get(StorageKey.DisableErrorReporting)) {
|
if (storage.get(StorageKey.DisableErrorReporting)) {
|
||||||
|
SNLog.onError = console.error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
const { default: Bugsnag } = await import('@bugsnag/js');
|
||||||
Bugsnag.start({
|
Bugsnag.start({
|
||||||
apiKey: (window as any)._bugsnag_api_key,
|
apiKey: (window as any)._bugsnag_api_key,
|
||||||
appType: isDesktopApplication() ? 'desktop' : 'web',
|
appType: isDesktopApplication() ? 'desktop' : 'web',
|
||||||
@@ -17,6 +19,13 @@ export async function startErrorReporting() {
|
|||||||
autoTrackSessions: false,
|
autoTrackSessions: false,
|
||||||
releaseStage: isDev ? 'development' : undefined
|
releaseStage: isDev ? 'development' : undefined
|
||||||
});
|
});
|
||||||
|
if (isDev) {
|
||||||
|
SNLog.onError = console.error;
|
||||||
|
} else {
|
||||||
|
SNLog.onError = (error) => {
|
||||||
|
Bugsnag.notify(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to start Bugsnag.', error);
|
console.error('Failed to start Bugsnag.', error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -302,6 +302,18 @@
|
|||||||
| the whole file, please use the Batch Manager extension.
|
| the whole file, please use the Batch Manager extension.
|
||||||
.sk-panel-row
|
.sk-panel-row
|
||||||
.sk-spinner.small.info(ng-if='self.state.importData.loading')
|
.sk-spinner.small.info(ng-if='self.state.importData.loading')
|
||||||
|
.sk-panel-section
|
||||||
|
.sk-panel-section-title Error Reporting
|
||||||
|
.sk-panel-section-subtitle.info
|
||||||
|
| Automatic error reporting is {{ self.state.errorReportingEnabled ? 'enabled.' : 'disabled.' }}
|
||||||
|
p.sk-p
|
||||||
|
| Help us improve Standard Notes by automatically submitting
|
||||||
|
| anonymized error reports.
|
||||||
|
.sk-panel-row
|
||||||
|
button(ng-click="self.toggleErrorReportingEnabled()").sk-button.info
|
||||||
|
span.sk-label {{ self.state.errorReportingEnabled ? 'Disable' : 'Enable'}} Error Reporting
|
||||||
|
.sk-panel-row
|
||||||
|
a(ng-click="self.openErrorReportingDialog()").sk-a What data is being sent?
|
||||||
.sk-panel-footer
|
.sk-panel-footer
|
||||||
.sk-panel-row
|
.sk-panel-row
|
||||||
.sk-p.left.neutral
|
.sk-p.left.neutral
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html ng-app="app">
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
|
<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
This file is strictly used for local development using the webpack-dev-server.
|
This file is strictly used for local development using the webpack-dev-server.
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html ng-app="app">
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -11028,8 +11028,8 @@
|
|||||||
"from": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad"
|
"from": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad"
|
||||||
},
|
},
|
||||||
"snjs": {
|
"snjs": {
|
||||||
"version": "github:standardnotes/snjs#b7866c68243b418ae5e7be830d1593f0e07333e4",
|
"version": "github:standardnotes/snjs#5757198630342821fdb0e8133b1597a39e0502ad",
|
||||||
"from": "github:standardnotes/snjs#b7866c68243b418ae5e7be830d1593f0e07333e4"
|
"from": "github:standardnotes/snjs#5757198630342821fdb0e8133b1597a39e0502ad"
|
||||||
},
|
},
|
||||||
"sockjs": {
|
"sockjs": {
|
||||||
"version": "0.3.20",
|
"version": "0.3.20",
|
||||||
|
|||||||
@@ -72,6 +72,6 @@
|
|||||||
"@bugsnag/js": "^7.5.1",
|
"@bugsnag/js": "^7.5.1",
|
||||||
"mobx": "^6.0.1",
|
"mobx": "^6.0.1",
|
||||||
"sncrypto": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad",
|
"sncrypto": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad",
|
||||||
"snjs": "github:standardnotes/snjs#b7866c68243b418ae5e7be830d1593f0e07333e4"
|
"snjs": "github:standardnotes/snjs#5757198630342821fdb0e8133b1597a39e0502ad"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user