import { useState } from 'preact/hooks'; import { storage, StorageKey } from '@Services/localStorage'; import { disableErrorReporting, enableErrorReporting, errorReportingId } from '@Services/errorReporting'; import { alertDialog } from '@Services/alertService'; import { observer } from 'mobx-react-lite'; import { AppState } from '@/ui_models/app_state'; type Props = { appState: AppState; } const ErrorReporting = 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
Automatic error reporting is {isErrorReportingEnabled ? 'enabled' : 'disabled'}

Help us improve Standard Notes by automatically submitting anonymized error reports.

{errorReportingIdValue && ( <>

Your random identifier is strong {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?
); }); export default ErrorReporting;