From 49e351d6ba03bf21543585d17eb4260516843978 Mon Sep 17 00:00:00 2001 From: vantezzen Date: Sat, 26 Oct 2019 15:50:39 +0200 Subject: Extend debug information --- src/stores/AppStore.js | 14 +++++++++----- src/stores/GlobalErrorStore.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 59b100b55..894c19347 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -227,6 +227,9 @@ export default class AppStore extends Store { } @computed get debugInfo() { + const settings = JSON.parse(JSON.stringify(this.stores.settings.app)); + settings.lockedPassword = '******'; + return { host: { platform: process.platform, @@ -238,19 +241,20 @@ export default class AppStore extends Store { electron: process.versions.electron, installedRecipes: this.stores.recipes.all.map(recipe => ({ id: recipe.id, version: recipe.version })), devRecipes: this.stores.recipePreviews.dev.map(recipe => ({ id: recipe.id, version: recipe.version })), - services: this.stores.services.all.map(service => ({ - id: service.id, - recipe: service.recipe.id, - isAttached: service.isAttached, + services: this.stores.services.all.map(service => ({ + id: service.id, + recipe: service.recipe.id, + isAttached: service.isAttached, isActive: service.isActive, isEnabled: service.isEnabled, isHibernating: service.isHibernating, hasCrashed: service.hasCrashed, isDarkModeEnabled: service.isDarkModeEnabled, })), + errors: this.stores.globalError.errors, workspaces: this.stores.workspaces.workspaces.map(workspace => ({ id: workspace.id, services: workspace.services })), windowSettings: readJsonSync(path.join(app.getPath('userData'), 'window-state.json')), - settings: this.stores.settings.app, + settings, features: this.stores.features.features, user: this.stores.user.data.id, }, diff --git a/src/stores/GlobalErrorStore.js b/src/stores/GlobalErrorStore.js index 8bdafb68c..dbcc56606 100644 --- a/src/stores/GlobalErrorStore.js +++ b/src/stores/GlobalErrorStore.js @@ -5,14 +5,32 @@ import Request from './lib/Request'; export default class GlobalErrorStore extends Store { @observable error = null; + @observable errors = []; + @observable response = {}; constructor(...args) { super(...args); + window.onerror = this._handleConsoleError.bind(this); + + const origConsoleError = console.error; + console.error = (...args) => { + this._handleConsoleError.call(this, args); + origConsoleError.apply(this, args); + } + Request.registerHook(this._handleRequests); } + _handleConsoleError(error, url, line) { + this.errors.push({ + error, + url, + line + }); + } + _handleRequests = action(async (request) => { if (request.isError) { this.error = request.error; @@ -28,6 +46,17 @@ export default class GlobalErrorStore extends Store { // this.actions.user.logout({ serverLogout: true }); } } + + this.errors.push({ + request: { + result: request.result, + wasExecuted: request.wasExecuted, + method: request._method, + }, + error: this.error, + response: this.response, + server: window.ferdi.stores.settings.app.server, + }); } else { window.ferdi.stores.app.authRequestFailed = false; } -- cgit v1.2.3-70-g09d2