diff --git a/.env.sample b/.env.sample index 42ed60a38bd..cd705c8e038 100644 --- a/.env.sample +++ b/.env.sample @@ -8,7 +8,6 @@ RAILS_LOG_LEVEL=INFO RAILS_SERVE_STATIC_FILES=true SECRET_KEY_BASE=test -BUGSNAG_API_KEY= APP_HOST=http://localhost:3001 PURCHASE_URL=https://standardnotes.com/purchase diff --git a/app/assets/javascripts/app.tsx b/app/assets/javascripts/app.tsx index b8848a528c6..6a9b8813714 100644 --- a/app/assets/javascripts/app.tsx +++ b/app/assets/javascripts/app.tsx @@ -2,7 +2,6 @@ declare global { interface Window { - bugsnagApiKey?: string; dashboardUrl?: string; defaultSyncServer: string; devAccountEmail?: string; @@ -22,7 +21,6 @@ import { render } from 'preact'; import { ApplicationGroupView } from './components/ApplicationGroupView'; import { Bridge } from './services/bridge'; import { BrowserBridge } from './services/browserBridge'; -import { startErrorReporting } from './services/errorReporting'; import { StartApplication } from './startApplication'; import { ApplicationGroup } from './ui_models/application_group'; import { isDev } from './utils'; @@ -34,7 +32,7 @@ const startApplication: StartApplication = async function startApplication( webSocketUrl: string ) { SNLog.onLog = console.log; - startErrorReporting(); + SNLog.onError = console.error; const mainApplicationGroup = new ApplicationGroup( defaultSyncServerHost, diff --git a/app/assets/javascripts/preferences/panes/General.tsx b/app/assets/javascripts/preferences/panes/General.tsx index a616c2d07b6..e295764b9be 100644 --- a/app/assets/javascripts/preferences/panes/General.tsx +++ b/app/assets/javascripts/preferences/panes/General.tsx @@ -2,7 +2,7 @@ import { WebApplication } from '@/ui_models/application'; import { AppState } from '@/ui_models/app_state'; import { FunctionComponent } from 'preact'; import { PreferencesPane } from '../components'; -import { ErrorReporting, Tools, Defaults, LabsPane } from './general-segments'; +import { Tools, Defaults, LabsPane } from './general-segments'; import { ExtensionsLatestVersions } from '@/preferences/panes/extensions-segments'; import { Advanced } from '@/preferences/panes/account'; import { observer } from 'mobx-react-lite'; @@ -18,7 +18,6 @@ export const General: FunctionComponent = observer( - = observer(({ appState }: Props) => { - const [isErrorReportingEnabled] = useState(() => storage.get(StorageKey.DisableErrorReporting) === false); - const [errorReportingIdValue] = useState(() => errorReportingId()); - - const toggleErrorReportingEnabled = () => { - if (isErrorReportingEnabled) { - disableErrorReporting(); - } else { - enableErrorReporting(); - } - if (!appState.sync.inProgress) { - window.location.reload(); - } - }; - - const openErrorReportingDialog = () => { - alertDialog({ - title: 'Data sent during automatic error reporting', - text: ` - We use Bugsnag - to automatically report errors that occur while the app is running. See - - this article, paragraph 'Browser' under 'Sending diagnostic data', - - to see what data is included in error reports. -

