forked from LedgerHQ/ledger-live-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
75 lines (62 loc) · 2.23 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
75
// @flow
// Fix for crash with `Unsupported top level event type "onGestureHandlerStateChange" dispatched`
// https://github.com/kmagiera/react-native-gesture-handler/issues/320#issuecomment-443815828
import "react-native-gesture-handler";
/** URL polyfill */
// URL object `intentionally` lightweight, does not support URLSearchParams features
// https://github.com/facebook/react-native/issues/23922
import "react-native-url-polyfill/auto";
import { AppRegistry } from "react-native";
import { Sentry } from "react-native-sentry";
import Config from "react-native-config";
import App from "./src";
import { getEnabled } from "./src/components/HookSentry";
import logReport from "./src/log-report";
if (Config.SENTRY_DSN && !__DEV__ && !Config.MOCK) {
Sentry.config(Config.SENTRY_DSN, {
handlePromiseRejection: true,
autoBreadcrumbs: {
xhr: false,
},
}).install();
Sentry.setUserContext({
ip_address: null,
});
const blacklistErrorName = ["NetworkDown"];
const blacklistErrorDescription = [/Device .* was disconnected/];
Sentry.setShouldSendCallback((event: mixed) => {
if (!getEnabled()) return false;
// If the error matches blacklistErrorName or blacklistErrorDescription,
// we will not send it to Sentry.
if (event && typeof event === "object") {
const { exception } = event;
if (
exception &&
typeof exception === "object" &&
Array.isArray(exception.values)
) {
const { values } = exception;
const shouldBlacklist = values.some(item => {
if (item && typeof item === "object") {
const { type, value } = item;
return (
(typeof type === "string" &&
blacklistErrorName.some(pattern => type.match(pattern))) ||
(typeof value === "string" &&
blacklistErrorDescription.some(pattern => value.match(pattern)))
);
}
return false;
});
if (shouldBlacklist) return false;
}
}
return true;
});
}
if (Config.DISABLE_YELLOW_BOX) {
// $FlowFixMe
console.disableYellowBox = true; // eslint-disable-line no-console
}
logReport.logReportInit();
AppRegistry.registerComponent("ledgerlivemobile", () => App);