-
-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathWebAssemblyHostBuilderExtensions.cs
More file actions
50 lines (44 loc) · 1.83 KB
/
WebAssemblyHostBuilderExtensions.cs
File metadata and controls
50 lines (44 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Sentry;
using Sentry.AspNetCore.Blazor.WebAssembly.Internal;
using Sentry.Extensions.Logging;
using Sentry.Internal;
// ReSharper disable once CheckNamespace - Discoverability
namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting;
/// <summary>
/// Extension methods for <see cref="WebAssemblyHostBuilder"/>
/// </summary>
public static class WebAssemblyHostBuilderExtensions
{
/// <summary>
/// Use Sentry Integration
/// </summary>
/// <param name="builder"></param>
/// <param name="configureOptions"></param>
/// <returns></returns>
public static WebAssemblyHostBuilder UseSentry(this WebAssemblyHostBuilder builder, Action<SentryBlazorOptions> configureOptions)
{
builder.Logging.AddSentry<SentryBlazorOptions>(blazorOptions =>
{
configureOptions(blazorOptions);
// System.PlatformNotSupportedException: System.Diagnostics.Process is not supported on this platform.
blazorOptions.DetectStartupTime = StartupTimeDetectionMode.Fast;
// Warning: No response compression supported by HttpClientHandler.
blazorOptions.RequestBodyCompressionLevel = CompressionLevel.NoCompression;
// Since the WebAssemblyHost is a client-side application
blazorOptions.IsGlobalModeEnabled = true;
blazorOptions.AddTransactionProcessor(new TraceIgnoreStatusCodeTransactionProcessor(blazorOptions));
});
builder.Services.AddSingleton<IConfigureOptions<SentryBlazorOptions>, BlazorWasmOptionsSetup>();
return builder;
}
}
/// <summary>
/// Sentry Blazor Options
/// </summary>
public class SentryBlazorOptions : SentryLoggingOptions
{
// Awesome Blazor specific options go here
}