- 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. - ` - }); - }; - - return ( - - - -
-
- Error Reporting - - Help us improve Standard Notes by automatically submitting - anonymized error reports. - -
-
- -
-
-
- - {errorReportingIdValue && ( - <> - - Your random identifier is {errorReportingIdValue} - - - Disabling error reporting will remove that identifier from your - local storage, and a new identifier will be created should you - decide to enable error reporting again in the future. - - - )} - - - What data is being sent? - - - - ); -}); diff --git a/app/assets/javascripts/preferences/panes/general-segments/index.ts b/app/assets/javascripts/preferences/panes/general-segments/index.ts index 32a2585a3ed..dcd7d3af7e0 100644 --- a/app/assets/javascripts/preferences/panes/general-segments/index.ts +++ b/app/assets/javascripts/preferences/panes/general-segments/index.ts @@ -1,4 +1,3 @@ -export * from './ErrorReporting'; export * from './Tools'; export * from './Defaults'; export * from './Labs'; diff --git a/app/assets/javascripts/services/errorReporting.ts b/app/assets/javascripts/services/errorReporting.ts deleted file mode 100644 index 57776974070..00000000000 --- a/app/assets/javascripts/services/errorReporting.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { isNullOrUndefined, SNLog } from '@standardnotes/snjs'; -import { getDesktopVersion, isDesktopApplication, isDev } from '@/utils'; -import { storage, StorageKey } from './localStorage'; -import Bugsnag from '@bugsnag/js'; -import { WebCrypto } from '../crypto'; -import { WebAppVersion } from '@/version'; - -function redactFilePath(line: string): string { - const fileName = line.match(/\w+\.(html|js)/)?.[0]; - const redacted = ''; - if (fileName) { - return redacted + '/' + fileName; - } else { - return redacted; - } -} - -export function startErrorReporting(): void { - const disableErrorReporting = storage.get(StorageKey.DisableErrorReporting); - if ( - /** - * 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.bugsnagApiKey - ) { - SNLog.onError = console.error; - return; - } - try { - const storedUserId = storage.get(StorageKey.AnonymousUserId); - let anonymousUserId: string; - if (storedUserId === null) { - anonymousUserId = WebCrypto.generateUUID(); - storage.set(StorageKey.AnonymousUserId, anonymousUserId); - } else { - anonymousUserId = storedUserId; - } - - Bugsnag.start({ - apiKey: window.bugsnagApiKey, - appType: isDesktopApplication() ? 'desktop' : 'web', - appVersion: getDesktopVersion() || WebAppVersion, - collectUserIp: false, - autoTrackSessions: false, - releaseStage: isDev ? 'development' : undefined, - enabledBreadcrumbTypes: ['error', 'log'], - onError(event) { - event.setUser(anonymousUserId); - - /** - * Redact any data that could be used to identify user, - * such as file paths. - */ - if (isDesktopApplication()) { - if (event.context) { - event.context = `Desktop/${redactFilePath(event.context)}`; - } - } - - if (event.request.url?.includes('file:')) { - event.request.url = redactFilePath(event.request.url); - } - - const originalStack = event.originalError.stack; - if ( - typeof originalStack === 'string' && - originalStack.includes('file:') - ) { - event.originalError.stack = originalStack - .split('\n') - .map((line) => - line.includes('file:') ? redactFilePath(line) : line - ) - .join('\n'); - } - - for (const error of event.errors) { - for (const stackFrame of error.stacktrace) { - if (stackFrame.file.includes('file:')) { - stackFrame.file = redactFilePath(stackFrame.file); - } - } - } - }, - }); - - 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; - } -} - -export function disableErrorReporting() { - storage.remove(StorageKey.AnonymousUserId); - storage.set(StorageKey.DisableErrorReporting, true); -} - -export function enableErrorReporting() { - storage.set(StorageKey.DisableErrorReporting, false); -} - -export function errorReportingId() { - return storage.get(StorageKey.AnonymousUserId); -} diff --git a/app/assets/javascripts/services/localStorage.ts b/app/assets/javascripts/services/localStorage.ts index fa03d7c9b83..63558941515 100644 --- a/app/assets/javascripts/services/localStorage.ts +++ b/app/assets/javascripts/services/localStorage.ts @@ -1,16 +1,14 @@ export enum StorageKey { - DisableErrorReporting = 'DisableErrorReporting', AnonymousUserId = 'AnonymousUserId', ShowBetaWarning = 'ShowBetaWarning', ShowNoAccountWarning = 'ShowNoAccountWarning', } export type StorageValue = { - [StorageKey.DisableErrorReporting]: boolean; [StorageKey.AnonymousUserId]: string; [StorageKey.ShowBetaWarning]: boolean; [StorageKey.ShowNoAccountWarning]: boolean; -} +}; export const storage = { get(key: K): StorageValue[K] | null { diff --git a/app/views/application/app.html.erb b/app/views/application/app.html.erb index 582011651a0..001336b1bc4 100644 --- a/app/views/application/app.html.erb +++ b/app/views/application/app.html.erb @@ -33,7 +33,6 @@