Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- .NET on iOS: Add experimental EnableAppHangTrackingV2 configuration flag to the options binding SDK ([#3877](https://github.com/getsentry/sentry-dotnet/pull/3877))
- Added `SentryOptions.DisableSentryHttpMessageHandler`. Useful if you're using `OpenTelemetry.Instrumentation.Http` and ending up with duplicate spans. ([#3879](https://github.com/getsentry/sentry-dotnet/pull/3879))

### Fixes

- Fixed duplicate SentryMauiEventProcessors ([#3905](https://github.com/getsentry/sentry-dotnet/pull/3905))

### Dependencies

- Bump Native SDK from v0.7.17 to v0.7.18 ([#3891](https://github.com/getsentry/sentry-dotnet/pull/3891))
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.Maui/Internal/SentryMauiOptionsSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal class SentryMauiOptionsSetup : IConfigureOptions<SentryMauiOptions>
public SentryMauiOptionsSetup(IConfiguration config)
{
ArgumentNullException.ThrowIfNull(config);
_config = config;
_config = config.GetSection("Sentry");
}

public void Configure(SentryMauiOptions options)
Expand Down
3 changes: 0 additions & 3 deletions src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ public static MauiAppBuilder UseSentry(this MauiAppBuilder builder,
{
var services = builder.Services;

var section = builder.Configuration.GetSection("Sentry");
services.AddSingleton<IConfigureOptions<SentryMauiOptions>>(_ => new SentryMauiOptionsSetup(section));

if (configureOptions != null)
{
services.Configure(configureOptions);
Expand Down
19 changes: 19 additions & 0 deletions test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Extensions.Options;
using Sentry.Internal.Http;
using Sentry.Maui.Internal;
using MauiConstants = Sentry.Maui.Internal.Constants;

namespace Sentry.Maui.Tests;
Expand Down Expand Up @@ -29,6 +30,24 @@ public Fixture()

private readonly Fixture _fixture = new();

[Fact]
public void UseSentry_RegistersEventProcessorOnlyOnce()
{
// Arrange
var builder = _fixture.Builder;
builder.Services.Configure<SentryMauiOptions>(options =>
{
options.Dsn = ValidDsn;
});

// Act
using var app = builder.UseSentry().Build();

// Assert
var options = app.Services.GetRequiredService<IOptions<SentryMauiOptions>>().Value;
options.EventProcessors.Should().ContainSingle(t => t.Type == typeof(SentryMauiEventProcessor));
}

[Fact]
public void CanUseSentry_WithConfigurationOnly()
{
Expand Down
Loading