-
Notifications
You must be signed in to change notification settings - Fork 21
/
integrations.js
43 lines (34 loc) · 1.15 KB
/
integrations.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {AsyncStorage} from "react-native";
import {Client, Configuration} from "bugsnag-react-native";
import Analitics from "appcenter-analytics";
export const isEventsEnabled = async () =>
(await AsyncStorage.getItem("EVENTS")) === "true";
export const setEventIsEnabled = async isEnabled => {
await AsyncStorage.setItem("EVENTS", isEnabled.toString());
await setUpEvents(isEnabled);
};
export const isCrashEnabled = async () =>
(await AsyncStorage.getItem("CRASH_REPORTS")) === "true";
export const setCrashEnabled = async isEnabled => {
await AsyncStorage.setItem("CRASH_REPORTS", isEnabled.toString());
await setUpCrashReports();
};
export const setUpEvents = async () => {
const isEnabled = await isEventsEnabled();
await Analitics.setEnabled(isEnabled);
};
let bugsnag;
let _isBugsEnabled = false;
const initBagSnag = () => {
if (!bugsnag) {
const configuration = new Configuration("5fce34026e5537c6f757fd54b5247a32");
configuration.registerBeforeSendCallback(() => {
return _isBugsEnabled;
});
bugsnag = new Client(configuration);
}
};
export const setUpCrashReports = async () => {
_isBugsEnabled = await isCrashEnabled();
initBagSnag();
};