diff --git a/CHANGELOG.md b/CHANGELOG.md index e67270fd9d..42e4ffa46d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - `InvalidOperationException` potentially thrown during a race condition, especially in concurrent high-volume logging scenarios ([#4428](https://github.com/getsentry/sentry-dotnet/pull/4428)) - Blocking calls are no longer treated as unhandled crashes ([#4458](https://github.com/getsentry/sentry-dotnet/pull/4458)) - Only apply Session Replay masks to specific control types when necessary to avoid performance issues in MAUI apps with complex UIs ([#4445](https://github.com/getsentry/sentry-dotnet/pull/4445)) +- Ensure profiling is disabled in Blazor WebAssembly ([#4507](https://github.com/getsentry/sentry-dotnet/pull/4507)) ### Dependencies diff --git a/src/Sentry.AspNetCore.Blazor.WebAssembly/Sentry.AspNetCore.Blazor.WebAssembly.csproj b/src/Sentry.AspNetCore.Blazor.WebAssembly/Sentry.AspNetCore.Blazor.WebAssembly.csproj index 4ff5701fa0..263ab88be4 100644 --- a/src/Sentry.AspNetCore.Blazor.WebAssembly/Sentry.AspNetCore.Blazor.WebAssembly.csproj +++ b/src/Sentry.AspNetCore.Blazor.WebAssembly/Sentry.AspNetCore.Blazor.WebAssembly.csproj @@ -7,6 +7,7 @@ + diff --git a/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs b/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs index ca208e0280..db1febde85 100644 --- a/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs +++ b/src/Sentry.AspNetCore.Blazor.WebAssembly/WebAssemblyHostBuilderExtensions.cs @@ -1,6 +1,8 @@ using Microsoft.Extensions.Logging; using Sentry; +using Sentry.Extensibility; using Sentry.Extensions.Logging; +using Sentry.Profiling; // ReSharper disable once CheckNamespace - Discoverability namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting; @@ -28,10 +30,27 @@ public static WebAssemblyHostBuilder UseSentry(this WebAssemblyHostBuilder build blazorOptions.RequestBodyCompressionLevel = CompressionLevel.NoCompression; // Since the WebAssemblyHost is a client-side application blazorOptions.IsGlobalModeEnabled = true; + // If profiling enabled, disable it. + RemoveBlazorProfilingIntegration(blazorOptions); }); return builder; } + + private static void RemoveBlazorProfilingIntegration(SentryBlazorOptions options) + { + if (!options.IsProfilingEnabled) + { + return; + } + + options.SetupLogging(); + options.LogDebug("Detected Sentry profiling initialization in Blazor WebAssembly. " + + "Sentry does not support Blazor WebAssembly profiling. Removing profiling integration. " + + "Check https://github.com/getsentry/sentry-dotnet/issues/4506 for more information."); + // Ensure project doesn't have Profiling Integration + options.RemoveIntegration(); + } } /// diff --git a/src/Sentry/Sentry.csproj b/src/Sentry/Sentry.csproj index f00de450ff..604f8edaae 100644 --- a/src/Sentry/Sentry.csproj +++ b/src/Sentry/Sentry.csproj @@ -13,7 +13,7 @@ $(TargetFrameworks);net9.0-ios18.0;net8.0-ios17.0 $(TargetFrameworks);net9.0-maccatalyst18.0;net8.0-maccatalyst17.0 - + @@ -148,6 +148,7 @@ +