title | sdk | description |
---|---|---|
Blazor WebAssembly |
sentry.aspnetcore.blazor.webassembly |
Learn about Sentry's .NET integration with Blazor WebAssembly. |
Sentry provides an integration with Blazor WebAssembly through the Sentry.AspNetCore.Blazor.WebAssembly NuGet package.
<OnboardingOptionButtons options={['error-monitoring', 'performance']}/>
Add the Sentry dependency to your Blazor WebAssembly application:
dotnet add package Sentry.AspNetCore.Blazor.WebAssembly -v {{@inject packages.version('sentry.dotnet.aspnetcore.blazor.webassembly') }}
Install-Package Sentry.AspNetCore.Blazor.WebAssembly -Version {{@inject packages.version('sentry.dotnet.aspnetcore.blazor.webassembly') }}
This package extends Sentry.Extensions.Logging. This means that in addition to the related Blazor WebAssembly features, you'll also get access to the ILogger<T>
integration and other features available in the main Sentry SDK through this package.
Sentry integration with Blazor WebAssembly is done by calling .UseSentry()
and specifying the options, for example:
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.UseSentry(options =>
{
options.Dsn = "___PUBLIC_DSN___";
// When configuring for the first time, to see what the SDK is doing:
options.Debug = true;
// Adds request URL and headers, IP and name for users, etc.
options.SendDefaultPii = true;
// ___PRODUCT_OPTION_START___ performance
options.TracesSampleRate = 0.1;
// ___PRODUCT_OPTION_END___ performance
});
// Captures logError and higher as events
builder.Logging.AddSentry(o => o.InitializeSdk = false);
await builder.Build().RunAsync();
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
- This integration with Blazor WebAssembly sample demonstrates using Sentry with Blazor WebAssembly. (C#)