-
Notifications
You must be signed in to change notification settings - Fork 104
/
index.js
74 lines (68 loc) · 1.92 KB
/
index.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* 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 { mixpanel } from "./ts/mixpanel";
import { name as appName } from "./app.json";
const errorHandler = (e, isFatal) => {
if (isFatal) {
if (mixpanel) {
mixpanel.track("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 (mixpanel) {
mixpanel.track("APPLICATION_ERROR", {
TYPE: "native",
ERROR: exceptionString,
APP_VERSION: DeviceInfo.getReadableVersion()
});
}
});
// Please note that any LogBox can cause e2e tests to fail.
// TODO: temp only, to complete the porting to 0.63.x
LogBox.ignoreLogs([
"componentWillReceiveProps",
"Function components cannot be given refs",
"Animated",
"Virtualized",
"currentlyFocusedField"
]);
// Disable allowFontScaling for Text/TextInput component
Text.defaultProps = Text.defaultProps || {};
Text.defaultProps.allowFontScaling = false;
TextInput.defaultProps = TextInput.defaultProps || {};
TextInput.defaultProps.allowFontScaling = false;
AppRegistry.registerComponent(appName, () => App);