feat: (wip) add error reporting
This commit is contained in:
@@ -53,6 +53,7 @@ import {
|
||||
import { trusted } from './filters';
|
||||
import { isDev } from './utils';
|
||||
import { Bridge, BrowserBridge } from './services/bridge';
|
||||
import { startErrorReporting } from './services/errorReporting';
|
||||
|
||||
if (__WEB__) {
|
||||
startApplication(
|
||||
@@ -67,6 +68,7 @@ function startApplication(
|
||||
defaultSyncServerHost: string,
|
||||
bridge: Bridge
|
||||
) {
|
||||
startErrorReporting();
|
||||
angular.module('app', ['ngSanitize']);
|
||||
|
||||
// Config
|
||||
|
||||
23
app/assets/javascripts/services/errorReporting.ts
Normal file
23
app/assets/javascripts/services/errorReporting.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { isDesktopApplication, isDev } from '@/utils';
|
||||
import { storage, StorageKey } from './localStorage';
|
||||
import Bugsnag from '@bugsnag/js';
|
||||
|
||||
declare const __VERSION__: string;
|
||||
|
||||
export async function startErrorReporting() {
|
||||
if (storage.get(StorageKey.DisableErrorReporting)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Bugsnag.start({
|
||||
apiKey: (window as any)._bugsnag_api_key,
|
||||
appType: isDesktopApplication() ? 'desktop' : 'web',
|
||||
appVersion: __VERSION__,
|
||||
collectUserIp: false,
|
||||
autoTrackSessions: false,
|
||||
releaseStage: isDev ? 'development' : undefined
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Failed to start Bugsnag.', error);
|
||||
}
|
||||
}
|
||||
16
app/assets/javascripts/services/localStorage.ts
Normal file
16
app/assets/javascripts/services/localStorage.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export enum StorageKey {
|
||||
DisableErrorReporting = 'DisableErrorReporting',
|
||||
}
|
||||
|
||||
export const storage = {
|
||||
get(key: StorageKey) {
|
||||
const value = localStorage.getItem(key);
|
||||
return value ? JSON.parse(value) : null;
|
||||
},
|
||||
set(key: StorageKey, value: unknown) {
|
||||
localStorage.setItem(key, JSON.stringify(value));
|
||||
},
|
||||
remove(key: StorageKey) {
|
||||
localStorage.removeItem(key);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user