Skip to content

Commit a2fa21f

Browse files
authored
refactor: rename native options (#2940)
1 parent 351adea commit a2fa21f

17 files changed

+142
-144
lines changed

Diff for: CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
## Unreleased
44

5+
### API breaking Changes
6+
7+
#### Changed APIs
8+
9+
- Rename iOS and MacCatalyst platform specific options from `Cocoa` to `Native` ([#2940](https://github.com/getsentry/sentry-dotnet/pull/2940))
10+
- Rename iOS platform specific options `EnableCocoaSdkTracing` to `EnableTracing` ([#2940](https://github.com/getsentry/sentry-dotnet/pull/2940))
11+
- Rename Android platform specific options from `Android` to `Native` ([#2940](https://github.com/getsentry/sentry-dotnet/pull/2940))
12+
- Rename Android platform specific options `EnableAndroidSdkTracing` and `EnableAndroidSdkBeforeSend` to `EnableTracing` and `EnableBeforeSend` respectively ([#2940](https://github.com/getsentry/sentry-dotnet/pull/2940))
13+
514
### Dependencies
615

716
- Bump Cocoa SDK from v8.17.0 to v8.17.1 ([#2936](https://github.com/getsentry/sentry-dotnet/pull/2936))

Diff for: samples/Sentry.Samples.Android/MainActivity.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ protected override void OnCreate(Bundle? savedInstanceState)
1111
{
1212
o.Dsn = "https://[email protected]/5428537";
1313
o.SendDefaultPii = true; // adds the user's IP address automatically
14-
o.Android.LogCatIntegration = LogCatIntegrationType.Errors; // Get logcat logs for both handled and unhandled errors; default is unhandled only
15-
o.Android.LogCatMaxLines = 1000; // Defaults to 1000
14+
o.Native.LogCatIntegration = LogCatIntegrationType.Errors; // Get logcat logs for both handled and unhandled errors; default is unhandled only
15+
o.Native.LogCatMaxLines = 1000; // Defaults to 1000
1616
});
1717

1818
// Here's an example of adding custom scope information.

Diff for: src/Sentry/BindableSentryOptions.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,8 @@ public void ApplyTo(SentryOptions options)
9090
options.AutoSessionTracking = AutoSessionTracking ?? options.AutoSessionTracking;
9191
options.UseAsyncFileIO = UseAsyncFileIO ?? options.UseAsyncFileIO;
9292
options.JsonPreserveReferences = JsonPreserveReferences ?? options.JsonPreserveReferences;
93-
#if ANDROID
94-
Android.ApplyTo(options.Android);
95-
#elif __IOS__
96-
Cocoa.ApplyTo(options.Cocoa);
93+
#if ANDROID || __IOS__
94+
Native.ApplyTo(options.Native);
9795
#endif
9896
}
9997
}

Diff for: src/Sentry/Platforms/Android/AndroidEventProcessor.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ internal class AndroidEventProcessor : ISentryEventProcessor, IDisposable
99
private readonly JavaSdk.IEventProcessor? _androidProcessor;
1010
private readonly JavaSdk.Hint _hint = new();
1111

12-
public AndroidEventProcessor(SentryAndroidOptions androidOptions)
12+
public AndroidEventProcessor(SentryAndroidOptions nativeOptions)
1313
{
1414
// Locate the Android SDK's default event processor by its class
1515
// NOTE: This approach avoids hardcoding the class name (which could be obfuscated by proguard)
16-
_androidProcessor = androidOptions.EventProcessors.OfType<JavaObject>()
16+
_androidProcessor = nativeOptions.EventProcessors.OfType<JavaObject>()
1717
.Where(o => o.Class == JavaClass.FromType(typeof(DefaultAndroidEventProcessor)))
1818
.Cast<JavaSdk.IEventProcessor>()
1919
.FirstOrDefault();
2020

2121
// TODO: This would be cleaner, but doesn't compile. Figure out why.
22-
// _androidProcessor = androidOptions.EventProcessors
22+
// _androidProcessor = nativeOptions.EventProcessors
2323
// .OfType<DefaultAndroidEventProcessor>()
2424
// .FirstOrDefault();
2525
}

Diff for: src/Sentry/Platforms/Android/BindableSentryOptions.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ namespace Sentry;
55

66
internal partial class BindableSentryOptions
77
{
8-
public AndroidOptions Android { get; } = new AndroidOptions();
8+
public NativeOptions Native { get; } = new NativeOptions();
99

1010
/// <summary>
1111
/// Provides additional options for the Android platform.
1212
/// </summary>
13-
public class AndroidOptions
13+
public class NativeOptions
1414
{
1515
public bool? AnrEnabled { get; set; }
1616
public bool? AnrReportInDebug { get; set; }
@@ -33,12 +33,12 @@ public class AndroidOptions
3333
public bool? PrintUncaughtStackTrace { get; set; }
3434
public double? ProfilesSampleRate { get; set; }
3535
public TimeSpan? ReadTimeout { get; set; }
36-
public bool? EnableAndroidSdkTracing { get; set; }
37-
public bool? EnableAndroidSdkBeforeSend { get; set; }
36+
public bool? EnableTracing { get; set; }
37+
public bool? EnableBeforeSend { get; set; }
3838
public LogCatIntegrationType? LogCatIntegration { get; set; }
3939
public int? LogCatMaxLines { get; set; }
4040

41-
public void ApplyTo(SentryOptions.AndroidOptions options)
41+
public void ApplyTo(SentryOptions.NativeOptions options)
4242
{
4343
options.AnrEnabled = AnrEnabled ?? options.AnrEnabled;
4444
options.AnrReportInDebug = AnrReportInDebug ?? options.AnrReportInDebug;
@@ -61,8 +61,8 @@ public void ApplyTo(SentryOptions.AndroidOptions options)
6161
options.PrintUncaughtStackTrace = PrintUncaughtStackTrace ?? options.PrintUncaughtStackTrace;
6262
options.ProfilesSampleRate = ProfilesSampleRate ?? options.ProfilesSampleRate;
6363
options.ReadTimeout = ReadTimeout ?? options.ReadTimeout;
64-
options.EnableAndroidSdkTracing = EnableAndroidSdkTracing ?? options.EnableAndroidSdkTracing;
65-
options.EnableAndroidSdkBeforeSend = EnableAndroidSdkBeforeSend ?? options.EnableAndroidSdkBeforeSend;
64+
options.EnableTracing = EnableTracing ?? options.EnableTracing;
65+
options.EnableBeforeSend = EnableBeforeSend ?? options.EnableBeforeSend;
6666
options.LogCatIntegration = LogCatIntegration ?? options.LogCatIntegration;
6767
options.LogCatMaxLines = LogCatMaxLines ?? options.LogCatMaxLines;
6868
}

Diff for: src/Sentry/Platforms/Android/SentryOptions.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ public partial class SentryOptions
88
/// <summary>
99
/// Exposes additional options for the Android platform.
1010
/// </summary>
11-
public AndroidOptions Android { get; }
11+
public NativeOptions Native { get; }
1212

1313
/// <summary>
1414
/// Provides additional options for the Android platform.
1515
/// </summary>
16-
public class AndroidOptions
16+
public class NativeOptions
1717
{
1818
private readonly SentryOptions _options;
1919

20-
internal AndroidOptions(SentryOptions options)
20+
internal NativeOptions(SentryOptions options)
2121
{
2222
_options = options;
2323
}
@@ -255,7 +255,7 @@ public void AddInAppInclude(string prefix){
255255
/// Gets or sets a value that indicates if tracing features are enabled on the embedded Android SDK.
256256
/// The default value is <c>false</c> (disabled).
257257
/// </summary>
258-
public bool EnableAndroidSdkTracing { get; set; } = false;
258+
public bool EnableTracing { get; set; } = false;
259259

260260
/// <summary>
261261
/// Gets or sets a value that indicates if the <c>BeforeSend</c> callback set in <see cref="o:SetBeforeSend"/>
@@ -266,6 +266,6 @@ public void AddInAppInclude(string prefix){
266266
/// implement all of the same features that may be present in the event graph. Some optional elements may
267267
/// be stripped away during the round-tripping between the two SDKs. Use with caution.
268268
/// </remarks>
269-
public bool EnableAndroidSdkBeforeSend { get; set; } = false;
269+
public bool EnableBeforeSend { get; set; } = false;
270270
}
271271
}

Diff for: src/Sentry/Platforms/Android/SentrySdk.cs

+30-30
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ private static void InitSentryAndroidSdk(SentryOptions options)
5959
AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironment_UnhandledExceptionRaiser;
6060

6161
// Define the configuration for the Android SDK
62-
SentryAndroidOptions? androidOptions = null;
62+
SentryAndroidOptions? nativeOptions = null;
6363
var configuration = new OptionsConfigurationCallback(o =>
6464
{
6565
// Capture the android options reference on the outer scope
66-
androidOptions = o;
66+
nativeOptions = o;
6767

6868
// TODO: Should we set the DistinctId to match the one used by GlobalSessionManager?
6969
//o.DistinctId = ?
@@ -116,7 +116,7 @@ private static void InitSentryAndroidSdk(SentryOptions options)
116116
}
117117

118118
// These options we have behind feature flags
119-
if (options is { IsPerformanceMonitoringEnabled: true, Android.EnableAndroidSdkTracing: true })
119+
if (options is { IsPerformanceMonitoringEnabled: true, Native.EnableTracing: true })
120120
{
121121
o.EnableTracing = (JavaBoolean?)options.EnableTracing;
122122
o.TracesSampleRate = (JavaDouble?)options.TracesSampleRate;
@@ -127,39 +127,39 @@ private static void InitSentryAndroidSdk(SentryOptions options)
127127
}
128128
}
129129

130-
if (options.Android.EnableAndroidSdkBeforeSend && options.BeforeSendInternal is { } beforeSend)
130+
if (options.Native.EnableBeforeSend && options.BeforeSendInternal is { } beforeSend)
131131
{
132132
o.BeforeSend = new BeforeSendCallback(beforeSend, options, o);
133133
}
134134

135135
// These options are from SentryAndroidOptions
136-
o.AttachScreenshot = options.Android.AttachScreenshot;
137-
o.AnrEnabled = options.Android.AnrEnabled;
138-
o.AnrReportInDebug = options.Android.AnrReportInDebug;
139-
o.AnrTimeoutIntervalMillis = (long)options.Android.AnrTimeoutInterval.TotalMilliseconds;
140-
o.EnableActivityLifecycleBreadcrumbs = options.Android.EnableActivityLifecycleBreadcrumbs;
141-
o.EnableAutoActivityLifecycleTracing = options.Android.EnableAutoActivityLifecycleTracing;
142-
o.EnableActivityLifecycleTracingAutoFinish = options.Android.EnableActivityLifecycleTracingAutoFinish;
143-
o.EnableAppComponentBreadcrumbs = options.Android.EnableAppComponentBreadcrumbs;
144-
o.EnableAppLifecycleBreadcrumbs = options.Android.EnableAppLifecycleBreadcrumbs;
145-
o.EnableRootCheck = options.Android.EnableRootCheck;
146-
o.EnableSystemEventBreadcrumbs = options.Android.EnableSystemEventBreadcrumbs;
147-
o.EnableUserInteractionBreadcrumbs = options.Android.EnableUserInteractionBreadcrumbs;
148-
o.EnableUserInteractionTracing = options.Android.EnableUserInteractionTracing;
136+
o.AttachScreenshot = options.Native.AttachScreenshot;
137+
o.AnrEnabled = options.Native.AnrEnabled;
138+
o.AnrReportInDebug = options.Native.AnrReportInDebug;
139+
o.AnrTimeoutIntervalMillis = (long)options.Native.AnrTimeoutInterval.TotalMilliseconds;
140+
o.EnableActivityLifecycleBreadcrumbs = options.Native.EnableActivityLifecycleBreadcrumbs;
141+
o.EnableAutoActivityLifecycleTracing = options.Native.EnableAutoActivityLifecycleTracing;
142+
o.EnableActivityLifecycleTracingAutoFinish = options.Native.EnableActivityLifecycleTracingAutoFinish;
143+
o.EnableAppComponentBreadcrumbs = options.Native.EnableAppComponentBreadcrumbs;
144+
o.EnableAppLifecycleBreadcrumbs = options.Native.EnableAppLifecycleBreadcrumbs;
145+
o.EnableRootCheck = options.Native.EnableRootCheck;
146+
o.EnableSystemEventBreadcrumbs = options.Native.EnableSystemEventBreadcrumbs;
147+
o.EnableUserInteractionBreadcrumbs = options.Native.EnableUserInteractionBreadcrumbs;
148+
o.EnableUserInteractionTracing = options.Native.EnableUserInteractionTracing;
149149

150150
// These options are in Java.SentryOptions but not ours
151-
o.AttachThreads = options.Android.AttachThreads;
152-
o.ConnectionTimeoutMillis = (int)options.Android.ConnectionTimeout.TotalMilliseconds;
153-
o.EnableNdk = options.Android.EnableNdk;
154-
o.EnableShutdownHook = options.Android.EnableShutdownHook;
155-
o.EnableUncaughtExceptionHandler = options.Android.EnableUncaughtExceptionHandler;
156-
o.ProfilesSampleRate = (JavaDouble?)options.Android.ProfilesSampleRate;
157-
o.PrintUncaughtStackTrace = options.Android.PrintUncaughtStackTrace;
158-
o.ReadTimeoutMillis = (int)options.Android.ReadTimeout.TotalMilliseconds;
151+
o.AttachThreads = options.Native.AttachThreads;
152+
o.ConnectionTimeoutMillis = (int)options.Native.ConnectionTimeout.TotalMilliseconds;
153+
o.EnableNdk = options.Native.EnableNdk;
154+
o.EnableShutdownHook = options.Native.EnableShutdownHook;
155+
o.EnableUncaughtExceptionHandler = options.Native.EnableUncaughtExceptionHandler;
156+
o.ProfilesSampleRate = (JavaDouble?)options.Native.ProfilesSampleRate;
157+
o.PrintUncaughtStackTrace = options.Native.PrintUncaughtStackTrace;
158+
o.ReadTimeoutMillis = (int)options.Native.ReadTimeout.TotalMilliseconds;
159159

160160
// In-App Excludes and Includes to be passed to the Android SDK
161-
options.Android.InAppExcludes?.ForEach(o.AddInAppExclude);
162-
options.Android.InAppIncludes?.ForEach(o.AddInAppInclude);
161+
options.Native.InAppExcludes?.ForEach(o.AddInAppExclude);
162+
options.Native.InAppIncludes?.ForEach(o.AddInAppInclude);
163163

164164
// These options are intentionally set and not exposed for modification
165165
o.EnableExternalConfiguration = false;
@@ -187,10 +187,10 @@ private static void InitSentryAndroidSdk(SentryOptions options)
187187
}
188188

189189
// Set options for the managed SDK that depend on the Android SDK. (The user will not be able to modify these.)
190-
options.AddEventProcessor(new AndroidEventProcessor(androidOptions!));
191-
if (options.Android.LogCatIntegration != LogCatIntegrationType.None)
190+
options.AddEventProcessor(new AndroidEventProcessor(nativeOptions!));
191+
if (options.Native.LogCatIntegration != LogCatIntegrationType.None)
192192
{
193-
options.AddEventProcessor(new LogCatAttachmentEventProcessor(options.DiagnosticLogger, options.Android.LogCatIntegration, options.Android.LogCatMaxLines));
193+
options.AddEventProcessor(new LogCatAttachmentEventProcessor(options.DiagnosticLogger, options.Native.LogCatIntegration, options.Native.LogCatMaxLines));
194194
}
195195
options.CrashedLastRun = () => JavaSdk.Sentry.IsCrashedLastRun()?.BooleanValue() is true;
196196
options.EnableScopeSync = true;

Diff for: src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ namespace Sentry;
33

44
internal partial class BindableSentryOptions
55
{
6-
public CocoaOptions Cocoa { get; } = new CocoaOptions();
6+
public NativeOptions Native { get; } = new NativeOptions();
77

88
/// <summary>
99
/// Provides additional options for the Android platform.
1010
/// </summary>
11-
public class CocoaOptions
11+
public class NativeOptions
1212
{
1313
public bool? AttachScreenshot { get; set; }
1414
public TimeSpan? AppHangTimeoutInterval { get; set; }
@@ -24,9 +24,9 @@ public class CocoaOptions
2424
public bool? EnableSwizzling { get; set; }
2525
public bool? EnableUIViewControllerTracing { get; set; }
2626
public bool? EnableUserInteractionTracing { get; set; }
27-
public bool? EnableCocoaSdkTracing { get; set; }
27+
public bool? EnableTracing { get; set; }
2828

29-
public void ApplyTo(SentryOptions.CocoaOptions options)
29+
public void ApplyTo(SentryOptions.NativeOptions options)
3030
{
3131
options.AttachScreenshot = AttachScreenshot ?? options.AttachScreenshot;
3232
options.AppHangTimeoutInterval = AppHangTimeoutInterval ?? options.AppHangTimeoutInterval;
@@ -42,7 +42,7 @@ public void ApplyTo(SentryOptions.CocoaOptions options)
4242
options.EnableSwizzling = EnableSwizzling ?? options.EnableSwizzling;
4343
options.EnableUIViewControllerTracing = EnableUIViewControllerTracing ?? options.EnableUIViewControllerTracing;
4444
options.EnableUserInteractionTracing = EnableUserInteractionTracing ?? options.EnableUserInteractionTracing;
45-
options.EnableCocoaSdkTracing = EnableCocoaSdkTracing ?? options.EnableCocoaSdkTracing;
45+
options.EnableTracing = EnableTracing ?? options.EnableTracing;
4646
}
4747
}
4848
}

Diff for: src/Sentry/Platforms/Cocoa/CocoaEventProcessor.cs

-7
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ namespace Sentry.Cocoa;
55

66
internal class CocoaEventProcessor : ISentryEventProcessor, IDisposable
77
{
8-
private readonly SentryCocoaOptions _options;
9-
10-
public CocoaEventProcessor(SentryCocoaOptions options)
11-
{
12-
_options = options;
13-
}
14-
158
public SentryEvent Process(SentryEvent @event)
169
{
1710
// Get a temp event from the Cocoa SDK

Diff for: src/Sentry/Platforms/Cocoa/Extensions/SentryEventExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// * updating the objects on either side.
1919
// */
2020
//
21-
// public static SentryEvent ToSentryEvent(this CocoaSdk.SentryEvent sentryEvent, SentryCocoaOptions cocoaOptions)
21+
// public static SentryEvent ToSentryEvent(this CocoaSdk.SentryEvent sentryEvent, SentryCocoaSdkOptions nativeOptions)
2222
// {
2323
// using var stream = sentryEvent.ToJsonStream()!;
2424
// //stream.Seek(0, SeekOrigin.Begin); ??
@@ -28,7 +28,7 @@
2828
// return SentryEvent.FromJson(json.RootElement, exception);
2929
// }
3030
//
31-
// public static CocoaSdk.SentryEvent ToCocoaSentryEvent(this SentryEvent sentryEvent, SentryOptions options, SentryCocoaOptions cocoaOptions)
31+
// public static CocoaSdk.SentryEvent ToCocoaSentryEvent(this SentryEvent sentryEvent, SentryOptions options, SentryCocoaSdkOptions nativeOptions)
3232
// {
3333
// var envelope = Envelope.FromEvent(sentryEvent);
3434
//

Diff for: src/Sentry/Platforms/Cocoa/Sentry.Cocoa.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<ItemGroup>
88
<Using Include="Foundation" />
9-
<Using Include="Sentry.CocoaSdk.SentryOptions" Alias="SentryCocoaOptions" />
9+
<Using Include="Sentry.CocoaSdk.SentryOptions" Alias="SentryCocoaSdkOptions" />
1010
<Using Include="Sentry.CocoaSdk.SentrySDK" Alias="SentryCocoaSdk" />
1111
<Using Include="Sentry.CocoaSdk.PrivateSentrySDKOnly" Alias="SentryCocoaHybridSdk" />
1212
</ItemGroup>

Diff for: src/Sentry/Platforms/Cocoa/SentryOptions.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ public partial class SentryOptions
99
/// Exposes additional options for iOS and MacCatalyst.
1010
/// </summary>
1111
// ReSharper disable once InconsistentNaming
12-
public CocoaOptions Cocoa { get; }
12+
public NativeOptions Native { get; }
1313

1414
/// <summary>
1515
/// Provides additional options for iOS and MacCatalyst.
1616
/// </summary>
17-
public class CocoaOptions
17+
public class NativeOptions
1818
{
1919
private readonly SentryOptions _options;
2020

21-
internal CocoaOptions(SentryOptions options)
21+
internal NativeOptions(SentryOptions options)
2222
{
2323
_options = options;
2424
}
@@ -182,7 +182,7 @@ internal CocoaOptions(SentryOptions options)
182182
/// Gets or sets a value that indicates if tracing features are enabled on the embedded Cocoa SDK.
183183
/// The default value is <c>false</c> (disabled).
184184
/// </summary>
185-
public bool EnableCocoaSdkTracing { get; set; } = false;
185+
public bool EnableTracing { get; set; } = false;
186186

187187
internal List<string>? InAppExcludes { get; private set; }
188188
internal List<string>? InAppIncludes { get; private set; }

0 commit comments

Comments
 (0)