|
1 | 1 | using System.Net.Http; |
2 | 2 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; |
| 3 | +using Sentry.Samples.AspNetCore.Blazor.Wasm; |
3 | 4 |
|
4 | | -namespace Sentry.Samples.AspNetCore.Blazor.Wasm; |
5 | | - |
6 | | -internal static class Program |
| 5 | +// Capture blazor bootstrapping errors |
| 6 | +using var sdk = SentrySdk.Init(o => |
| 7 | +{ |
| 8 | + o.Dsn = "https://[email protected]/5428537"; |
| 9 | + o.Debug = true; |
| 10 | +}); |
| 11 | +try |
7 | 12 | { |
8 | | -#pragma warning disable IDE1006 // Naming Styles |
9 | | - public static async Task Main(string[] args) |
10 | | - { |
11 | | - // Capture blazor bootstrapping errors |
12 | | - using var sdk = SentrySdk.Init(o => |
13 | | - { |
14 | | - o.Dsn = "https://[email protected]/5428537"; |
15 | | - o.Debug = true; |
16 | | - }); |
17 | | - try |
18 | | - { |
19 | | - var builder = WebAssemblyHostBuilder.CreateDefault(args); |
20 | | - builder.RootComponents.Add<App>("#app"); |
21 | | - builder.Logging.SetMinimumLevel(LogLevel.Debug); |
22 | | - // Captures logError and higher as events |
23 | | - builder.Logging.AddSentry(o => o.InitializeSdk = false); |
| 13 | + var builder = WebAssemblyHostBuilder.CreateDefault(args); |
| 14 | + builder.RootComponents.Add<App>("#app"); |
| 15 | + builder.Logging.SetMinimumLevel(LogLevel.Debug); |
| 16 | + // Captures logError and higher as events |
| 17 | + builder.Logging.AddSentry(o => o.InitializeSdk = false); |
24 | 18 |
|
25 | | - builder.Services.AddScoped(_ => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); |
| 19 | + builder.Services.AddScoped(_ => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); |
26 | 20 |
|
27 | | - await builder.Build().RunAsync(); |
28 | | - } |
29 | | - catch (Exception e) |
30 | | - { |
31 | | - SentrySdk.CaptureException(e); |
32 | | - await SentrySdk.FlushAsync(TimeSpan.FromSeconds(2)); |
33 | | - throw; |
34 | | - } |
35 | | - } |
| 21 | + await builder.Build().RunAsync(); |
| 22 | +} |
| 23 | +catch (Exception e) |
| 24 | +{ |
| 25 | + SentrySdk.CaptureException(e); |
| 26 | + await SentrySdk.FlushAsync(TimeSpan.FromSeconds(2)); |
| 27 | + throw; |
36 | 28 | } |
0 commit comments