-
-
Notifications
You must be signed in to change notification settings - Fork 359
Expand file tree
/
Copy pathoptions.ts
More file actions
373 lines (321 loc) · 11.8 KB
/
options.ts
File metadata and controls
373 lines (321 loc) · 11.8 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
import type { makeFetchTransport } from '@sentry/browser';
import type { CaptureContext, ClientOptions, Event, EventHint, Options } from '@sentry/core';
import type { BrowserOptions, Profiler } from '@sentry/react';
import type * as React from 'react';
import { Platform } from 'react-native';
import type { TouchEventBoundaryProps } from './touchevents';
import { isExpoGo } from './utils/environment';
type ProfilerProps = React.ComponentProps<typeof Profiler>;
type BrowserTransportOptions = Parameters<typeof makeFetchTransport>[0];
type BrowserExperiments = NonNullable<BrowserOptions['_experiments']>;
type SharedExperimentsSubset = BrowserExperiments;
export interface BaseReactNativeOptions {
/**
* Enables native transport + device info + offline caching.
* Be careful, disabling this also breaks automatic release setting.
* This means you have to manage setting the release yourself.
* Defaults to `true`.
*/
enableNative?: boolean;
/**
* Enables native crashHandling. This only works if `enableNative` is `true`.
* Defaults to `true`.
*/
enableNativeCrashHandling?: boolean;
/**
* Initializes the native SDK on init.
* Set this to `false` if you have an existing native SDK and don't want to re-initialize.
*
* NOTE: Be careful and only use this if you know what you are doing.
* If you use this flag, make sure a native SDK is running before the JS Engine initializes or events might not be captured.
* Also, make sure the DSN on both the React Native side and the native side are the same one.
* We strongly recommend checking the documentation if you need to use this.
*
* @default true
*/
autoInitializeNativeSdk?: boolean;
/** Should the native nagger alert be shown or not. */
enableNativeNagger?: boolean;
/** Should sessions be tracked to Sentry Health or not. */
enableAutoSessionTracking?: boolean;
/** The interval to end a session if the App goes to the background. */
sessionTrackingIntervalMillis?: number;
/** Enable NDK on Android
*
* @default true
* @platform android
*/
enableNdk?: boolean;
/** Enable scope sync from Java to NDK on Android
* Only has an effect if `enableNdk` is `true`.
*
* @platform android
*/
enableNdkScopeSync?: boolean;
/**
* When enabled, all the threads are automatically attached to all logged events on Android
*
* @platform android
*/
attachThreads?: boolean;
/**
* When enabled, certain personally identifiable information (PII) is added by active integrations.
*
* @default false
*/
sendDefaultPii?: boolean;
/**
* Callback that is called after the RN SDK on the JS Layer has made contact with the Native Layer.
*/
onReady?: (response: {
/** `true` if the native SDK has been initialized, `false` otherwise. */
didCallNativeInit: boolean;
}) => void;
/** Enable auto performance tracking by default. Renamed from `enableAutoPerformanceTracking` in v5. */
enableAutoPerformanceTracing?: boolean;
/**
* Enables Out of Memory Tracking for iOS and macCatalyst.
* See the following link for more information and possible restrictions:
* https://docs.sentry.io/platforms/apple/guides/ios/configuration/out-of-memory/
*
* Renamed from `enableOutOfMemoryTracking` in v5.
*
* @default true
* @platform ios
*/
enableWatchdogTerminationTracking?: boolean;
/**
* Set data to the inital scope
* @deprecated Use `Sentry.configureScope(...)`
*/
initialScope?: CaptureContext;
/**
* When enabled, Sentry will overwrite the global Promise instance to ensure that unhandled rejections are correctly tracked.
* If you run into issues with Promise polyfills such as `core-js`, make sure you polyfill after Sentry is initialized.
* Read more at https://docs.sentry.io/platforms/react-native/troubleshooting/#unhandled-promise-rejections
*
* When disabled, this option will not disable unhandled rejection tracking. Set `onunhandledrejection: false` on the `ReactNativeErrorHandlers` integration instead.
*
* @default true
*/
patchGlobalPromise?: boolean;
/**
* The max cache items for capping the number of envelopes.
*
* @default 30
*/
maxCacheItems?: number;
/**
* When enabled, the SDK tracks when the application stops responding for a specific amount of
* time defined by the `appHangTimeoutInterval` option.
*
* iOS only
*
* @default true
* @platform ios
*/
enableAppHangTracking?: boolean;
/**
* The minimum amount of time an app should be unresponsive to be classified as an App Hanging.
* The actual amount may be a little longer.
* Avoid using values lower than 100ms, which may cause a lot of app hangs events being transmitted.
* Value should be in seconds.
*
* iOS only
*
* @default 2
* @platform ios
*/
appHangTimeoutInterval?: number;
/**
* The max queue size for capping the number of envelopes waiting to be sent by Transport.
*/
maxQueueSize?: number;
/**
* When enabled and a user experiences an error, Sentry provides the ability to take a screenshot and include it as an attachment.
*
* @default false
*/
attachScreenshot?: boolean;
/**
* When enabled Sentry includes the current view hierarchy in the error attachments.
*
* @default false
*/
attachViewHierarchy?: boolean;
/**
* When enabled, Sentry will capture failed XHR/Fetch requests. This option also enabled HTTP Errors on iOS.
* [Sentry Android Gradle Plugin](https://docs.sentry.io/platforms/android/configuration/integrations/okhttp/)
* is needed to capture HTTP Errors on Android.
*
* @default false
*/
enableCaptureFailedRequests?: boolean;
/**
* If you use Spotlight by Sentry during development, use
* this option to forward captured Sentry events to Spotlight.
*
* Either set it to true, or provide a specific Spotlight Sidecar URL.
*
* More details: https://spotlightjs.com/
*
* IMPORTANT: Only set this option to `true` while developing, not in production!
*/
spotlight?: boolean | string;
/**
* Sets a callback which is executed before capturing screenshots. Only
* relevant if `attachScreenshot` is set to true. When false is returned
* from the function, no screenshot will be attached.
*/
beforeScreenshot?: (event: Event, hint: EventHint) => boolean;
/**
* Track the app start time by adding measurements to the first route transaction. If there is no routing instrumentation
* an app start transaction will be started.
*
* Requires performance monitoring to be enabled.
*
* @default true
*/
enableAppStartTracking?: boolean;
/**
* Track the slow and frozen frames in the application. Enabling this options will add
* slow and frozen frames measurements to all created root spans (transactions).
*
* @default true
*/
enableNativeFramesTracking?: boolean;
/**
* Track when and how long the JS event loop stalls for. Adds stalls as measurements to all transactions.
*
* @default true
*/
enableStallTracking?: boolean;
/**
* Trace User Interaction events like touch and gestures.
*
* @default false
*/
enableUserInteractionTracing?: boolean;
/**
* The sample rate for profiling
* 1.0 will profile all transactions and 0 will profile none.
*/
profilesSampleRate?: number;
/**
* The sample rate for session-long replays.
* 1.0 will record all sessions and 0 will record none.
*/
replaysSessionSampleRate?: number;
/**
* The sample rate for sessions that has had an error occur.
* This is independent of `sessionSampleRate`.
* 1.0 will record all sessions and 0 will record none.
*/
replaysOnErrorSampleRate?: number;
/**
* Controls how many milliseconds to wait before shutting down. The default is 2 seconds. Setting this too low can cause
* problems for sending events from command line applications. Setting it too
* high can cause the application to block for users with network connectivity
* problems.
*/
shutdownTimeout?: number;
/**
* Defines the quality of the session replay. The higher the quality, the more accurate the replay
* will be, but also more data to transfer and more CPU load.
*
* @default 'medium'
*/
replaysSessionQuality?: SentryReplayQuality;
/**
* Options which are in beta, or otherwise not guaranteed to be stable.
*/
_experiments?: SharedExperimentsSubset & {
[key: string]: unknown;
/**
* @deprecated Use `replaysSessionSampleRate` in the options root instead.
*
* This will be removed in the next major version.
*/
replaysSessionSampleRate?: number;
/**
* @deprecated Use `replaysOnErrorSampleRate` in the options root instead.
*
* This will be removed in the next major version.
*/
replaysOnErrorSampleRate?: number;
/**
* Experiment: A more reliable way to report unhandled C++ exceptions in iOS.
*
* This approach hooks into all instances of the `__cxa_throw` function, which provides a more comprehensive and consistent exception handling across an app’s runtime, regardless of the number of C++ modules or how they’re linked. It helps in obtaining accurate stack traces.
*
* - Note: The mechanism of hooking into `__cxa_throw` could cause issues with symbolication on iOS due to caching of symbol references.
*
* @default false
* @platform ios
*/
enableUnhandledCPPExceptionsV2?: boolean;
};
/**
* This options changes the placement of the attached stacktrace of `captureMessage` in the event.
*
* @default false
* @deprecated This option will be removed in the next major version. Use `beforeSend` instead.
*/
useThreadsForMessageStack?: boolean;
/**
* If set to `true`, the SDK propagates the W3C `traceparent` header to any outgoing requests,
* in addition to the `sentry-trace` and `baggage` headers. Use the {@link CoreOptions.tracePropagationTargets}
* option to control to which outgoing requests the header will be attached.
*
* **Important:** If you set this option to `true`, make sure that you configured your servers'
* CORS settings to allow the `traceparent` header. Otherwise, requests might get blocked.
*
* @see https://www.w3.org/TR/trace-context/
*
* @default false
*/
propagateTraceparent?: boolean;
}
export type SentryReplayQuality = 'low' | 'medium' | 'high';
export interface ReactNativeTransportOptions extends BrowserTransportOptions {
/**
* @deprecated use `maxQueueSize` in the root of the SDK options.
*/
bufferSize?: number;
}
/**
* Configuration options for the Sentry ReactNative SDK.
* @see ReactNativeFrontend for more information.
*/
export interface ReactNativeOptions
extends Omit<Options<ReactNativeTransportOptions>, '_experiments'>,
BaseReactNativeOptions {}
export interface ReactNativeClientOptions
extends Omit<ClientOptions<ReactNativeTransportOptions>, 'tunnel' | '_experiments'>,
BaseReactNativeOptions {}
export interface ReactNativeWrapperOptions {
/** Props for the root React profiler */
profilerProps?: Omit<ProfilerProps, 'updateProps' | 'children' | 'name'>;
/** Props for the root touch event boundary */
touchEventBoundaryProps?: TouchEventBoundaryProps;
}
/**
* If the user has not explicitly set `enableNativeNagger`
* the function enables native nagging based on the current
* environment.
*/
export function shouldEnableNativeNagger(userOptions: unknown): boolean {
if (typeof userOptions === 'boolean') {
// User can override the default behavior
return userOptions;
}
if (Platform.OS === 'web' || Platform.OS === 'windows') {
// We don't want to nag on known platforms that don't support native
return false;
}
if (isExpoGo()) {
// If the app is running in Expo Go, we don't want to nag
return false;
}
return true;
}