mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
import { getUniqueId } from 'react-native-device-info';
|
|
import Bugsnag from '@bugsnag/react-native';
|
|
import BlueApp from '../BlueApp';
|
|
|
|
/**
|
|
* in case Bugsnag was started, but user decided to opt out while using the app, we have this
|
|
* flag `userHasOptedOut` and we forbid logging in `onError` handler
|
|
* @type {boolean}
|
|
*/
|
|
let userHasOptedOut: boolean = false;
|
|
|
|
if (process.env.NODE_ENV !== 'development') {
|
|
(async () => {
|
|
const uniqueID = await getUniqueId();
|
|
const doNotTrack = await BlueApp.isDoNotTrackEnabled();
|
|
|
|
if (doNotTrack) {
|
|
// dont start Bugsnag at all
|
|
return;
|
|
}
|
|
|
|
Bugsnag.start({
|
|
user: {
|
|
id: uniqueID,
|
|
},
|
|
onError: function (event) {
|
|
return !userHasOptedOut;
|
|
},
|
|
});
|
|
})();
|
|
}
|
|
|
|
const A = async (event: string) => {};
|
|
|
|
A.ENUM = {
|
|
INIT: 'INIT',
|
|
GOT_NONZERO_BALANCE: 'GOT_NONZERO_BALANCE',
|
|
GOT_ZERO_BALANCE: 'GOT_ZERO_BALANCE',
|
|
CREATED_WALLET: 'CREATED_WALLET',
|
|
CREATED_LIGHTNING_WALLET: 'CREATED_LIGHTNING_WALLET',
|
|
APP_UNSUSPENDED: 'APP_UNSUSPENDED',
|
|
};
|
|
|
|
A.setOptOut = (value: boolean) => {
|
|
if (value) userHasOptedOut = true;
|
|
};
|
|
|
|
A.logError = (errorString: string) => {
|
|
console.error(errorString);
|
|
Bugsnag.notify(new Error(String(errorString)));
|
|
};
|
|
|
|
export default A;
|