-
-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathNativeOptions.cs
More file actions
335 lines (292 loc) · 15.2 KB
/
NativeOptions.cs
File metadata and controls
335 lines (292 loc) · 15.2 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
using Sentry.Android;
// ReSharper disable once CheckNamespace
namespace Sentry;
public partial class SentryOptions
{
/// <summary>
/// Exposes additional options for the Android platform.
/// </summary>
public NativeOptions Native { get; }
/// <summary>
/// Provides additional options for the Android platform.
/// </summary>
public class NativeOptions
{
private readonly SentryOptions _options;
internal NativeOptions(SentryOptions options)
{
_options = options;
}
// ---------- From SentryAndroidOptions.java ----------
/// <summary>
/// Gets or sets a value that indicates if ANR (Application Not Responding) is enabled.
/// The default value is <c>true</c> (enabled).
/// </summary>
/// <remarks>
/// See https://docs.sentry.io/platforms/android/configuration/app-not-respond/
/// </remarks>
public bool AnrEnabled { get; set; } = true;
/// <summary>
/// Gets or sets a value that indicates if ANR (Application Not Responding) is enabled on Debug mode.
/// The default value is <c>false</c> (disabled).
/// </summary>
/// <remarks>
/// See https://docs.sentry.io/platforms/android/configuration/app-not-respond/
/// </remarks>
public bool AnrReportInDebug { get; set; } = false;
/// <summary>
/// Gets or sets the ANR (Application Not Responding) timeout interval.
/// The default values is 5 seconds.
/// </summary>
/// <remarks>
/// See https://docs.sentry.io/platforms/android/configuration/app-not-respond/
/// </remarks>
public TimeSpan AnrTimeoutInterval { get; set; } = TimeSpan.FromSeconds(5);
// TODO: Make this option work for .NET managed code
/// <summary>
/// Gets or sets a value that indicates whether to attach a screenshot when an error occurs.
/// The default value is <c>false</c> (disabled).
/// </summary>
/// <remarks>
/// This feature is provided by the Sentry Android SDK and thus only works for Java-based errors.
/// See https://docs.sentry.io/platforms/android/enriching-events/screenshots/
/// </remarks>
public bool AttachScreenshot { get; set; } = false;
/// <summary>
/// Gets or sets a value that indicates if automatic breadcrumbs for <c>Activity</c> lifecycle events are
/// enabled. The default value is <c>true</c> (enabled).
/// </summary>
/// <remarks>
/// See https://docs.sentry.io/platforms/android/enriching-events/breadcrumbs/
/// </remarks>
public bool EnableActivityLifecycleBreadcrumbs { get; set; } = true;
/// <summary>
/// Gets or sets a value that indicates if automatic breadcrumbs for <c>App</c> components are enabled.
/// The default value is <c>true</c> (enabled).
/// </summary>
/// <remarks>
/// See https://docs.sentry.io/platforms/android/enriching-events/breadcrumbs/
/// </remarks>
public bool EnableAppComponentBreadcrumbs { get; set; } = true;
/// <summary>
/// Gets or sets a value that indicates if automatic breadcrumbs for <c>App</c> lifecycle events are enabled.
/// The default value is <c>true</c> (enabled).
/// </summary>
/// <remarks>
/// See https://docs.sentry.io/platforms/android/enriching-events/breadcrumbs/
/// </remarks>
public bool EnableAppLifecycleBreadcrumbs { get; set; } = true;
/// <summary>
/// Gets or sets a value that controls checking whether the device has been rooted. The check itself may cause app stores to flag
/// an application as harmful, in which case this property can be set <c>false</c> to disable the check.
/// The default value is <c>true</c> (enabled).
/// </summary>
public bool EnableRootCheck { get; set; } = true;
/// <summary>
/// Gets or sets a value that indicates if automatic breadcrumbs for network events are enabled.
/// The default value is <c>true</c> (enabled).
/// </summary>
/// <remarks>
/// See https://docs.sentry.io/platforms/android/enriching-events/breadcrumbs/
/// </remarks>
public bool EnableNetworkEventBreadcrumbs { get; set; } = true;
/// <summary>
/// Gets or sets a value that indicates if automatic breadcrumbs for system events are enabled.
/// The default value is <c>true</c> (enabled).
/// </summary>
/// <remarks>
/// See https://docs.sentry.io/platforms/android/enriching-events/breadcrumbs/
/// </remarks>
public bool EnableSystemEventBreadcrumbs { get; set; } = true;
/// <summary>
/// Gets or sets a value that indicates if automatic breadcrumbs for user interactions are enabled.
/// The default value is <c>true</c> (enabled).
/// </summary>
/// <remarks>
/// See https://docs.sentry.io/platforms/android/enriching-events/breadcrumbs/
/// </remarks>
public bool EnableUserInteractionBreadcrumbs { get; set; } = true;
/// <summary>
/// Gets or sets a value that indicates if automatic instrumentation for <c>Activity</c> lifecycle tracing
/// is enabled. The default value is <c>true</c> (enabled).
/// Enabling this option also requires setting <see cref="SentryOptions.TracesSampleRate"/> or
/// <see cref="SentryOptions.TracesSampler"/>. You can also control whether these transactions will
/// finish automatically with <see cref="EnableActivityLifecycleTracingAutoFinish"/>.
/// </summary>
/// <remarks>
/// See https://docs.sentry.io/platforms/android/performance/instrumentation/automatic-instrumentation/#androids-activity-instrumentation
/// </remarks>
public bool EnableAutoActivityLifecycleTracing { get; set; } = true;
/// <summary>
/// Gets or sets a value that indicates if automatic instrumentation for <c>Activity</c> lifecycle tracing
/// should finish automatically. Requires <see cref="EnableAutoActivityLifecycleTracing"/> set <c>true</c>.
/// The default value is <c>true</c> (enabled).
/// </summary>
/// <remarks>
/// See https://docs.sentry.io/platforms/android/performance/instrumentation/automatic-instrumentation/#androids-activity-instrumentation
/// </remarks>
public bool EnableActivityLifecycleTracingAutoFinish { get; set; } = true;
/// <summary>
/// Gets or sets a value that indicates if automatic instrumentation for user interaction tracing is enabled.
/// The default value is <c>false</c> (disabled).
/// </summary>
/// <remarks>
/// See https://docs.sentry.io/platforms/android/performance/instrumentation/automatic-instrumentation/#user-interaction-instrumentation
/// </remarks>
public bool EnableUserInteractionTracing { get; set; } = false;
/// <summary>
/// Gets or sets the strategy for how Sentry Native's signal handler interacts with the CLR/Mono
/// signal handler.
/// The default value is <see cref="Android.SignalHandlerStrategy.Default"/>.
/// </summary>
/// <remarks>
/// .NET runtimes 10.0.0–10.0.3 (.NET SDKs 10.0.100–10.0.301) are not compatible with
/// <see cref="Android.SignalHandlerStrategy.ChainAtStart"/>. Using it on affected
/// versions throws an <see cref="InvalidOperationException"/> during initialization.
/// The issue was resolved in .NET runtime 10.0.4 (.NET SDK 10.0.400). See
/// <see href="https://github.com/dotnet/runtime/pull/123346">dotnet/runtime#123346</see>.
/// </remarks>
public SignalHandlerStrategy SignalHandlerStrategy { get; set; } = SignalHandlerStrategy.Default;
// ---------- From SentryOptions.java ----------
/// <summary>
/// Gets or sets a value that indicates if all the threads are automatically attached to all logged events.
/// The default value is <c>false</c> (disabled).
/// </summary>
public bool AttachThreads { get; set; } = false;
/// <summary>
/// Gets or sets the connection timeout on the HTTP connection used by Java when sending data to Sentry.
/// The default value is 5 seconds.
/// </summary>
public TimeSpan ConnectionTimeout { get; set; } = TimeSpan.FromSeconds(5);
/// <summary>
/// Gets or sets a value that indicates if the NDK (Android Native Development Kit) is enabled.
/// The default value is <c>true</c> (enabled).
/// </summary>
/// <remarks>
/// See https://docs.sentry.io/platforms/android/using-ndk/#disable-ndk-integration
/// </remarks>
public bool EnableNdk { get; set; } = true;
/// <summary>
/// Gets or sets a value that indicates if the hook that flushes when the main Java thread shuts down
/// is enabled. The default value is <c>true</c> (enabled).
/// </summary>
public bool EnableShutdownHook { get; set; } = true;
/// <summary>
/// Gets or sets a value that indicates if the handler that attaches to Java's
/// <c>Thread.UncaughtExceptionHandler</c> is enabled. The default value is <c>true</c> (enabled).
/// </summary>s
public bool EnableUncaughtExceptionHandler { get; set; } = true;
/// <summary>
/// Gets or sets a value that indicates if uncaught Java errors will have their stack traces
/// printed to the standard error stream. The default value is <c>false</c> (disabled).
/// </summary>
public bool PrintUncaughtStackTrace { get; set; } = false;
/// <summary>
/// Gets or sets the profiling sample rate, between 0.0 and 1.0.
/// The default value is <c>null</c> (disabled).
/// </summary>
public double? ProfilesSampleRate { get; set; }
/// <summary>
/// Gets or sets the read timeout on the HTTP connection used by Java when sending data to Sentry.
/// The default value is 5 seconds.
/// </summary>
public TimeSpan ReadTimeout { get; set; } = TimeSpan.FromSeconds(5);
// ---------- Other ----------
internal List<string>? InAppExcludes { get; private set; }
internal List<string>? InAppIncludes { get; private set; }
/// <summary>
/// Add prefix to exclude from 'InApp' stacktrace list by the Android SDK.
/// Note that this uses Java package names, not .NET namespaces.
/// </summary>
/// <param name="prefix">The string used to filter the stacktrace to be excluded from InApp.</param>
/// <remarks>
/// See https://docs.sentry.io/platforms/java/configuration/options/#in-app-exclude
/// </remarks>
/// <example>
/// 'java.util.', 'org.apache.logging.log4j.'
/// </example>
public void AddInAppExclude(string prefix)
{
InAppExcludes ??= new List<string>();
InAppExcludes.Add(prefix);
}
/// <summary>
/// Add prefix to include as in 'InApp' stacktrace by the Android SDK.
/// Note that this uses Java package names, not .NET namespaces.
/// </summary>
/// <param name="prefix">The string used to filter the stacktrace to be included in InApp.</param>
/// <remarks>
/// See https://docs.sentry.io/platforms/java/configuration/options/#in-app-include
/// </remarks>
/// <example>
/// 'java.util.customcode.', 'io.sentry.samples.'
/// </example>
public void AddInAppInclude(string prefix)
{
InAppIncludes ??= new List<string>();
InAppIncludes.Add(prefix);
}
/// <summary>
/// Gets or sets a value that indicates if tracing features are enabled on the embedded Android SDK.
/// The default value is <c>false</c> (disabled).
/// </summary>
public bool EnableTracing { get; set; } = false;
/// <summary>
/// Gets or sets a value that indicates if the <c>BeforeSend</c> callback set in <see cref="o:SetBeforeSend"/>
/// will be invoked for events that originate from the embedded Android SDK. The default value is <c>false</c> (disabled).
/// </summary>
/// <remarks>
/// This is an experimental feature and is imperfect, as the .NET SDK and the embedded Android SDK don't
/// implement all of the same features that may be present in the event graph. Some optional elements may
/// be stripped away during the round-tripping between the two SDKs. Use with caution.
/// </remarks>
public bool EnableBeforeSend { get; set; } = false;
public class NativeExperimentalOptions
{
public NativeSentryReplayOptions SessionReplay { get; set; } = new();
}
public class NativeSentryReplayOptions
{
public double? OnErrorSampleRate { get; set; }
public double? SessionSampleRate { get; set; }
public bool MaskAllImages { get; set; } = true;
public bool MaskAllText { get; set; } = true;
internal HashSet<Type> MaskedControls { get; } = [];
internal HashSet<Type> UnmaskedControls { get; } = [];
internal bool IsSessionReplayEnabled => OnErrorSampleRate > 0.0 || SessionSampleRate > 0.0;
/// <summary>
/// Allows you to mask all controls of a particular type for session replay recordings.
/// </summary>
/// <typeparam name="T">The Type of control that should be masked</typeparam>
/// <remarks>
/// WARNING: In apps with complex user interfaces, consisting of hundreds of visual controls on a single
/// page, this option may cause performance issues. In such cases, consider applying SessionReplay.Mask
/// attributes to individual controls instead:
/// <code>sentry:SessionReplay.Mask="Mask"</code>
/// </remarks>
public void MaskControlsOfType<T>()
{
MaskedControls.Add(typeof(T));
}
/// <summary>
/// Allows you to unmask all controls of a particular type for session replay recordings.
/// </summary>
/// <typeparam name="T">The Type of control that should be unmasked</typeparam>
/// <remarks>
/// WARNING: In apps with complex user interfaces, consisting of hundreds of visual controls on a single
/// page, this option may cause performance issues. In such cases, consider applying SessionReplay.Mask
/// attributes to individual controls instead:
/// <code>sentry:SessionReplay.Mask="Unmask"</code>
/// </remarks>
public void UnmaskControlsOfType<T>()
{
UnmaskedControls.Add(typeof(T));
}
internal bool IsTypeMaskingUsed => MaskedControls.Count > 0 || UnmaskedControls.Count > 0;
}
/// <summary>
/// ExperimentalOptions
/// </summary>
public NativeExperimentalOptions ExperimentalOptions { get; set; } = new();
}
}