2019-08-23 13:18:47 +00:00
|
|
|
import { Client } from 'bugsnag-react-native';
|
2019-05-28 13:03:08 +00:00
|
|
|
import firebase from 'react-native-firebase';
|
2019-08-23 13:18:47 +00:00
|
|
|
import config from '../../config';
|
2018-05-18 17:55:08 +00:00
|
|
|
|
2019-08-23 13:18:47 +00:00
|
|
|
const bugsnag = new Client(config.BUGSNAG_API_KEY);
|
|
|
|
|
|
|
|
export const { analytics } = firebase;
|
|
|
|
export const loggerConfig = bugsnag.config;
|
|
|
|
export const { leaveBreadcrumb } = bugsnag;
|
|
|
|
|
2020-02-28 19:51:13 +00:00
|
|
|
let metadata = {};
|
|
|
|
|
|
|
|
export const logServerVersion = (serverVersion) => {
|
|
|
|
metadata = {
|
|
|
|
serverVersion
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-08-31 19:22:58 +00:00
|
|
|
export default (e) => {
|
2019-09-16 20:26:32 +00:00
|
|
|
if (e instanceof Error && !__DEV__) {
|
2020-02-28 19:51:13 +00:00
|
|
|
bugsnag.notify(e, (report) => {
|
|
|
|
report.metadata = {
|
|
|
|
details: {
|
|
|
|
...metadata
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
2019-08-31 19:22:58 +00:00
|
|
|
} else {
|
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
};
|