feat: remove bugsnag (#931)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<GeneralProps> = observer(
|
||||
<PreferencesPane>
|
||||
<Tools application={application} />
|
||||
<Defaults application={application} />
|
||||
<ErrorReporting appState={appState} />
|
||||
<LabsPane application={application} />
|
||||
<Advanced
|
||||
application={application}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
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';
|
||||
import { FunctionComponent } from 'preact';
|
||||
import { PreferencesGroup, PreferencesSegment, Title, Text } from '@/preferences/components';
|
||||
import { Switch } from '@/components/Switch';
|
||||
|
||||
type Props = {
|
||||
appState: AppState;
|
||||
}
|
||||
|
||||
export const ErrorReporting: FunctionComponent<Props> = 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 <a target="_blank" rel="noreferrer" href="https://www.bugsnag.com/">Bugsnag</a>
|
||||
to automatically report errors that occur while the app is running. See
|
||||
<a target="_blank" rel="noreferrer" 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.
|
||||
`
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<PreferencesGroup>
|
||||
<PreferencesSegment>
|
||||
|
||||
<div className="flex flex-row items-center">
|
||||
<div className="flex-grow flex flex-col">
|
||||
<Title>Error Reporting</Title>
|
||||
<Text>
|
||||
Help us improve Standard Notes by automatically submitting
|
||||
anonymized error reports.
|
||||
</Text>
|
||||
</div>
|
||||
<div className="flex flex-col justify-center items-center min-w-15">
|
||||
<Switch onChange={toggleErrorReportingEnabled} checked={isErrorReportingEnabled} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="min-h-2" />
|
||||
|
||||
{errorReportingIdValue && (
|
||||
<>
|
||||
<Text>
|
||||
Your random identifier is <span className="font-bold">{errorReportingIdValue}</span>
|
||||
</Text>
|
||||
<Text>
|
||||
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.
|
||||
</Text>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Text>
|
||||
<a className="cursor-pointer" onClick={openErrorReportingDialog}>What data is being sent?</a>
|
||||
</Text>
|
||||
</PreferencesSegment>
|
||||
</PreferencesGroup>
|
||||
);
|
||||
});
|
||||
@@ -1,4 +1,3 @@
|
||||
export * from './ErrorReporting';
|
||||
export * from './Tools';
|
||||
export * from './Defaults';
|
||||
export * from './Labs';
|
||||
|
||||
@@ -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 = '<redacted file path>';
|
||||
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);
|
||||
}
|
||||
@@ -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<K extends StorageKey>(key: K): StorageValue[K] | null {
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
<script>
|
||||
window.defaultSyncServer = "<%= ENV['DEFAULT_SYNC_SERVER'] %>";
|
||||
window.defaultFilesHost = "<%= ENV['DEFAULT_FILES_HOST'] %>";
|
||||
window.bugsnagApiKey = "<%= ENV['BUGSNAG_API_KEY'] %>";
|
||||
window.enabledUnfinishedFeatures = "<%= ENV['ENABLE_UNFINISHED_FEATURES'] %>" === 'true';
|
||||
window.websocketUrl = "<%= ENV['WEBSOCKET_URL'] %>";
|
||||
window.purchaseUrl = "<%= ENV['PURCHASE_URL'] %>";
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
<body
|
||||
data-default-sync-server="<%= env.DEFAULT_SYNC_SERVER %>"
|
||||
data-default-files-host="<%= env.DEFAULT_FILES_HOST %>"
|
||||
data-bugsnag-api-key="<%= env.BUGSNAG_API_KEY %>"
|
||||
data-enable-unfinished-features="<%= env.ENABLE_UNFINISHED_FEATURES %>"
|
||||
data-web-socket-url="<%= env.WEBSOCKET_URL %>"
|
||||
data-purchase-url="<%= env.PURCHASE_URL %>"
|
||||
@@ -44,7 +43,6 @@
|
||||
<script>
|
||||
window.defaultSyncServer = document.body.dataset.defaultSyncServer || "https://api.standardnotes.com";
|
||||
window.defaultFilesHost = document.body.dataset.defaultFilesHost;
|
||||
window.bugsnagApiKey = document.body.dataset.bugsnagApiKey;
|
||||
window.enabledUnfinishedFeatures = document.body.dataset.enableUnfinishedFeatures === 'true';
|
||||
window.websocketUrl = document.body.dataset.webSocketUrl;
|
||||
window.purchaseUrl = document.body.dataset.purchaseUrl;
|
||||
|
||||
@@ -72,7 +72,6 @@
|
||||
"webpack-merge": "^5.8.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@bugsnag/js": "^7.16.2",
|
||||
"@reach/alert": "^0.16.0",
|
||||
"@reach/alert-dialog": "^0.16.2",
|
||||
"@reach/checkbox": "^0.16.0",
|
||||
|
||||
77
yarn.lock
77
yarn.lock
@@ -1751,54 +1751,6 @@
|
||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@bugsnag/browser@^7.16.2":
|
||||
version "7.16.2"
|
||||
resolved "https://registry.yarnpkg.com/@bugsnag/browser/-/browser-7.16.2.tgz#b6fc7ebaeae4800d195b660abc770caf33670e03"
|
||||
integrity sha512-iBbAmjTDe0I6WPTHi3wIcmKu3ykydtT6fc8atJA65rzgDLMlTM1Wnwz4Ny1cn0bVouLGa48BRiOJ27Rwy7QRYA==
|
||||
dependencies:
|
||||
"@bugsnag/core" "^7.16.1"
|
||||
|
||||
"@bugsnag/core@^7.16.1":
|
||||
version "7.16.1"
|
||||
resolved "https://registry.yarnpkg.com/@bugsnag/core/-/core-7.16.1.tgz#0376b5c4dd7b44f57eb503775857d974e4b5afc9"
|
||||
integrity sha512-zuBnL7B329VldItRqhXYrp1hjmjZnltJwNXMysi9WtY4t29WKk5LVwgWb1mPM9clJ0FoObZ7kvvQMUTKh3ezFQ==
|
||||
dependencies:
|
||||
"@bugsnag/cuid" "^3.0.0"
|
||||
"@bugsnag/safe-json-stringify" "^6.0.0"
|
||||
error-stack-parser "^2.0.3"
|
||||
iserror "0.0.2"
|
||||
stack-generator "^2.0.3"
|
||||
|
||||
"@bugsnag/cuid@^3.0.0":
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@bugsnag/cuid/-/cuid-3.0.0.tgz#2ee7642a30aee6dc86f5e7f824653741e42e5c35"
|
||||
integrity sha512-LOt8aaBI+KvOQGneBtpuCz3YqzyEAehd1f3nC5yr9TIYW1+IzYKa2xWS4EiMz5pPOnRPHkyyS5t/wmSmN51Gjg==
|
||||
|
||||
"@bugsnag/js@^7.16.2":
|
||||
version "7.16.2"
|
||||
resolved "https://registry.yarnpkg.com/@bugsnag/js/-/js-7.16.2.tgz#fb15ec9cc5980f0b210aecc7b740274e50400a91"
|
||||
integrity sha512-AzV0PtG3SZt+HnA2JmRJeI60aDNZsIJbEEAZIWZeATvWBt5RdVdsWKllM1SkTvURfxfdAVd4Xry3BgVrh8nEbg==
|
||||
dependencies:
|
||||
"@bugsnag/browser" "^7.16.2"
|
||||
"@bugsnag/node" "^7.16.2"
|
||||
|
||||
"@bugsnag/node@^7.16.2":
|
||||
version "7.16.2"
|
||||
resolved "https://registry.yarnpkg.com/@bugsnag/node/-/node-7.16.2.tgz#8ac1b41786306d8917fb9fe222ada74fe0c4c6d5"
|
||||
integrity sha512-V5pND701cIYGzjjTwt0tuvAU1YyPB9h7vo5F/DzrDHRPmCINA/oVbc0Twco87knc2VPe8ntGFqTicTY65iOWzg==
|
||||
dependencies:
|
||||
"@bugsnag/core" "^7.16.1"
|
||||
byline "^5.0.0"
|
||||
error-stack-parser "^2.0.2"
|
||||
iserror "^0.0.2"
|
||||
pump "^3.0.0"
|
||||
stack-generator "^2.0.3"
|
||||
|
||||
"@bugsnag/safe-json-stringify@^6.0.0":
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@bugsnag/safe-json-stringify/-/safe-json-stringify-6.0.0.tgz#22abdcd83e008c369902976730c34c150148a758"
|
||||
integrity sha512-htzFO1Zc57S8kgdRK9mLcPVTW1BY2ijfH7Dk2CeZmspTWKdKqSo1iwmqrq2WtRjFlo8aRZYgLX0wFrDXF/9DLA==
|
||||
|
||||
"@discoveryjs/json-ext@^0.5.0":
|
||||
version "0.5.5"
|
||||
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.5.tgz#9283c9ce5b289a3c4f61c12757469e59377f81f3"
|
||||
@@ -3694,11 +3646,6 @@ buffer@^6.0.3:
|
||||
base64-js "^1.3.1"
|
||||
ieee754 "^1.2.1"
|
||||
|
||||
byline@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/byline/-/byline-5.0.0.tgz#741c5216468eadc457b03410118ad77de8c1ddb1"
|
||||
integrity sha1-dBxSFkaOrcRXsDQQEYrXfejB3bE=
|
||||
|
||||
bytes@3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048"
|
||||
@@ -4634,13 +4581,6 @@ error-ex@^1.3.1:
|
||||
dependencies:
|
||||
is-arrayish "^0.2.1"
|
||||
|
||||
error-stack-parser@^2.0.2, error-stack-parser@^2.0.3:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/error-stack-parser/-/error-stack-parser-2.0.6.tgz#5a99a707bd7a4c58a797902d48d82803ede6aad8"
|
||||
integrity sha512-d51brTeqC+BHlwF0BhPtcYgF5nlzf9ZZ0ZIUQNZpc9ZB9qw5IJ2diTrBY9jlCJkTLITYPjmiX6OWCwH+fuyNgQ==
|
||||
dependencies:
|
||||
stackframe "^1.1.1"
|
||||
|
||||
es-abstract@^1.17.0-next.1:
|
||||
version "1.17.7"
|
||||
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.7.tgz#a4de61b2f66989fc7421676c1cb9787573ace54c"
|
||||
@@ -6123,11 +6063,6 @@ isarray@~1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
|
||||
integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
|
||||
|
||||
iserror@0.0.2, iserror@^0.0.2:
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/iserror/-/iserror-0.0.2.tgz#bd53451fe2f668b9f2402c1966787aaa2c7c0bf5"
|
||||
integrity sha1-vVNFH+L2aLnyQCwZZnh6qix8C/U=
|
||||
|
||||
isexe@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
|
||||
@@ -8878,13 +8813,6 @@ stable@^0.1.8:
|
||||
resolved "https://registry.yarnpkg.com/stable/-/stable-0.1.8.tgz#836eb3c8382fe2936feaf544631017ce7d47a3cf"
|
||||
integrity sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==
|
||||
|
||||
stack-generator@^2.0.3:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/stack-generator/-/stack-generator-2.0.5.tgz#fb00e5b4ee97de603e0773ea78ce944d81596c36"
|
||||
integrity sha512-/t1ebrbHkrLrDuNMdeAcsvynWgoH/i4o8EGGfX7dEYDoTXOYVAkEpFdtshlvabzc6JlJ8Kf9YdFEoz7JkzGN9Q==
|
||||
dependencies:
|
||||
stackframe "^1.1.1"
|
||||
|
||||
stack-utils@^2.0.3:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.5.tgz#d25265fca995154659dbbfba3b49254778d2fdd5"
|
||||
@@ -8892,11 +8820,6 @@ stack-utils@^2.0.3:
|
||||
dependencies:
|
||||
escape-string-regexp "^2.0.0"
|
||||
|
||||
stackframe@^1.1.1:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.2.0.tgz#52429492d63c62eb989804c11552e3d22e779303"
|
||||
integrity sha512-GrdeshiRmS1YLMYgzF16olf2jJ/IzxXY9lhKOskuVziubpTYcYqyOwYeJKzQkwy7uN0fYSsbsC4RQaXf9LCrYA==
|
||||
|
||||
"statuses@>= 1.4.0 < 2", "statuses@>= 1.5.0 < 2", statuses@~1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
|
||||
|
||||
Reference in New Issue
Block a user