Merge branch 'release/3.5.2'
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
declare const __VERSION__: string;
|
||||
declare const __WEB__: boolean;
|
||||
|
||||
import { SNLog } from 'snjs';
|
||||
import angular from 'angular';
|
||||
import { configRoutes } from './routes';
|
||||
|
||||
@@ -53,6 +54,7 @@ import {
|
||||
import { trusted } from './filters';
|
||||
import { isDev } from './utils';
|
||||
import { Bridge, BrowserBridge } from './services/bridge';
|
||||
import { startErrorReporting } from './services/errorReporting';
|
||||
|
||||
if (__WEB__) {
|
||||
startApplication(
|
||||
@@ -63,10 +65,14 @@ if (__WEB__) {
|
||||
(window as any).startApplication = startApplication;
|
||||
}
|
||||
|
||||
function startApplication(
|
||||
async function startApplication(
|
||||
defaultSyncServerHost: string,
|
||||
bridge: Bridge
|
||||
) {
|
||||
|
||||
SNLog.onLog = console.log;
|
||||
startErrorReporting();
|
||||
|
||||
angular.module('app', ['ngSanitize']);
|
||||
|
||||
// Config
|
||||
@@ -140,4 +146,8 @@ function startApplication(
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
angular.element(document).ready(() => {
|
||||
angular.bootstrap(document, ['app']);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import { PasswordWizardType } from '@/types';
|
||||
import { BackupFile } from 'snjs/dist/@types/services/protocol_service';
|
||||
import { confirmDialog, alertDialog } from '@/services/alertService';
|
||||
import { autorun, IReactionDisposer } from 'mobx';
|
||||
import { storage, StorageKey } from '@/services/localStorage';
|
||||
|
||||
const ELEMENT_ID_IMPORT_PASSWORD_INPUT = 'import-password-request';
|
||||
|
||||
@@ -65,6 +66,7 @@ type AccountMenuState = {
|
||||
encryptionEnabled: boolean;
|
||||
selectedAutoLockInterval: any;
|
||||
showBetaWarning: boolean;
|
||||
errorReportingEnabled: boolean;
|
||||
}
|
||||
|
||||
class AccountMenuCtrl extends PureViewCtrl<{}, AccountMenuState> {
|
||||
@@ -96,6 +98,7 @@ class AccountMenuCtrl extends PureViewCtrl<{}, AccountMenuState> {
|
||||
},
|
||||
mutable: {},
|
||||
showBetaWarning: false,
|
||||
errorReportingEnabled: !storage.get(StorageKey.DisableErrorReporting),
|
||||
} as AccountMenuState;
|
||||
}
|
||||
|
||||
@@ -587,6 +590,36 @@ 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 report errors that occur while the app is running. See
|
||||
<a target="_blank" href="https://docs.bugsnag.com/platforms/javascript/#sending-diagnostic-data">
|
||||
this article, paragraph 'Browser' under 'Sending diagnostic data',
|
||||
</a>
|
||||
to see what data is included in error reports.
|
||||
<br><br>
|
||||
Error reports never include IP addresses and are fully
|
||||
anonymized. We use error reports to be alerted when something in our
|
||||
code is causing unexpected errors and crashes in your application
|
||||
experience.
|
||||
`
|
||||
});
|
||||
}
|
||||
|
||||
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() {
|
||||
return isDesktopApplication();
|
||||
}
|
||||
|
||||
33
app/assets/javascripts/services/errorReporting.ts
Normal file
33
app/assets/javascripts/services/errorReporting.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { SNLog } from 'snjs';
|
||||
import { isDesktopApplication, isDev } from '@/utils';
|
||||
import { storage, StorageKey } from './localStorage';
|
||||
import Bugsnag from '@bugsnag/js';
|
||||
|
||||
declare const __VERSION__: string;
|
||||
|
||||
export function startErrorReporting() {
|
||||
if (storage.get(StorageKey.DisableErrorReporting)) {
|
||||
SNLog.onError = console.error;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Bugsnag.start({
|
||||
apiKey: (window as any)._bugsnag_api_key,
|
||||
appType: isDesktopApplication() ? 'desktop' : 'web',
|
||||
appVersion: __VERSION__,
|
||||
collectUserIp: false,
|
||||
autoTrackSessions: false,
|
||||
releaseStage: isDev ? 'development' : undefined
|
||||
});
|
||||
if (isDev) {
|
||||
SNLog.onError = console.error;
|
||||
} else {
|
||||
SNLog.onError = (error) => {
|
||||
Bugsnag.notify(error);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to start Bugsnag.', error);
|
||||
SNLog.onError = console.error;
|
||||
}
|
||||
}
|
||||
16
app/assets/javascripts/services/localStorage.ts
Normal file
16
app/assets/javascripts/services/localStorage.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export enum StorageKey {
|
||||
DisableErrorReporting = 'DisableErrorReporting',
|
||||
}
|
||||
|
||||
export const storage = {
|
||||
get(key: StorageKey) {
|
||||
const value = localStorage.getItem(key);
|
||||
return value ? JSON.parse(value) : null;
|
||||
},
|
||||
set(key: StorageKey, value: unknown) {
|
||||
localStorage.setItem(key, JSON.stringify(value));
|
||||
},
|
||||
remove(key: StorageKey) {
|
||||
localStorage.removeItem(key);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user