forked from pagopa/io-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
61 lines (56 loc) · 1.54 KB
/
index.js
File metadata and controls
61 lines (56 loc) · 1.54 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* eslint-disable functional/immutable-data */
/**
* Main app entrypoint
*/
// Shim file generated by rn-nodeify
import "./shim";
import "react-native-get-random-values";
import {
AlertStatic as Alert,
AppRegistry,
Text,
TextInput,
LogBox
} from "react-native";
import DeviceInfo from "react-native-device-info";
import {
setJSExceptionHandler,
setNativeExceptionHandler
} from "react-native-exception-handler";
import App from "./ts/App";
import {initI18n} from "./ts/i18n";
import { isMixpanelInstanceInitialized, mixpanelTrack } from "./ts/mixpanel";
import { name as appName } from "./app.json";
void initI18n();
const errorHandler = (e, isFatal) => {
if (isFatal) {
if (isMixpanelInstanceInitialized()) {
mixpanelTrack("APPLICATION_ERROR", {
TYPE: "js",
ERROR: JSON.stringify(e),
APP_VERSION: DeviceInfo.getReadableVersion()
});
}
Alert.alert(
"Unexpected error occurred",
`
Error: ${isFatal ? "Fatal:" : ""} ${e.name} ${e.message}
You will need to restart the app.
`
);
} else {
// eslint-disable-next-line no-console
console.log(e); // So that we can see it in the ADB logs in case of Android if needed
}
};
setJSExceptionHandler(errorHandler);
setNativeExceptionHandler(exceptionString => {
if (isMixpanelInstanceInitialized()) {
mixpanelTrack("APPLICATION_ERROR", {
TYPE: "native",
ERROR: exceptionString,
APP_VERSION: DeviceInfo.getReadableVersion()
});
}
});
AppRegistry.registerComponent(appName, () => App);