diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f0ef6666f..7fc5b981ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ ## Unreleased +### API breaking Changes + +#### Changed APIs + +- Rename iOS and MacCatalyst platform specific options from `Cocoa` to `Native` ([#2940](https://github.com/getsentry/sentry-dotnet/pull/2940)) +- Rename iOS platform specific options `EnableCocoaSdkTracing` to `EnableTracing` ([#2940](https://github.com/getsentry/sentry-dotnet/pull/2940)) +- Rename Android platform specific options from `Android` to `Native` ([#2940](https://github.com/getsentry/sentry-dotnet/pull/2940)) +- Rename Android platform specific options `EnableAndroidSdkTracing` and `EnableAndroidSdkBeforeSend` to `EnableTracing` and `EnableBeforeSend` respectively ([#2940](https://github.com/getsentry/sentry-dotnet/pull/2940)) + ### Dependencies - Bump Cocoa SDK from v8.17.0 to v8.17.1 ([#2936](https://github.com/getsentry/sentry-dotnet/pull/2936)) diff --git a/samples/Sentry.Samples.Android/MainActivity.cs b/samples/Sentry.Samples.Android/MainActivity.cs index 727c5626be..f6a264944e 100644 --- a/samples/Sentry.Samples.Android/MainActivity.cs +++ b/samples/Sentry.Samples.Android/MainActivity.cs @@ -11,8 +11,8 @@ protected override void OnCreate(Bundle? savedInstanceState) { o.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537"; o.SendDefaultPii = true; // adds the user's IP address automatically - o.Android.LogCatIntegration = LogCatIntegrationType.Errors; // Get logcat logs for both handled and unhandled errors; default is unhandled only - o.Android.LogCatMaxLines = 1000; // Defaults to 1000 + o.Native.LogCatIntegration = LogCatIntegrationType.Errors; // Get logcat logs for both handled and unhandled errors; default is unhandled only + o.Native.LogCatMaxLines = 1000; // Defaults to 1000 }); // Here's an example of adding custom scope information. diff --git a/src/Sentry/BindableSentryOptions.cs b/src/Sentry/BindableSentryOptions.cs index 81329f50a5..366658c053 100644 --- a/src/Sentry/BindableSentryOptions.cs +++ b/src/Sentry/BindableSentryOptions.cs @@ -90,10 +90,8 @@ public void ApplyTo(SentryOptions options) options.AutoSessionTracking = AutoSessionTracking ?? options.AutoSessionTracking; options.UseAsyncFileIO = UseAsyncFileIO ?? options.UseAsyncFileIO; options.JsonPreserveReferences = JsonPreserveReferences ?? options.JsonPreserveReferences; -#if ANDROID - Android.ApplyTo(options.Android); -#elif __IOS__ - Cocoa.ApplyTo(options.Cocoa); +#if ANDROID || __IOS__ + Native.ApplyTo(options.Native); #endif } } diff --git a/src/Sentry/Platforms/Android/AndroidEventProcessor.cs b/src/Sentry/Platforms/Android/AndroidEventProcessor.cs index 3db9bf954f..cba15fd78e 100644 --- a/src/Sentry/Platforms/Android/AndroidEventProcessor.cs +++ b/src/Sentry/Platforms/Android/AndroidEventProcessor.cs @@ -9,17 +9,17 @@ internal class AndroidEventProcessor : ISentryEventProcessor, IDisposable private readonly JavaSdk.IEventProcessor? _androidProcessor; private readonly JavaSdk.Hint _hint = new(); - public AndroidEventProcessor(SentryAndroidOptions androidOptions) + public AndroidEventProcessor(SentryAndroidOptions nativeOptions) { // Locate the Android SDK's default event processor by its class // NOTE: This approach avoids hardcoding the class name (which could be obfuscated by proguard) - _androidProcessor = androidOptions.EventProcessors.OfType() + _androidProcessor = nativeOptions.EventProcessors.OfType() .Where(o => o.Class == JavaClass.FromType(typeof(DefaultAndroidEventProcessor))) .Cast() .FirstOrDefault(); // TODO: This would be cleaner, but doesn't compile. Figure out why. - // _androidProcessor = androidOptions.EventProcessors + // _androidProcessor = nativeOptions.EventProcessors // .OfType() // .FirstOrDefault(); } diff --git a/src/Sentry/Platforms/Android/BindableSentryOptions.cs b/src/Sentry/Platforms/Android/BindableSentryOptions.cs index 68720da5f0..86853656cc 100644 --- a/src/Sentry/Platforms/Android/BindableSentryOptions.cs +++ b/src/Sentry/Platforms/Android/BindableSentryOptions.cs @@ -5,12 +5,12 @@ namespace Sentry; internal partial class BindableSentryOptions { - public AndroidOptions Android { get; } = new AndroidOptions(); + public NativeOptions Native { get; } = new NativeOptions(); /// /// Provides additional options for the Android platform. /// - public class AndroidOptions + public class NativeOptions { public bool? AnrEnabled { get; set; } public bool? AnrReportInDebug { get; set; } @@ -33,12 +33,12 @@ public class AndroidOptions public bool? PrintUncaughtStackTrace { get; set; } public double? ProfilesSampleRate { get; set; } public TimeSpan? ReadTimeout { get; set; } - public bool? EnableAndroidSdkTracing { get; set; } - public bool? EnableAndroidSdkBeforeSend { get; set; } + public bool? EnableTracing { get; set; } + public bool? EnableBeforeSend { get; set; } public LogCatIntegrationType? LogCatIntegration { get; set; } public int? LogCatMaxLines { get; set; } - public void ApplyTo(SentryOptions.AndroidOptions options) + public void ApplyTo(SentryOptions.NativeOptions options) { options.AnrEnabled = AnrEnabled ?? options.AnrEnabled; options.AnrReportInDebug = AnrReportInDebug ?? options.AnrReportInDebug; @@ -61,8 +61,8 @@ public void ApplyTo(SentryOptions.AndroidOptions options) options.PrintUncaughtStackTrace = PrintUncaughtStackTrace ?? options.PrintUncaughtStackTrace; options.ProfilesSampleRate = ProfilesSampleRate ?? options.ProfilesSampleRate; options.ReadTimeout = ReadTimeout ?? options.ReadTimeout; - options.EnableAndroidSdkTracing = EnableAndroidSdkTracing ?? options.EnableAndroidSdkTracing; - options.EnableAndroidSdkBeforeSend = EnableAndroidSdkBeforeSend ?? options.EnableAndroidSdkBeforeSend; + options.EnableTracing = EnableTracing ?? options.EnableTracing; + options.EnableBeforeSend = EnableBeforeSend ?? options.EnableBeforeSend; options.LogCatIntegration = LogCatIntegration ?? options.LogCatIntegration; options.LogCatMaxLines = LogCatMaxLines ?? options.LogCatMaxLines; } diff --git a/src/Sentry/Platforms/Android/SentryOptions.cs b/src/Sentry/Platforms/Android/SentryOptions.cs index 7681063a63..9b8cf1c2a8 100644 --- a/src/Sentry/Platforms/Android/SentryOptions.cs +++ b/src/Sentry/Platforms/Android/SentryOptions.cs @@ -8,16 +8,16 @@ public partial class SentryOptions /// /// Exposes additional options for the Android platform. /// - public AndroidOptions Android { get; } + public NativeOptions Native { get; } /// /// Provides additional options for the Android platform. /// - public class AndroidOptions + public class NativeOptions { private readonly SentryOptions _options; - internal AndroidOptions(SentryOptions options) + internal NativeOptions(SentryOptions options) { _options = options; } @@ -255,7 +255,7 @@ public void AddInAppInclude(string prefix){ /// Gets or sets a value that indicates if tracing features are enabled on the embedded Android SDK. /// The default value is false (disabled). /// - public bool EnableAndroidSdkTracing { get; set; } = false; + public bool EnableTracing { get; set; } = false; /// /// Gets or sets a value that indicates if the BeforeSend callback set in @@ -266,6 +266,6 @@ public void AddInAppInclude(string prefix){ /// 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. /// - public bool EnableAndroidSdkBeforeSend { get; set; } = false; + public bool EnableBeforeSend { get; set; } = false; } } diff --git a/src/Sentry/Platforms/Android/SentrySdk.cs b/src/Sentry/Platforms/Android/SentrySdk.cs index a8d00baf9f..4abfcb067a 100644 --- a/src/Sentry/Platforms/Android/SentrySdk.cs +++ b/src/Sentry/Platforms/Android/SentrySdk.cs @@ -59,11 +59,11 @@ private static void InitSentryAndroidSdk(SentryOptions options) AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironment_UnhandledExceptionRaiser; // Define the configuration for the Android SDK - SentryAndroidOptions? androidOptions = null; + SentryAndroidOptions? nativeOptions = null; var configuration = new OptionsConfigurationCallback(o => { // Capture the android options reference on the outer scope - androidOptions = o; + nativeOptions = o; // TODO: Should we set the DistinctId to match the one used by GlobalSessionManager? //o.DistinctId = ? @@ -116,7 +116,7 @@ private static void InitSentryAndroidSdk(SentryOptions options) } // These options we have behind feature flags - if (options is { IsPerformanceMonitoringEnabled: true, Android.EnableAndroidSdkTracing: true }) + if (options is { IsPerformanceMonitoringEnabled: true, Native.EnableTracing: true }) { o.EnableTracing = (JavaBoolean?)options.EnableTracing; o.TracesSampleRate = (JavaDouble?)options.TracesSampleRate; @@ -127,39 +127,39 @@ private static void InitSentryAndroidSdk(SentryOptions options) } } - if (options.Android.EnableAndroidSdkBeforeSend && options.BeforeSendInternal is { } beforeSend) + if (options.Native.EnableBeforeSend && options.BeforeSendInternal is { } beforeSend) { o.BeforeSend = new BeforeSendCallback(beforeSend, options, o); } // These options are from SentryAndroidOptions - o.AttachScreenshot = options.Android.AttachScreenshot; - o.AnrEnabled = options.Android.AnrEnabled; - o.AnrReportInDebug = options.Android.AnrReportInDebug; - o.AnrTimeoutIntervalMillis = (long)options.Android.AnrTimeoutInterval.TotalMilliseconds; - o.EnableActivityLifecycleBreadcrumbs = options.Android.EnableActivityLifecycleBreadcrumbs; - o.EnableAutoActivityLifecycleTracing = options.Android.EnableAutoActivityLifecycleTracing; - o.EnableActivityLifecycleTracingAutoFinish = options.Android.EnableActivityLifecycleTracingAutoFinish; - o.EnableAppComponentBreadcrumbs = options.Android.EnableAppComponentBreadcrumbs; - o.EnableAppLifecycleBreadcrumbs = options.Android.EnableAppLifecycleBreadcrumbs; - o.EnableRootCheck = options.Android.EnableRootCheck; - o.EnableSystemEventBreadcrumbs = options.Android.EnableSystemEventBreadcrumbs; - o.EnableUserInteractionBreadcrumbs = options.Android.EnableUserInteractionBreadcrumbs; - o.EnableUserInteractionTracing = options.Android.EnableUserInteractionTracing; + o.AttachScreenshot = options.Native.AttachScreenshot; + o.AnrEnabled = options.Native.AnrEnabled; + o.AnrReportInDebug = options.Native.AnrReportInDebug; + o.AnrTimeoutIntervalMillis = (long)options.Native.AnrTimeoutInterval.TotalMilliseconds; + o.EnableActivityLifecycleBreadcrumbs = options.Native.EnableActivityLifecycleBreadcrumbs; + o.EnableAutoActivityLifecycleTracing = options.Native.EnableAutoActivityLifecycleTracing; + o.EnableActivityLifecycleTracingAutoFinish = options.Native.EnableActivityLifecycleTracingAutoFinish; + o.EnableAppComponentBreadcrumbs = options.Native.EnableAppComponentBreadcrumbs; + o.EnableAppLifecycleBreadcrumbs = options.Native.EnableAppLifecycleBreadcrumbs; + o.EnableRootCheck = options.Native.EnableRootCheck; + o.EnableSystemEventBreadcrumbs = options.Native.EnableSystemEventBreadcrumbs; + o.EnableUserInteractionBreadcrumbs = options.Native.EnableUserInteractionBreadcrumbs; + o.EnableUserInteractionTracing = options.Native.EnableUserInteractionTracing; // These options are in Java.SentryOptions but not ours - o.AttachThreads = options.Android.AttachThreads; - o.ConnectionTimeoutMillis = (int)options.Android.ConnectionTimeout.TotalMilliseconds; - o.EnableNdk = options.Android.EnableNdk; - o.EnableShutdownHook = options.Android.EnableShutdownHook; - o.EnableUncaughtExceptionHandler = options.Android.EnableUncaughtExceptionHandler; - o.ProfilesSampleRate = (JavaDouble?)options.Android.ProfilesSampleRate; - o.PrintUncaughtStackTrace = options.Android.PrintUncaughtStackTrace; - o.ReadTimeoutMillis = (int)options.Android.ReadTimeout.TotalMilliseconds; + o.AttachThreads = options.Native.AttachThreads; + o.ConnectionTimeoutMillis = (int)options.Native.ConnectionTimeout.TotalMilliseconds; + o.EnableNdk = options.Native.EnableNdk; + o.EnableShutdownHook = options.Native.EnableShutdownHook; + o.EnableUncaughtExceptionHandler = options.Native.EnableUncaughtExceptionHandler; + o.ProfilesSampleRate = (JavaDouble?)options.Native.ProfilesSampleRate; + o.PrintUncaughtStackTrace = options.Native.PrintUncaughtStackTrace; + o.ReadTimeoutMillis = (int)options.Native.ReadTimeout.TotalMilliseconds; // In-App Excludes and Includes to be passed to the Android SDK - options.Android.InAppExcludes?.ForEach(o.AddInAppExclude); - options.Android.InAppIncludes?.ForEach(o.AddInAppInclude); + options.Native.InAppExcludes?.ForEach(o.AddInAppExclude); + options.Native.InAppIncludes?.ForEach(o.AddInAppInclude); // These options are intentionally set and not exposed for modification o.EnableExternalConfiguration = false; @@ -187,10 +187,10 @@ private static void InitSentryAndroidSdk(SentryOptions options) } // Set options for the managed SDK that depend on the Android SDK. (The user will not be able to modify these.) - options.AddEventProcessor(new AndroidEventProcessor(androidOptions!)); - if (options.Android.LogCatIntegration != LogCatIntegrationType.None) + options.AddEventProcessor(new AndroidEventProcessor(nativeOptions!)); + if (options.Native.LogCatIntegration != LogCatIntegrationType.None) { - options.AddEventProcessor(new LogCatAttachmentEventProcessor(options.DiagnosticLogger, options.Android.LogCatIntegration, options.Android.LogCatMaxLines)); + options.AddEventProcessor(new LogCatAttachmentEventProcessor(options.DiagnosticLogger, options.Native.LogCatIntegration, options.Native.LogCatMaxLines)); } options.CrashedLastRun = () => JavaSdk.Sentry.IsCrashedLastRun()?.BooleanValue() is true; options.EnableScopeSync = true; diff --git a/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs b/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs index 961dae946c..5697ccf8cb 100644 --- a/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs +++ b/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs @@ -3,12 +3,12 @@ namespace Sentry; internal partial class BindableSentryOptions { - public CocoaOptions Cocoa { get; } = new CocoaOptions(); + public NativeOptions Native { get; } = new NativeOptions(); /// /// Provides additional options for the Android platform. /// - public class CocoaOptions + public class NativeOptions { public bool? AttachScreenshot { get; set; } public TimeSpan? AppHangTimeoutInterval { get; set; } @@ -24,9 +24,9 @@ public class CocoaOptions public bool? EnableSwizzling { get; set; } public bool? EnableUIViewControllerTracing { get; set; } public bool? EnableUserInteractionTracing { get; set; } - public bool? EnableCocoaSdkTracing { get; set; } + public bool? EnableTracing { get; set; } - public void ApplyTo(SentryOptions.CocoaOptions options) + public void ApplyTo(SentryOptions.NativeOptions options) { options.AttachScreenshot = AttachScreenshot ?? options.AttachScreenshot; options.AppHangTimeoutInterval = AppHangTimeoutInterval ?? options.AppHangTimeoutInterval; @@ -42,7 +42,7 @@ public void ApplyTo(SentryOptions.CocoaOptions options) options.EnableSwizzling = EnableSwizzling ?? options.EnableSwizzling; options.EnableUIViewControllerTracing = EnableUIViewControllerTracing ?? options.EnableUIViewControllerTracing; options.EnableUserInteractionTracing = EnableUserInteractionTracing ?? options.EnableUserInteractionTracing; - options.EnableCocoaSdkTracing = EnableCocoaSdkTracing ?? options.EnableCocoaSdkTracing; + options.EnableTracing = EnableTracing ?? options.EnableTracing; } } } diff --git a/src/Sentry/Platforms/Cocoa/CocoaEventProcessor.cs b/src/Sentry/Platforms/Cocoa/CocoaEventProcessor.cs index 63f81446d4..372ababd35 100644 --- a/src/Sentry/Platforms/Cocoa/CocoaEventProcessor.cs +++ b/src/Sentry/Platforms/Cocoa/CocoaEventProcessor.cs @@ -5,13 +5,6 @@ namespace Sentry.Cocoa; internal class CocoaEventProcessor : ISentryEventProcessor, IDisposable { - private readonly SentryCocoaOptions _options; - - public CocoaEventProcessor(SentryCocoaOptions options) - { - _options = options; - } - public SentryEvent Process(SentryEvent @event) { // Get a temp event from the Cocoa SDK diff --git a/src/Sentry/Platforms/Cocoa/Extensions/SentryEventExtensions.cs b/src/Sentry/Platforms/Cocoa/Extensions/SentryEventExtensions.cs index 122de9c31b..ebb7c735ba 100644 --- a/src/Sentry/Platforms/Cocoa/Extensions/SentryEventExtensions.cs +++ b/src/Sentry/Platforms/Cocoa/Extensions/SentryEventExtensions.cs @@ -18,7 +18,7 @@ // * updating the objects on either side. // */ // -// public static SentryEvent ToSentryEvent(this CocoaSdk.SentryEvent sentryEvent, SentryCocoaOptions cocoaOptions) +// public static SentryEvent ToSentryEvent(this CocoaSdk.SentryEvent sentryEvent, SentryCocoaSdkOptions nativeOptions) // { // using var stream = sentryEvent.ToJsonStream()!; // //stream.Seek(0, SeekOrigin.Begin); ?? @@ -28,7 +28,7 @@ // return SentryEvent.FromJson(json.RootElement, exception); // } // -// public static CocoaSdk.SentryEvent ToCocoaSentryEvent(this SentryEvent sentryEvent, SentryOptions options, SentryCocoaOptions cocoaOptions) +// public static CocoaSdk.SentryEvent ToCocoaSentryEvent(this SentryEvent sentryEvent, SentryOptions options, SentryCocoaSdkOptions nativeOptions) // { // var envelope = Envelope.FromEvent(sentryEvent); // diff --git a/src/Sentry/Platforms/Cocoa/Sentry.Cocoa.props b/src/Sentry/Platforms/Cocoa/Sentry.Cocoa.props index 614e9739b3..aeef195bfa 100644 --- a/src/Sentry/Platforms/Cocoa/Sentry.Cocoa.props +++ b/src/Sentry/Platforms/Cocoa/Sentry.Cocoa.props @@ -6,7 +6,7 @@ - + diff --git a/src/Sentry/Platforms/Cocoa/SentryOptions.cs b/src/Sentry/Platforms/Cocoa/SentryOptions.cs index 91ad040363..c14213087a 100644 --- a/src/Sentry/Platforms/Cocoa/SentryOptions.cs +++ b/src/Sentry/Platforms/Cocoa/SentryOptions.cs @@ -9,16 +9,16 @@ public partial class SentryOptions /// Exposes additional options for iOS and MacCatalyst. /// // ReSharper disable once InconsistentNaming - public CocoaOptions Cocoa { get; } + public NativeOptions Native { get; } /// /// Provides additional options for iOS and MacCatalyst. /// - public class CocoaOptions + public class NativeOptions { private readonly SentryOptions _options; - internal CocoaOptions(SentryOptions options) + internal NativeOptions(SentryOptions options) { _options = options; } @@ -182,7 +182,7 @@ internal CocoaOptions(SentryOptions options) /// Gets or sets a value that indicates if tracing features are enabled on the embedded Cocoa SDK. /// The default value is false (disabled). /// - public bool EnableCocoaSdkTracing { get; set; } = false; + public bool EnableTracing { get; set; } = false; internal List? InAppExcludes { get; private set; } internal List? InAppIncludes { get; private set; } diff --git a/src/Sentry/Platforms/Cocoa/SentrySdk.cs b/src/Sentry/Platforms/Cocoa/SentrySdk.cs index 3ea1ea85f2..56c4b1b0b6 100644 --- a/src/Sentry/Platforms/Cocoa/SentrySdk.cs +++ b/src/Sentry/Platforms/Cocoa/SentrySdk.cs @@ -19,34 +19,34 @@ private static void InitSentryCocoaSdk(SentryOptions options) options.Distribution ??= GetDefaultDistributionString(); // Set options for the Cocoa SDK - var cocoaOptions = new SentryCocoaOptions(); + var nativeOptions = new SentryCocoaSdkOptions(); // These options are copied over from our SentryOptions - cocoaOptions.AttachStacktrace = options.AttachStacktrace; - cocoaOptions.Debug = options.Debug; - cocoaOptions.DiagnosticLevel = options.DiagnosticLevel.ToCocoaSentryLevel(); - cocoaOptions.Dsn = options.Dsn; - cocoaOptions.EnableAutoSessionTracking = options.AutoSessionTracking; - cocoaOptions.EnableCaptureFailedRequests = options.CaptureFailedRequests; - cocoaOptions.FailedRequestStatusCodes = GetFailedRequestStatusCodes(options.FailedRequestStatusCodes); - cocoaOptions.MaxAttachmentSize = (nuint) options.MaxAttachmentSize; - cocoaOptions.MaxBreadcrumbs = (nuint) options.MaxBreadcrumbs; - cocoaOptions.MaxCacheItems = (nuint) options.MaxCacheItems; - cocoaOptions.ReleaseName = options.Release; - cocoaOptions.SampleRate = options.SampleRate; - cocoaOptions.SendClientReports = options.SendClientReports; - cocoaOptions.SendDefaultPii = options.SendDefaultPii; - cocoaOptions.SessionTrackingIntervalMillis = (nuint) options.AutoSessionTrackingInterval.TotalMilliseconds; + nativeOptions.AttachStacktrace = options.AttachStacktrace; + nativeOptions.Debug = options.Debug; + nativeOptions.DiagnosticLevel = options.DiagnosticLevel.ToCocoaSentryLevel(); + nativeOptions.Dsn = options.Dsn; + nativeOptions.EnableAutoSessionTracking = options.AutoSessionTracking; + nativeOptions.EnableCaptureFailedRequests = options.CaptureFailedRequests; + nativeOptions.FailedRequestStatusCodes = GetFailedRequestStatusCodes(options.FailedRequestStatusCodes); + nativeOptions.MaxAttachmentSize = (nuint) options.MaxAttachmentSize; + nativeOptions.MaxBreadcrumbs = (nuint) options.MaxBreadcrumbs; + nativeOptions.MaxCacheItems = (nuint) options.MaxCacheItems; + nativeOptions.ReleaseName = options.Release; + nativeOptions.SampleRate = options.SampleRate; + nativeOptions.SendClientReports = options.SendClientReports; + nativeOptions.SendDefaultPii = options.SendDefaultPii; + nativeOptions.SessionTrackingIntervalMillis = (nuint) options.AutoSessionTrackingInterval.TotalMilliseconds; if (options.Environment is { } environment) { - cocoaOptions.Environment = environment; + nativeOptions.Environment = environment; } // These options are not available in the Sentry Cocoa SDK - // cocoaOptions.? = options.InitCacheFlushTimeout; - // cocoaOptions.? = options.MaxQueueItems; - // cocoaOptions.? = options.ShutdownTimeout; + // nativeOptions.? = options.InitCacheFlushTimeout; + // nativeOptions.? = options.MaxQueueItems; + // nativeOptions.? = options.ShutdownTimeout; // NOTE: options.CacheDirectoryPath - No option for this in Sentry Cocoa, but caching is still enabled // https://github.com/getsentry/sentry-cocoa/issues/1051 @@ -56,7 +56,7 @@ private static void InitSentryCocoaSdk(SentryOptions options) if (options.BeforeBreadcrumbInternal is { } beforeBreadcrumb) { - cocoaOptions.BeforeBreadcrumb = b => + nativeOptions.BeforeBreadcrumb = b => { // Note: The Cocoa SDK doesn't yet support hints. // See https://github.com/getsentry/sentry-cocoa/issues/2325 @@ -71,18 +71,18 @@ private static void InitSentryCocoaSdk(SentryOptions options) } // These options we have behind feature flags - if (options is {IsPerformanceMonitoringEnabled: true, Cocoa.EnableCocoaSdkTracing: true}) + if (options is {IsPerformanceMonitoringEnabled: true, Native.EnableTracing: true}) { if (options.EnableTracing != null) { - cocoaOptions.EnableTracing = options.EnableTracing.Value; + nativeOptions.EnableTracing = options.EnableTracing.Value; } - cocoaOptions.TracesSampleRate = options.TracesSampleRate; + nativeOptions.TracesSampleRate = options.TracesSampleRate; if (options.TracesSampler is { } tracesSampler) { - cocoaOptions.TracesSampler = cocoaContext => + nativeOptions.TracesSampler = cocoaContext => { var context = cocoaContext.ToTransactionSamplingContext(); var result = tracesSampler(context); @@ -96,12 +96,12 @@ private static void InitSentryCocoaSdk(SentryOptions options) // TODO: Finish SentryEventExtensions to enable these - // if (options.Cocoa.EnableCocoaSdkBeforeSend && options.BeforeSend is { } beforeSend) + // if (options.Native.EnableCocoaSdkBeforeSend && options.BeforeSend is { } beforeSend) // { - // cocoaOptions.BeforeSend = evt => + // nativeOptions.BeforeSend = evt => // { - // var sentryEvent = evt.ToSentryEvent(cocoaOptions); - // var result = beforeSend(sentryEvent)?.ToCocoaSentryEvent(options, cocoaOptions); + // var sentryEvent = evt.ToSentryEvent(nativeOptions); + // var result = beforeSend(sentryEvent)?.ToCocoaSentryEvent(options, nativeOptions); // // // Note: Nullable result is allowed but delegate is generated incorrectly // // See https://github.com/xamarin/xamarin-macios/issues/15299#issuecomment-1201863294 @@ -109,46 +109,46 @@ private static void InitSentryCocoaSdk(SentryOptions options) // }; // } - // if (options.Cocoa.OnCrashedLastRun is { } onCrashedLastRun) + // if (options.Native.OnCrashedLastRun is { } onCrashedLastRun) // { - // cocoaOptions.OnCrashedLastRun = evt => + // nativeOptions.OnCrashedLastRun = evt => // { - // var sentryEvent = evt.ToSentryEvent(cocoaOptions); + // var sentryEvent = evt.ToSentryEvent(nativeOptions); // onCrashedLastRun(sentryEvent); // }; // } // These options are from Cocoa's SentryOptions - cocoaOptions.AttachScreenshot = options.Cocoa.AttachScreenshot; - cocoaOptions.AppHangTimeoutInterval = options.Cocoa.AppHangTimeoutInterval.TotalSeconds; - cocoaOptions.IdleTimeout = options.Cocoa.IdleTimeout.TotalSeconds; - cocoaOptions.Dist = options.Distribution; - cocoaOptions.EnableAppHangTracking = options.Cocoa.EnableAppHangTracking; - cocoaOptions.EnableAutoBreadcrumbTracking = options.Cocoa.EnableAutoBreadcrumbTracking; - cocoaOptions.EnableAutoPerformanceTracing = options.Cocoa.EnableAutoPerformanceTracing; - cocoaOptions.EnableCoreDataTracing = options.Cocoa.EnableCoreDataTracing; - cocoaOptions.EnableFileIOTracing = options.Cocoa.EnableFileIOTracing; - cocoaOptions.EnableNetworkBreadcrumbs = options.Cocoa.EnableNetworkBreadcrumbs; - cocoaOptions.EnableNetworkTracking = options.Cocoa.EnableNetworkTracking; - cocoaOptions.EnableWatchdogTerminationTracking = options.Cocoa.EnableWatchdogTerminationTracking; - cocoaOptions.EnableSwizzling = options.Cocoa.EnableSwizzling; - cocoaOptions.EnableUIViewControllerTracing = options.Cocoa.EnableUIViewControllerTracing; - cocoaOptions.EnableUserInteractionTracing = options.Cocoa.EnableUserInteractionTracing; - cocoaOptions.UrlSessionDelegate = options.Cocoa.UrlSessionDelegate; + nativeOptions.AttachScreenshot = options.Native.AttachScreenshot; + nativeOptions.AppHangTimeoutInterval = options.Native.AppHangTimeoutInterval.TotalSeconds; + nativeOptions.IdleTimeout = options.Native.IdleTimeout.TotalSeconds; + nativeOptions.Dist = options.Distribution; + nativeOptions.EnableAppHangTracking = options.Native.EnableAppHangTracking; + nativeOptions.EnableAutoBreadcrumbTracking = options.Native.EnableAutoBreadcrumbTracking; + nativeOptions.EnableAutoPerformanceTracing = options.Native.EnableAutoPerformanceTracing; + nativeOptions.EnableCoreDataTracing = options.Native.EnableCoreDataTracing; + nativeOptions.EnableFileIOTracing = options.Native.EnableFileIOTracing; + nativeOptions.EnableNetworkBreadcrumbs = options.Native.EnableNetworkBreadcrumbs; + nativeOptions.EnableNetworkTracking = options.Native.EnableNetworkTracking; + nativeOptions.EnableWatchdogTerminationTracking = options.Native.EnableWatchdogTerminationTracking; + nativeOptions.EnableSwizzling = options.Native.EnableSwizzling; + nativeOptions.EnableUIViewControllerTracing = options.Native.EnableUIViewControllerTracing; + nativeOptions.EnableUserInteractionTracing = options.Native.EnableUserInteractionTracing; + nativeOptions.UrlSessionDelegate = options.Native.UrlSessionDelegate; // StitchAsyncCode removed from Cocoa SDK in 8.6.0 with https://github.com/getsentry/sentry-cocoa/pull/2973 - // cocoaOptions.StitchAsyncCode = options.Cocoa.StitchAsyncCode; + // nativeOptions.StitchAsyncCode = options.Native.StitchAsyncCode; // In-App Excludes and Includes to be passed to the Cocoa SDK - options.Cocoa.InAppExcludes?.ForEach(x => cocoaOptions.AddInAppExclude(x)); - options.Cocoa.InAppIncludes?.ForEach(x => cocoaOptions.AddInAppInclude(x)); + options.Native.InAppExcludes?.ForEach(x => nativeOptions.AddInAppExclude(x)); + options.Native.InAppIncludes?.ForEach(x => nativeOptions.AddInAppInclude(x)); // These options are intentionally not expose or modified - // cocoaOptions.Enabled - // cocoaOptions.SdkInfo - // cocoaOptions.Integrations - // cocoaOptions.DefaultIntegrations - // cocoaOptions.EnableProfiling (deprecated) + // nativeOptions.Enabled + // nativeOptions.SdkInfo + // nativeOptions.Integrations + // nativeOptions.DefaultIntegrations + // nativeOptions.EnableProfiling (deprecated) // When we have an unhandled managed exception, we send that to Sentry twice - once managed and once native. // The managed exception is what a .NET developer would expect, and it is sent by the Sentry.NET SDK @@ -157,7 +157,7 @@ private static void InitSentryCocoaSdk(SentryOptions options) // Thankfully, we can see Xamarin's unhandled exception handler on the stack trace, so we can filter them out. // Here is the function that calls abort(), which we will use as a filter: // https://github.com/xamarin/xamarin-macios/blob/c55fbdfef95028ba03d0f7a35aebca03bd76f852/runtime/runtime.m#L1114-L1122 - cocoaOptions.BeforeSend = evt => + nativeOptions.BeforeSend = evt => { // There should only be one exception on the event in this case if (evt.Exceptions?.Length == 1) @@ -180,10 +180,10 @@ private static void InitSentryCocoaSdk(SentryOptions options) SentryCocoaHybridSdk.SetSdkName("sentry.cocoa.dotnet"); // Now initialize the Cocoa SDK - SentryCocoaSdk.StartWithOptions(cocoaOptions); + SentryCocoaSdk.StartWithOptions(nativeOptions); // Set options for the managed SDK that depend on the Cocoa SDK. (The user will not be able to modify these.) - options.AddEventProcessor(new CocoaEventProcessor(cocoaOptions)); + options.AddEventProcessor(new CocoaEventProcessor()); options.CrashedLastRun = () => SentryCocoaSdk.CrashedLastRun; options.EnableScopeSync = true; options.ScopeObserver = new CocoaScopeObserver(options); diff --git a/src/Sentry/SentryOptions.cs b/src/Sentry/SentryOptions.cs index 9a8aedb66a..4419343b00 100644 --- a/src/Sentry/SentryOptions.cs +++ b/src/Sentry/SentryOptions.cs @@ -1133,13 +1133,13 @@ public SentryOptions() ; #if ANDROID - Android = new AndroidOptions(this); + Native = new NativeOptions(this); var reader = new Lazy(() => AndroidHelpers.GetAndroidAssemblyReader(DiagnosticLogger)); AssemblyReader = name => reader.Value?.TryReadAssembly(name); #elif __IOS__ - Cocoa = new CocoaOptions(this); + Native = new NativeOptions(this); #endif InAppExclude = new() { diff --git a/test/Sentry.Testing/BindableTests.cs b/test/Sentry.Testing/BindableTests.cs index 6b3ebae996..5a6c7e517c 100644 --- a/test/Sentry.Testing/BindableTests.cs +++ b/test/Sentry.Testing/BindableTests.cs @@ -31,10 +31,8 @@ private static IEnumerable GetBindableProperties(IEnumerable +public class BindableSentryOptionsTests : BindableTests { [Fact] public void BindableProperties_MatchOptionsProperties() { - var actual = GetPropertyNames(); + var actual = GetPropertyNames(); AssertContainsAllOptionsProperties(actual); } @@ -16,8 +16,8 @@ public void BindableProperties_MatchOptionsProperties() public void ApplyTo_SetsOptionsFromConfig() { // Arrange - var actual = new SentryOptions.AndroidOptions(new SentryOptions()); - var bindable = new BindableSentryOptions.AndroidOptions(); + var actual = new SentryOptions.NativeOptions(new SentryOptions()); + var bindable = new BindableSentryOptions.NativeOptions(); // Act Fixture.Config.Bind(bindable); diff --git a/test/Sentry.Tests/Platforms/iOS/BindableSentryOptionsTests.cs b/test/Sentry.Tests/Platforms/iOS/BindableSentryOptionsTests.cs index c8660a92a7..bd03d2cf8c 100644 --- a/test/Sentry.Tests/Platforms/iOS/BindableSentryOptionsTests.cs +++ b/test/Sentry.Tests/Platforms/iOS/BindableSentryOptionsTests.cs @@ -3,17 +3,17 @@ namespace Sentry.Tests.Platforms.Cocoa; -public class BindableSentryOptionsTests : BindableTests +public class BindableSentryOptionsTests : BindableTests { public BindableSentryOptionsTests() - : base(nameof(SentryOptions.CocoaOptions.UrlSessionDelegate)) + : base(nameof(SentryOptions.NativeOptions.UrlSessionDelegate)) { } [Fact] public void BindableProperties_MatchOptionsProperties() { - var actual = GetPropertyNames(); + var actual = GetPropertyNames(); AssertContainsAllOptionsProperties(actual); } @@ -21,8 +21,8 @@ public void BindableProperties_MatchOptionsProperties() public void ApplyTo_SetsOptionsFromConfig() { // Arrange - var actual = new SentryOptions.CocoaOptions(new SentryOptions()); - var bindable = new BindableSentryOptions.CocoaOptions(); + var actual = new SentryOptions.NativeOptions(new SentryOptions()); + var bindable = new BindableSentryOptions.NativeOptions(); // Act Fixture.Config.Bind(bindable);