-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
58 lines (53 loc) · 1.71 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
require('fast-text-encoding');
import * as Sentry from '@sentry/react-native';
import { registerRootComponent } from 'expo';
import * as TaskManager from 'expo-task-manager';
import { SENTRY_DSN } from 'react-native-dotenv';
import App from './src';
import { LOCATION_TASK_NAME, MAX_PERMIT_ACCURACY } from './src/constants';
import { setLocation } from './src/hooks/useLocationStore';
if (!__DEV__) {
Sentry.init({
dsn: SENTRY_DSN,
enableAutoSessionTracking: true,
tracesSampleRate: 1.0,
profilesSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
integrations: [
Sentry.mobileReplayIntegration({
maskAllText: true,
blockAllMedia: true,
privacyOptions: {
maskAllInputs: true,
blockClass: ['sensitive-screen', 'payment-view'],
},
}),
],
});
}
if (!TaskManager.isTaskDefined(LOCATION_TASK_NAME)) {
TaskManager.defineTask(LOCATION_TASK_NAME, ({ data, error }) => {
if (error) {
console.error(error);
return;
}
const latestLocation = data.locations[data.locations.length - 1];
const bestAccuracyLocation = data.locations.reduce((best, cur) => {
if (best.coords.accuracy > cur.coords.accuracy) {
return cur;
}
return best;
}, latestLocation);
if (bestAccuracyLocation) {
if (bestAccuracyLocation.coords.accuracy > MAX_PERMIT_ACCURACY) {
return;
}
setLocation(bestAccuracyLocation);
}
});
}
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in the Expo client or in a native build,
// the environment is set up appropriately
registerRootComponent(App);