-
-
Notifications
You must be signed in to change notification settings - Fork 360
Expand file tree
/
Copy pathApp.tsx
More file actions
266 lines (253 loc) · 8.49 KB
/
App.tsx
File metadata and controls
266 lines (253 loc) · 8.49 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
import React from 'react';
import { Ionicons } from '@react-native-vector-icons/ionicons';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import {
NavigationContainer,
NavigationContainerRef,
TypedNavigator,
} from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createStackNavigator } from '@react-navigation/stack';
import * as Sentry from '@sentry/react-native';
import { isTurboModuleEnabled } from '@sentry/react-native/dist/js/utils/environment';
import { LogBox, Platform } from 'react-native';
import * as ImagePicker from 'react-native-image-picker';
import RunningIndicator from './components/RunningIndicator';
import WebviewScreen from './Screens/WebviewScreen';
import getErrorsTab from './tabs/ErrorsTab';
import getPerformanceTab from './tabs/PerformanceTab';
import getPlaygroundTab from './tabs/PlaygroundTab';
import { getDsn, logWithoutTracing } from './utils';
LogBox.ignoreAllLogs();
const isMobileOs = Platform.OS === 'android' || Platform.OS === 'ios';
if (typeof setImmediate === 'undefined') {
require('setimmediate');
}
const reactNavigationIntegration = Sentry.reactNavigationIntegration({
routeChangeTimeoutMs: 500, // How long it will wait for the route change to complete. Default is 1000ms
enableTimeToInitialDisplay: isMobileOs,
ignoreEmptyBackNavigationTransactions: false,
enableTimeToInitialDisplayForPreloadedRoutes: true,
useDispatchedActionData: true,
});
const sampleFeatureFlagsIntegration = Sentry.featureFlagsIntegration();
sampleFeatureFlagsIntegration.addFeatureFlag('sample-test-flag', true);
const StackNavigator: TypedNavigator<any, any> = isMobileOs
? createNativeStackNavigator()
: createStackNavigator();
const BottomTabNavigator = createBottomTabNavigator();
Sentry.init({
// Replace the example DSN below with your own DSN:
dsn: getDsn(),
debug: true,
environment: 'dev',
beforeSend: (event: Sentry.ErrorEvent) => {
logWithoutTracing('Event beforeSend:', event.event_id);
return event;
},
beforeSendTransaction(event: Sentry.TransactionEvent) {
logWithoutTracing('Transaction beforeSend:', event.event_id);
return event;
},
// This will be called with a boolean `didCallNativeInit` when the native SDK has been contacted.
onReady: ({ didCallNativeInit }) => {
logWithoutTracing(
'onReady called with didCallNativeInit:',
didCallNativeInit,
);
},
_experiments: {
enableUnhandledCPPExceptionsV2: true,
},
enableLogs: true,
beforeSendLog: (log) => {
return log;
},
enableUserInteractionTracing: true,
integrations(integrations) {
integrations.push(
reactNavigationIntegration,
Sentry.reactNativeTracingIntegration({
// The time to wait in ms until the transaction will be finished, For testing, default is 1000 ms
idleTimeoutMs: 5_000,
}),
Sentry.httpClientIntegration({
// These options are effective only in JS.
// This array can contain tuples of `[begin, end]` (both inclusive),
// Single status codes, or a combinations of both.
// default: [[500, 599]]
failedRequestStatusCodes: [[400, 599]],
// This array can contain Regexes or strings, or combinations of both.
// default: [/.*/]
failedRequestTargets: [/.*/],
}),
Sentry.mobileReplayIntegration({
maskAllImages: true,
maskAllVectors: true,
maskAllText: true,
enableViewRendererV2: true,
screenshotStrategy: 'canvas', // if you have strict PII requirements
}),
Sentry.appStartIntegration({
standalone: false,
}),
Sentry.reactNativeErrorHandlersIntegration({
patchGlobalPromise:
Platform.OS === 'ios' && isTurboModuleEnabled()
? // The global patch doesn't work on iOS with the New Architecture in this Sample app
// In
false
: true,
}),
Sentry.feedbackIntegration({
imagePicker: ImagePicker,
enableScreenshot: true,
enableTakeScreenshot: true,
styles: {
submitButton: {
backgroundColor: '#6a1b9a',
paddingVertical: 15,
borderRadius: 5,
alignItems: 'center',
marginBottom: 10,
},
},
namePlaceholder: 'Fullname',
buttonOptions: {
styles: {
triggerButton: {
marginBottom: 75, // Place above the tab bar
},
},
},
screenshotButtonOptions: {
styles: {
triggerButton: {
marginBottom: 75, // Place above the tab bar
},
},
},
}),
Sentry.extraErrorDataIntegration(),
sampleFeatureFlagsIntegration,
);
return integrations.filter(i => i.name !== 'Dedupe');
},
enableAutoSessionTracking: true,
// For testing, session close when 5 seconds (instead of the default 30) in the background.
sessionTrackingIntervalMillis: 30000,
tracesSampleRate: 1.0,
tracePropagationTargets: ['localhost', /^\//, /^https:\/\//, /^http:\/\//],
attachStacktrace: true,
// Attach screenshots to events.
attachScreenshot: true,
// Attach view hierarchy to events.
attachViewHierarchy: true,
// Enables capture failed requests in JS and native.
enableCaptureFailedRequests: true,
// Sets the `release` and `dist` on Sentry events. Make sure this matches EXACTLY with the values on your sourcemaps
// otherwise they will not work.
// release: 'myapp@1.2.3+1',
// dist: `1`,
profilesSampleRate: 1.0,
replaysSessionSampleRate: 1.0,
replaysOnErrorSampleRate: 1.0,
ignoreErrors: ['should', /(.)*2(.)*/],
replaysSessionQuality: 'medium', // default
spotlight: false,
// This should be disabled when manually initializing the native SDK
// Note that options from JS are not passed to the native SDKs when initialized manually
autoInitializeNativeSdk: true,
});
function BottomTabsNavigator() {
return (
<BottomTabNavigator.Navigator
screenOptions={{
headerShown: false,
}}
detachInactiveScreens={false}>
<BottomTabNavigator.Screen
name="ErrorsTab"
component={getErrorsTab(StackNavigator)}
options={{
tabBarLabel: 'Errors',
// eslint-disable-next-line react/no-unstable-nested-components
tabBarIcon: ({ focused, color, size }) => (
<Ionicons
name={focused ? 'bug' : 'bug-outline'}
size={size}
color={color}
testID="errors-tab-icon"
/>
),
}}
/>
<BottomTabNavigator.Screen
name="PerformanceTab"
component={getPerformanceTab(StackNavigator)}
options={{
tabBarLabel: 'Performance',
// eslint-disable-next-line react/no-unstable-nested-components
tabBarIcon: ({ focused, color, size }) => (
<Ionicons
name={focused ? 'speedometer' : 'speedometer-outline'}
size={size}
color={color}
testID="performance-tab-icon"
/>
),
}}
/>
<BottomTabNavigator.Screen
name="PlaygroundTab"
component={getPlaygroundTab()}
options={{
tabBarLabel: 'Playground',
// eslint-disable-next-line react/no-unstable-nested-components
tabBarIcon: ({ focused, color, size }) => (
<Ionicons
name={focused ? 'american-football' : 'american-football-outline'}
size={size}
color={color}
testID="playground-tab-icon"
/>
),
}}
/>
</BottomTabNavigator.Navigator>
);
}
function RootNavigationContainer() {
const navigation = React.useRef<NavigationContainerRef<{}>>(null);
return (
<NavigationContainer
ref={navigation}
onReady={() => {
reactNavigationIntegration.registerNavigationContainer(navigation);
}}>
<StackNavigator.Navigator
screenOptions={{
headerShown: false,
}}>
<StackNavigator.Screen
name="BottomTabs"
component={BottomTabsNavigator}
/>
<StackNavigator.Screen
name="Webview"
component={WebviewScreen}
options={{ headerShown: true }}
/>
</StackNavigator.Navigator>
</NavigationContainer>
);
}
function App() {
return (
<>
<RootNavigationContainer />
<RunningIndicator />
</>
);
}
export default Sentry.wrap(App);