diff --git a/.github/workflows/createrelease.yml b/.github/workflows/createrelease.yml index 1529bce..d237596 100644 --- a/.github/workflows/createrelease.yml +++ b/.github/workflows/createrelease.yml @@ -47,7 +47,13 @@ jobs: - name: Publish API if: ${{ github.event.release.prerelease == false }} - run: dotnet publish "CallbackHandler/CallbackHandler.csproj" --configuration Release --output publishOutput -r win-x64 --self-contained false + run: dotnet publish "CallbackHandler/CallbackHandler.csproj" + --configuration Release --output publishOutput -r win-x64 + --self-contained false + -p:Version=${{ steps.get_version.outputs.VERSION }} + -p:AssemblyVersion${{ steps.get_version.outputs.VERSION }} + -p:FileVersion=${{ steps.get_version.outputs.VERSION }} + -p:InformationalVersion${{ steps.get_version.outputs.VERSION }} - name: Build Release Package run: | diff --git a/CallbackHandler/CallbackHandler.csproj b/CallbackHandler/CallbackHandler.csproj index 548e6f9..ec14b4c 100644 --- a/CallbackHandler/CallbackHandler.csproj +++ b/CallbackHandler/CallbackHandler.csproj @@ -12,6 +12,7 @@ + diff --git a/CallbackHandler/Handlers/CallbackHandlers.cs b/CallbackHandler/Handlers/CallbackHandlers.cs index c7951ab..c2427f6 100644 --- a/CallbackHandler/Handlers/CallbackHandlers.cs +++ b/CallbackHandler/Handlers/CallbackHandlers.cs @@ -3,9 +3,12 @@ using CallbackHandlers.Models; using MediatR; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; +using Sentry; using Shared.Results; +using Shared.Results.Web; using SimpleResults; using System; using System.Collections.Generic; @@ -13,8 +16,6 @@ using System.Net; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Http.HttpResults; -using Shared.Results.Web; namespace CallbackHandler.Handlers; @@ -26,6 +27,10 @@ public static async Task RecordCallback(Deposit depositCallback, { Guid callbackId = Guid.NewGuid(); + if (depositCallback.Reference == "ExceptionTest") { + throw new Exception("This is a test exception"); + } + CallbackCommands.RecordCallbackCommand request = new( callbackId, JsonConvert.SerializeObject(depositCallback), diff --git a/CallbackHandler/Program.cs b/CallbackHandler/Program.cs index 8f6a9fc..f4dccb4 100644 --- a/CallbackHandler/Program.cs +++ b/CallbackHandler/Program.cs @@ -2,23 +2,28 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; +using Shared.General; +using Shared.Logger; +using Shared.Middleware; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using NLog.Extensions.Logging; -using Shared.Logger; -using Shared.Middleware; +using JasperFx.CommandLine.Descriptions; namespace CallbackHandler { using Lamar.Microsoft.DependencyInjection; using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.Options; using NLog; + using Sentry.Extensibility; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using System.Diagnostics.CodeAnalysis; using System.IO; + using System.Reflection; [ExcludeFromCodeCoverage] public class Program @@ -68,7 +73,30 @@ public static IHostBuilder CreateHostBuilder(string[] args) webBuilder.UseStartup(); webBuilder.UseConfiguration(config); webBuilder.UseKestrel(); + + IConfigurationSection isSentryConfigured = config.GetSection("SentryConfiguration"); + if (isSentryConfigured.Exists()) { + webBuilder.Configure((context, + app) => { + if (context.HostingEnvironment.IsDevelopment() == false) { + Version version = Assembly.GetExecutingAssembly().GetName().Version; + + webBuilder.UseSentry(o => { + + o.Dsn = ConfigurationReader.GetValueFromSection("SentryConfiguration", "Dsn"); + o.SendDefaultPii = true; // required for body + user data + o.MaxRequestBodySize = RequestSize.Always; + o.CaptureBlockingCalls = true; + //o.CaptureFailedRequests = true; + o.Release = version != null ? version.ToString() : "unknown"; + + }); + } + }); + + } }); + return hostBuilder; } diff --git a/CallbackHandler/Startup.cs b/CallbackHandler/Startup.cs index a50eae8..238832d 100644 --- a/CallbackHandler/Startup.cs +++ b/CallbackHandler/Startup.cs @@ -1,8 +1,8 @@ +using CallbackHandler.Endpoints; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; -using CallbackHandler.Endpoints; namespace CallbackHandler { @@ -11,6 +11,7 @@ namespace CallbackHandler using Lamar; using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.Extensions.Logging; + using Sentry; using Shared.EventStore.Aggregate; using Shared.Extensions; using Shared.General; @@ -80,7 +81,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF Logger.Initialise(logger); Startup.Configuration.LogConfiguration(Logger.LogWarning); - + ConfigurationReader.Initialise(Startup.Configuration); app.UseMiddleware(); app.AddRequestResponseLogging(); diff --git a/CallbackHandler/appsettings.json b/CallbackHandler/appsettings.json index 0db3279..1797133 100644 --- a/CallbackHandler/appsettings.json +++ b/CallbackHandler/appsettings.json @@ -1,3 +1,3 @@ { - + }