From 03313562d21d5db9bf6a14ebbeab80e06c883d3a Mon Sep 17 00:00:00 2001 From: Rory& Date: Wed, 24 Jan 2024 02:31:56 +0100 Subject: MRU->RMU, fixes, cleanup --- MatrixUtils.Desktop/SentryService.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 MatrixUtils.Desktop/SentryService.cs (limited to 'MatrixUtils.Desktop/SentryService.cs') diff --git a/MatrixUtils.Desktop/SentryService.cs b/MatrixUtils.Desktop/SentryService.cs new file mode 100644 index 0000000..c965632 --- /dev/null +++ b/MatrixUtils.Desktop/SentryService.cs @@ -0,0 +1,29 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Sentry; + +namespace MatrixUtils.Desktop; + +public class SentryService : IDisposable { + private IDisposable? _sentrySdkDisposable; + public SentryService(IServiceScopeFactory scopeFactory, ILogger logger) { + var config = scopeFactory.CreateScope().ServiceProvider.GetRequiredService(); + if (config.SentryDsn is null) { + logger.LogWarning("Sentry DSN is not set, skipping Sentry initialisation"); + return; + } + _sentrySdkDisposable = SentrySdk.Init(o => { + o.Dsn = config.SentryDsn; + // When configuring for the first time, to see what the SDK is doing: + o.Debug = true; + // Set traces_sample_rate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + o.TracesSampleRate = 1.0; + // Enable Global Mode if running in a client app + o.IsGlobalModeEnabled = true; + }); + } + + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + public void Dispose() => _sentrySdkDisposable?.Dispose(); +} -- cgit 1.4.1