Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/allow dotnet release detection #85

Merged
merged 4 commits into from
Sep 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

- screenshot extension ([#81](https://github.com/getsentry/sentry-xamarin/pull/81))
- allow setting release to null to rely on the dotnet SDK release detection ([#85](https://github.com/getsentry/sentry-xamarin/pull/85))
- Update Sentry.NET SDK to 3.9.2 ([#84](https://github.com/getsentry/sentry-xamarin/pull/84))
- [changelog](https://github.com/getsentry/sentry-dotnet/blob/3.9.2/CHANGELOG.md)
- [diff](https://github.com/getsentry/sentry-dotnet/compare/3.9.1...3.9.2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ public static void DisableOfflineCaching(this SentryXamarinOptions options)
options.InternalCacheEnabled = false;
}

internal static string DefaultCacheDirectoyPath(this SentryXamarinOptions _)
internal static string DefaultCacheDirectoryPath(this SentryXamarinOptions _)
=> _internalCacheDefaultPath.Value;

internal static void ConfigureSentryXamarinOptions(this SentryXamarinOptions options)
{
options.Release ??= $"{AppInfo.PackageName}@{AppInfo.VersionString}+{AppInfo.BuildString}";
if (options.InternalCacheEnabled)
{
options.CacheDirectoryPath ??= options.DefaultCacheDirectoyPath();
options.CacheDirectoryPath ??= options.DefaultCacheDirectoryPath();
}
}

Expand Down
20 changes: 12 additions & 8 deletions Src/Sentry.Xamarin/SentryXamarin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Xamarin.Essentials;

namespace Sentry
{
Expand All @@ -21,7 +22,18 @@ public static class SentryXamarin
public static void Init(Action<SentryXamarinOptions> configureOptions)
{
var options = new SentryXamarinOptions();
// Set the release now but give the user a chance to reset it (i.e: to null to rely on the built-in format)
options.Release = $"{AppInfo.PackageName}@{AppInfo.VersionString}+{AppInfo.BuildString}";

configureOptions?.Invoke(options);

options.ConfigureSentryXamarinOptions();
options.RegisterNativeActivityStatus();
options.RegisterNativeIntegrations();
options.RegisterXamarinEventProcessors();
options.RegisterXamarinInAppExclude();
options.ProtocolPackageName ??= ProtocolPackageName;

Init(options);
}

Expand All @@ -31,14 +43,6 @@ public static void Init(Action<SentryXamarinOptions> configureOptions)
/// <param name="options">The options instance</param>
public static void Init(SentryXamarinOptions options)
{
options ??= new SentryXamarinOptions();

options.ConfigureSentryXamarinOptions();
options.RegisterNativeActivityStatus();
options.RegisterNativeIntegrations();
options.RegisterXamarinEventProcessors();
options.RegisterXamarinInAppExclude();
options.ProtocolPackageName ??= ProtocolPackageName;
SentrySdk.Init(options);

options.RegisterScreenshotEventProcessor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void ConfigureSentryOptions_DefaultCachePathEnabledAndCacheDirectoryPathN
{
CacheDirectoryPath = null
};
var expectedPath = options.DefaultCacheDirectoyPath();
var expectedPath = options.DefaultCacheDirectoryPath();

//Act
options.ConfigureSentryXamarinOptions();
Expand Down