feat: make error reporting opt-in

This commit is contained in:
Baptiste Grob
2021-01-11 13:17:41 +01:00
parent a39d8ed72e
commit d44748fcad
2 changed files with 11 additions and 3 deletions

View File

@@ -100,7 +100,7 @@ class AccountMenuCtrl extends PureViewCtrl<{}, AccountMenuState> {
},
mutable: {},
showBetaWarning: false,
errorReportingEnabled: !storage.get(StorageKey.DisableErrorReporting),
errorReportingEnabled: storage.get(StorageKey.DisableErrorReporting) === false,
showSessions: false,
} as AccountMenuState;
}

View File

@@ -1,4 +1,4 @@
import { SNLog } from '@standardnotes/snjs';
import { isNullOrUndefined, SNLog } from '@standardnotes/snjs';
import { isDesktopApplication, isDev } from '@/utils';
import { storage, StorageKey } from './localStorage';
import Bugsnag from '@bugsnag/js';
@@ -6,6 +6,7 @@ import Bugsnag from '@bugsnag/js';
declare const __VERSION__: string;
declare global {
interface Window {
// eslint-disable-next-line camelcase
_bugsnag_api_key?: string;
}
}
@@ -21,8 +22,15 @@ function redactFilePath(line: string): string {
}
export function startErrorReporting() {
const disableErrorReporting = storage.get(StorageKey.DisableErrorReporting);
if (
storage.get(StorageKey.DisableErrorReporting) ||
/**
* Error reporting used to be opt-out, but is now opt-in, so
* treat the absence of an error reporting preference as an indication
* to disable error reporting.
*/
isNullOrUndefined(disableErrorReporting) ||
disableErrorReporting ||
!window._bugsnag_api_key
) {
SNLog.onError = console.error;