From e8905ef8c321ddb8b843244be2fd788d0ceaaf1e Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Fri, 13 Feb 2026 11:29:38 -0500 Subject: [PATCH 1/3] fix(blazor): Skip duplicate navigation breadcrumbs in WASM When Blazor apps use both @onclick+NavigateTo and href on links, LocationChanged fires twice for the same URL. Skip creating a breadcrumb when the new location matches the previous one. Co-Authored-By: Claude Opus 4.6 --- .../Internal/BlazorWasmOptionsSetup.cs | 6 ++++++ .../BlazorWasmOptionsSetupTests.cs | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/Sentry.AspNetCore.Blazor.WebAssembly/Internal/BlazorWasmOptionsSetup.cs b/src/Sentry.AspNetCore.Blazor.WebAssembly/Internal/BlazorWasmOptionsSetup.cs index ad1f5bbcc9..e284e81836 100644 --- a/src/Sentry.AspNetCore.Blazor.WebAssembly/Internal/BlazorWasmOptionsSetup.cs +++ b/src/Sentry.AspNetCore.Blazor.WebAssembly/Internal/BlazorWasmOptionsSetup.cs @@ -42,6 +42,12 @@ public void Configure(SentryBlazorOptions options) _navigationManager.LocationChanged += (_, args) => { + // Skip duplicate navigations (e.g. when both @onclick+NavigateTo and href fire) + if (string.Equals(args.Location, previousUrl, StringComparison.Ordinal)) + { + return; + } + var from = ToRelativePath(previousUrl); var to = ToRelativePath(args.Location); diff --git a/test/Sentry.AspNetCore.Blazor.WebAssembly.Tests/BlazorWasmOptionsSetupTests.cs b/test/Sentry.AspNetCore.Blazor.WebAssembly.Tests/BlazorWasmOptionsSetupTests.cs index d9960f3087..6a1435c284 100644 --- a/test/Sentry.AspNetCore.Blazor.WebAssembly.Tests/BlazorWasmOptionsSetupTests.cs +++ b/test/Sentry.AspNetCore.Blazor.WebAssembly.Tests/BlazorWasmOptionsSetupTests.cs @@ -147,4 +147,18 @@ public void Navigation_FromInitialPath_TracksCorrectFrom() crumb.Data.Should().ContainKey("from").WhoseValue.Should().Be("/login"); crumb.Data.Should().ContainKey("to").WhoseValue.Should().Be("/home"); } + + [Fact] + public void DuplicateNavigation_SkipsBreadcrumb() + { + // Arrange + _sut.Configure(new SentryBlazorOptions()); + + // Act — navigate to /page1, then fire LocationChanged again for the same URL + _navigationManager.NavigateTo("/page1"); + _navigationManager.NavigateTo("/page1"); + + // Assert — only one breadcrumb should be created + _scope.Breadcrumbs.Should().ContainSingle(); + } } From 1ef282e9b607c22384425f86fb206eddbdb15b4f Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Fri, 13 Feb 2026 11:33:19 -0500 Subject: [PATCH 2/3] Add changelog entry for duplicate breadcrumb fix Co-Authored-By: Claude Opus 4.6 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c43882a550..ae0092461d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - Add navigation breadcrumbs for Blazor WebAssembly ([#4907](https://github.com/getsentry/sentry-dotnet/pull/4907)) +### Fixes + +- Skip duplicate navigation breadcrumbs in Blazor WebAssembly ([#4922](https://github.com/getsentry/sentry-dotnet/pull/4922)) + ### Dependencies - Bumped Xamarin.Kotlin.StdLib.Jdk8 to 2.2.20 ([#4876](https://github.com/getsentry/sentry-dotnet/pull/4876)) From 8ab742fd419ed900dcb6290d47faf616a10dadf6 Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Fri, 13 Feb 2026 11:37:14 -0500 Subject: [PATCH 3/3] Remove changelog entry Co-Authored-By: Claude Opus 4.6 --- CHANGELOG.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae0092461d..c43882a550 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,6 @@ - Add navigation breadcrumbs for Blazor WebAssembly ([#4907](https://github.com/getsentry/sentry-dotnet/pull/4907)) -### Fixes - -- Skip duplicate navigation breadcrumbs in Blazor WebAssembly ([#4922](https://github.com/getsentry/sentry-dotnet/pull/4922)) - ### Dependencies - Bumped Xamarin.Kotlin.StdLib.Jdk8 to 2.2.20 ([#4876](https://github.com/getsentry/sentry-dotnet/pull/4876))