Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions src/WslStudio.App/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.UI.Xaml;
using Sentry;
using WslStudio.App.Services;

namespace WslStudio.App;

public partial class App : Microsoft.UI.Xaml.Application
{
private readonly IHost _host;
private readonly IDisposable _sentry;
private Window? _window;

public App()
{
_sentry = SentrySdk.Init(options =>
{
// Reads the DSN from the SENTRY_DSN environment variable.
// Sentry remains disabled if the variable is missing or empty.
options.Dsn = Environment.GetEnvironmentVariable("SENTRY_DSN");

#if DEBUG
// Useful while initially testing the integration.
options.Debug = true;
#else
options.Debug = false;
#endif

options.AutoSessionTracking = true;
});

InitializeComponent();

HostApplicationBuilder builder = Host.CreateApplicationBuilder();
Expand All @@ -31,7 +49,15 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)

private async void OnMainWindowClosed(object sender, WindowEventArgs args)
{
await _host.StopAsync();
_host.Dispose();
try
{
await _host.StopAsync();
await SentrySdk.FlushAsync(TimeSpan.FromSeconds(2));
}
finally
{
_host.Dispose();
_sentry.Dispose();
}
}
}
}
1 change: 1 addition & 0 deletions src/WslStudio.App/WslStudio.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.9" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.28000.1721" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="2.2.0" />
<PackageReference Include="Sentry" Version="6.6.0" />
</ItemGroup>

<ItemGroup>
Expand Down