[IMPROVEMENT] Log server version (#1786)

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-02-28 16:51:13 -03:00 committed by GitHub
parent 9d615d5ffb
commit ea4f3797ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View File

@ -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);

View File

@ -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);
}