Skip to content

Commit

Permalink
fix: Passing Sentry diagnostic level to iOS native layer (#281)
Browse files Browse the repository at this point in the history
* switch case for native diagnostic level

* cleanup

* updated CHANGELOG.md
  • Loading branch information
bitsandfoxes authored Aug 23, 2021
1 parent da7d065 commit 8e57342
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
22 changes: 13 additions & 9 deletions src/Sentry.Unity.Editor.iOS/NativeOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"
};
}
}
}

0 comments on commit 8e57342

Please sign in to comment.