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.
Add the Sentry dependency to your Blazor WebAssembly application:
Copied
dotnet add package Sentry.AspNetCore.Blazor.WebAssembly -v 5.0.0
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:
Copied
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.UseSentry(options =>
{
options.Dsn = "https://examplePublicKey@o0.ingest.sentry.io/0";
options.TracesSampleRate = 0.1;
// When configuring for the first time, to see what the SDK is doing:
// options.Debug = true;
});
// 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.
Copied
try
{
throw null;
}
catch (Exception ex)
{
SentrySdk.CaptureException(ex);
}
- This integration with Blazor WebAssembly sample demonstrates using Sentry with Blazor WebAssembly. (C#)
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").