Skip to content

Commit

Permalink
feat: make error reporting opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
arielsvg committed Jan 11, 2021
1 parent a39d8ed commit d44748f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/directives/views/accountMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 10 additions & 2 deletions app/assets/javascripts/services/errorReporting.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
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';

declare const __VERSION__: string;
declare global {
interface Window {
// eslint-disable-next-line camelcase
_bugsnag_api_key?: string;
}
}
Expand All @@ -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;
Expand Down

0 comments on commit d44748f

Please sign in to comment.