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 null data on breadcrumb. #90

Merged
merged 6 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

### Unreleased

### Fixes

- Ignore null data on Internal breadcrumbs ([#90](https://github.com/getsentry/sentry-xamarin/pull/90))

## 1.3.1

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion Src/Sentry.Xamarin/Extensions/IHubExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal static void AddInternalBreadcrumb(
previousBreadcrumb.Message == message &&
previousBreadcrumb.Category == category &&
previousBreadcrumb.Type == type &&
!previousBreadcrumb.Data.Except(data).Any() &&
previousBreadcrumb.Data?.Except(data).Any() is false &&
DateTimeOffset.UtcNow.Subtract(previousBreadcrumb.Timestamp).TotalSeconds < options.InternalBreadcrumbDuplicationTimeSpan)
{
//Skip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,6 @@ namespace Sentry.Xamarin.Forms.UWP.Tests.Extensions
{
public class SentryXamarinOptionsExtensionsTests
{
[Fact]
public void ConfigureSentryOptions_ReleaseSetIfNotInformed()
{
//Arrange
var options = new SentryXamarinOptions();
options.Release = null;

//Act
options.ConfigureSentryXamarinOptions();

//Assert
Assert.NotNull(options.Release);
}

[Fact]
public void ConfigureSentryOptions_ReleaseNotSetIfInformed()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public void Register_ValidEvent_EventWithDeviceInfoSet()

//Assert
Assert.NotNull(@event.Contexts.Device.Simulator);
Assert.NotNull(@event.Contexts.Device.Manufacturer);
lucas-zimerman marked this conversation as resolved.
Show resolved Hide resolved
Assert.NotNull(@event.Contexts.Device.Model);
}

Expand Down
23 changes: 23 additions & 0 deletions Tests/Sentry.Xamarin.Tests/Extensions/IHubExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,29 @@ public void AddInternalBreadcrumb_NewBreadcumbWithDifferentData_BreadcrumbAdded(
Assert.NotEqual(breadcrumb, options.LastInternalBreadcrumb);
}

[Fact]
public void AddInternalBreadcrumb_NewBreadcumbWithNullData_BreadcrumbAdded()
lucas-zimerman marked this conversation as resolved.
Show resolved Hide resolved
{
//Assert
const string message = "message";
const string type = "type";
var logger = Substitute.For<IDiagnosticLogger>();
var hub = Sut;
var options = new SentryXamarinOptions();
options.Debug = true;
options.DiagnosticLogger = logger;
var breadcrumb = new Breadcrumb(message, type);
options.LastInternalBreadcrumb = breadcrumb;

//Act
hub.AddInternalBreadcrumb(options, message, null, type);

//Assert
logger.DidNotReceive().Log(Arg.Any<SentryLevel>(), Arg.Is<string>(IHubExtensions.DuplicatedBreadcrumbDropped), Arg.Any<Exception>(), Arg.Any<object[]>());
Assert.NotEqual(breadcrumb, options.LastInternalBreadcrumb);
}


lucas-zimerman marked this conversation as resolved.
Show resolved Hide resolved
[Fact]
public async Task AddInternalBreadcrumb_DuplicatedIs2SecondsAhead_BreadcrumbAdded()
{
Expand Down