From ea4f3797ff1f7bd60819b7da0d43ef9c730b654e Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Fri, 28 Feb 2020 16:51:13 -0300 Subject: [PATCH] [IMPROVEMENT] Log server version (#1786) Co-authored-by: Diego Mello --- app/sagas/selectServer.js | 8 ++++++-- app/utils/log.js | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/sagas/selectServer.js b/app/sagas/selectServer.js index c939868f5..535aecd47 100644 --- a/app/sagas/selectServer.js +++ b/app/sagas/selectServer.js @@ -15,7 +15,7 @@ import { import { setUser } from '../actions/login'; import RocketChat from '../lib/rocketchat'; import database from '../lib/database'; -import log from '../utils/log'; +import log, { logServerVersion } from '../utils/log'; import { extractHostname } from '../utils/server'; import I18n from '../i18n'; import { SERVERS, TOKEN, SERVER_URL } from '../constants/userDefaults'; @@ -113,7 +113,11 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch } // Return server version even when offline - yield put(selectServerSuccess(server, (serverInfo && serverInfo.version) || version)); + const serverVersion = (serverInfo && serverInfo.version) || version; + + // we'll set serverVersion as metadata for bugsnag + logServerVersion(serverVersion); + yield put(selectServerSuccess(server, serverVersion)); } catch (e) { yield put(selectServerFailure()); log(e); diff --git a/app/utils/log.js b/app/utils/log.js index 357b4dc41..b4605bd64 100644 --- a/app/utils/log.js +++ b/app/utils/log.js @@ -8,9 +8,23 @@ export const { analytics } = firebase; export const loggerConfig = bugsnag.config; export const { leaveBreadcrumb } = bugsnag; +let metadata = {}; + +export const logServerVersion = (serverVersion) => { + metadata = { + serverVersion + }; +}; + export default (e) => { if (e instanceof Error && !__DEV__) { - bugsnag.notify(e); + bugsnag.notify(e, (report) => { + report.metadata = { + details: { + ...metadata + } + }; + }); } else { console.log(e); }