diff --git a/Sentry.sln b/Sentry.sln index 60593a896a..bbe63195bc 100644 --- a/Sentry.sln +++ b/Sentry.sln @@ -108,11 +108,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ .github\workflows\changelog.yaml = .github\workflows\changelog.yaml EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.AspNetCore.Grpc", "src\Sentry.AspNetCore.Grpc\Sentry.AspNetCore.Grpc.csproj", "{720811C8-29C7-4368-86F2-D61DF415AC2A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sentry.AspNetCore.Grpc", "src\Sentry.AspNetCore.Grpc\Sentry.AspNetCore.Grpc.csproj", "{720811C8-29C7-4368-86F2-D61DF415AC2A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.AspNetCore.Grpc.Tests", "test\Sentry.AspNetCore.Grpc.Tests\Sentry.AspNetCore.Grpc.Tests.csproj", "{3818FA5C-8649-427D-8E68-0C44558CA0DD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sentry.AspNetCore.Grpc.Tests", "test\Sentry.AspNetCore.Grpc.Tests\Sentry.AspNetCore.Grpc.Tests.csproj", "{3818FA5C-8649-427D-8E68-0C44558CA0DD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Samples.AspNetCore.Grpc", "samples\Sentry.Samples.AspNetCore.Grpc\Sentry.Samples.AspNetCore.Grpc.csproj", "{21599C29-C3D4-4DAC-A2D6-6C194600478F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sentry.Samples.AspNetCore.Grpc", "samples\Sentry.Samples.AspNetCore.Grpc\Sentry.Samples.AspNetCore.Grpc.csproj", "{21599C29-C3D4-4DAC-A2D6-6C194600478F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Samples.AspNetCore.Blazor.Wasm", "samples\Sentry.Samples.AspNetCore.Blazor.Wasm\Sentry.Samples.AspNetCore.Blazor.Wasm.csproj", "{73FDCE53-75D1-4DCC-933A-8AB93A0E86EA}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Samples.Aws.Lambda.AspNetCoreServer", "samples\Sentry.Samples.Aws.Lambda.AspNetCoreServer\Sentry.Samples.Aws.Lambda.AspNetCoreServer.csproj", "{274CEDC2-2129-469D-B269-649EFA2EF5E0}" EndProject @@ -242,6 +244,10 @@ Global {21599C29-C3D4-4DAC-A2D6-6C194600478F}.Debug|Any CPU.Build.0 = Debug|Any CPU {21599C29-C3D4-4DAC-A2D6-6C194600478F}.Release|Any CPU.ActiveCfg = Release|Any CPU {21599C29-C3D4-4DAC-A2D6-6C194600478F}.Release|Any CPU.Build.0 = Release|Any CPU + {73FDCE53-75D1-4DCC-933A-8AB93A0E86EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {73FDCE53-75D1-4DCC-933A-8AB93A0E86EA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {73FDCE53-75D1-4DCC-933A-8AB93A0E86EA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {73FDCE53-75D1-4DCC-933A-8AB93A0E86EA}.Release|Any CPU.Build.0 = Release|Any CPU {274CEDC2-2129-469D-B269-649EFA2EF5E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {274CEDC2-2129-469D-B269-649EFA2EF5E0}.Debug|Any CPU.Build.0 = Debug|Any CPU {274CEDC2-2129-469D-B269-649EFA2EF5E0}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -284,6 +290,7 @@ Global {720811C8-29C7-4368-86F2-D61DF415AC2A} = {AF6AF4C7-8AA2-4D59-8064-2D79560904EB} {3818FA5C-8649-427D-8E68-0C44558CA0DD} = {83263231-1A2A-4733-B759-EEFF14E8C5D5} {21599C29-C3D4-4DAC-A2D6-6C194600478F} = {77454495-55EE-4B40-A089-71B9E8F82E89} + {73FDCE53-75D1-4DCC-933A-8AB93A0E86EA} = {77454495-55EE-4B40-A089-71B9E8F82E89} {274CEDC2-2129-469D-B269-649EFA2EF5E0} = {77454495-55EE-4B40-A089-71B9E8F82E89} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/build.ps1 b/build.ps1 index a54485d665..580b0c9910 100644 --- a/build.ps1 +++ b/build.ps1 @@ -8,5 +8,5 @@ dotnet test -c Release -l $testLogger ` /p:Exclude='"""[Sentry.Protocol.Test*]*,[xunit.*]*,[Sentry.Test*]*\"""' if ($LASTEXITCODE -ne 0) { exit 1 } -dotnet pack -c Release --no-build /p:ContinuousIntegrationBuild=true +dotnet pack -c Release /p:ContinuousIntegrationBuild=true if ($LASTEXITCODE -ne 0) { exit 1 } diff --git a/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/App.razor b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/App.razor new file mode 100644 index 0000000000..651131deab --- /dev/null +++ b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/App.razor @@ -0,0 +1,10 @@ + + + + + + +

Sorry, there's nothing at this address.

+
+
+
diff --git a/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Pages/Index.razor b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Pages/Index.razor new file mode 100644 index 0000000000..ab828f3fde --- /dev/null +++ b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Pages/Index.razor @@ -0,0 +1,3 @@ +@page "/" + +

Sentry on Blazor WebAssembly

diff --git a/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Pages/Thrower.razor b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Pages/Thrower.razor new file mode 100644 index 0000000000..df69f978ad --- /dev/null +++ b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Pages/Thrower.razor @@ -0,0 +1,26 @@ +@page "/thrower" +@using Microsoft.Extensions.Logging +@inject ILogger Logger + +

Throw Exception

+ + + +@if (SentrySdk.LastEventId != SentryId.Empty) +{ +

Event Id: @SentrySdk.LastEventId

+} + +@code { + private void Throw() + { + Logger.LogInformation("Doing something ... "); + Stuff.DoSomething(); + } + + private static class Stuff + { + public static void DoSomething() => Thrower(); + private static void Thrower() => throw null; + } +} diff --git a/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Program.cs b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Program.cs new file mode 100644 index 0000000000..66fe9de6cc --- /dev/null +++ b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Program.cs @@ -0,0 +1,41 @@ +using System; +using System.Net.Http; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace Sentry.Samples.AspNetCore.Blazor.Wasm +{ + public static class Program + { +#pragma warning disable IDE1006 // Naming Styles + public static async Task Main(string[] args) + { + // Capture blazor bootstrapping errors + using var sdk = SentrySdk.Init(o => + { + o.Dsn = "https://80aed643f81249d4bed3e30687b310ab@o447951.ingest.sentry.io/5428537"; + o.Debug = true; + }); + try + { + var builder = WebAssemblyHostBuilder.CreateDefault(args); + builder.RootComponents.Add("#app"); + builder.Logging.SetMinimumLevel(LogLevel.Debug); + // Captures logError and higher as events + builder.Logging.AddSentry(o => o.InitializeSdk = false); + + builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); + + await builder.Build().RunAsync(); + } + catch (Exception e) + { + SentrySdk.CaptureException(e); + await SentrySdk.FlushAsync(TimeSpan.FromSeconds(2)); + throw; + } + } + } +} diff --git a/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Properties/launchSettings.json b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Properties/launchSettings.json new file mode 100644 index 0000000000..0244302b80 --- /dev/null +++ b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:65188", + "sslPort": 44354 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Sentry.Samples.AspNetCore.Blazor.Wasm": { + "commandName": "Project", + "dotnetRunMessages": "true", + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Sentry.Samples.AspNetCore.Blazor.Wasm.csproj b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Sentry.Samples.AspNetCore.Blazor.Wasm.csproj new file mode 100644 index 0000000000..7f70c466a0 --- /dev/null +++ b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Sentry.Samples.AspNetCore.Blazor.Wasm.csproj @@ -0,0 +1,18 @@ + + + + net5.0 + + + + + + + + + + + + + + diff --git a/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Shared/MainLayout.razor b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Shared/MainLayout.razor new file mode 100644 index 0000000000..4d177a4ea3 --- /dev/null +++ b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Shared/MainLayout.razor @@ -0,0 +1,11 @@ +@inherits LayoutComponentBase + +
+
+ @Body +
+ +
+ +
+
diff --git a/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Shared/NavMenu.razor b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Shared/NavMenu.razor new file mode 100644 index 0000000000..59d1d94a2d --- /dev/null +++ b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Shared/NavMenu.razor @@ -0,0 +1,25 @@ +@using Microsoft.Extensions.Logging +@inject ILogger Logger + +
+
    +
  • + + Throw, Catch and Capture + +
  • +
+
+ +@code { + private bool _collapseNavMenu = true; + + private string NavMenuCssClass => _collapseNavMenu ? "collapse" : null; + + private void ToggleNavMenu() + { + Logger.LogInformation("ToggleNavMenu {_collapseNavMenu}", _collapseNavMenu); + _collapseNavMenu = !_collapseNavMenu; + } + +} diff --git a/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/_Imports.razor b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/_Imports.razor new file mode 100644 index 0000000000..371c47f6ec --- /dev/null +++ b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/_Imports.razor @@ -0,0 +1,10 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using Microsoft.AspNetCore.Components.WebAssembly.Http +@using Microsoft.JSInterop +@using Sentry.Samples.AspNetCore.Blazor.Wasm +@using Sentry.Samples.AspNetCore.Blazor.Wasm.Shared +@using Sentry.Protocol diff --git a/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/wwwroot/index.html b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/wwwroot/index.html new file mode 100644 index 0000000000..b7f6c10d6a --- /dev/null +++ b/samples/Sentry.Samples.AspNetCore.Blazor.Wasm/wwwroot/index.html @@ -0,0 +1,22 @@ + + + + + + + BlazorApp1 + + + + +
Loading...
+ +
+ An unhandled error has occurred. + Reload + 🗙 +
+ + + +