From 8e573429cec5659396be59b82ff4b03ff3cc8dd4 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Mon, 23 Aug 2021 12:14:36 +0200 Subject: [PATCH] fix: Passing Sentry diagnostic level to iOS native layer (#281) * switch case for native diagnostic level * cleanup * updated CHANGELOG.md --- CHANGELOG.md | 1 + src/Sentry.Unity.Editor.iOS/NativeOptions.cs | 22 ++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68c73680a..1df453156 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Fixes +- Fixed passing Sentry diagnostic level to iOS native layer ([#281](https://github.com/getsentry/sentry-unity/pull/281)) - Fixed stuck traces sample rate slider ([#276](https://github.com/getsentry/sentry-unity/pull/276)) - Fixed selected input field tab glitches ([#276](https://github.com/getsentry/sentry-unity/pull/276)) - Bump Sentry .NET SDK 3.8.3 ([#269](https://github.com/getsentry/sentry-unity/pull/269)) diff --git a/src/Sentry.Unity.Editor.iOS/NativeOptions.cs b/src/Sentry.Unity.Editor.iOS/NativeOptions.cs index ee357658e..220c0d299 100644 --- a/src/Sentry.Unity.Editor.iOS/NativeOptions.cs +++ b/src/Sentry.Unity.Editor.iOS/NativeOptions.cs @@ -25,7 +25,7 @@ internal string Generate(SentryOptions options) NSDictionary* options = @{{ @""dsn"" : @""{options.Dsn}"", @""debug"" : @{ToObjCString(options.Debug)}, - @""diagnosticLevel"" : @{ToNativeDiagnosticLevel(options.DiagnosticLevel)}, + @""diagnosticLevel"" : @""{ToNativeDiagnosticLevel(options.DiagnosticLevel)}"", @""maxBreadcrumbs"": @{options.MaxBreadcrumbs}, @""maxCacheItems"": @{options.MaxCacheItems}, @""enableAutoSessionTracking"": @NO, @@ -40,13 +40,17 @@ internal string Generate(SentryOptions options) private static string ToObjCString(bool b) => b ? "YES" : "NO"; - // Native Diagnostic Level: - // None = 0 - // Debug = 1 - // Info = 2 - // Warning = 3 - // Error = 4 - // Fatal = 5 - private static int ToNativeDiagnosticLevel(SentryLevel diagnosticLevel) => (int)diagnosticLevel + 1; + private static string ToNativeDiagnosticLevel(SentryLevel sentryLevel) + { + return sentryLevel switch + { + SentryLevel.Debug => "debug", + SentryLevel.Info => "info", + SentryLevel.Warning => "warning", + SentryLevel.Error => "error", + SentryLevel.Fatal => "fatal", + _ => "none" + }; + } } }