Open manuc66 opened 1 year ago
Hey @manuc66, thanks for reaching out and you're right, we don't yet have anything built specifically to support Avalonia. Realistically, we won't have the bandwidth to build an official integration for this anytime soon.
I can try to help you work through the issues you've run into. As long as Avalonia has some kind of global exception handler, you could probably get some basic exception capturing going on.
There's quite a lot of complexity in instrumenting multi platform applications properly however. For our MAUI integration, we had to create bindings into Sentry's Android and iOS SDKs, to properly instrument the native code that gets produced when deploying to these platforms. That could maybe serve as an example of how this might be done in frameworks like Avalonia.
It should work with the core Sentry
package. Just SentrySdk.Init
early in the program. You can also use any Avalonia specific error handler and call into SentrySdk.CaptureException
.
Here's how we document for WPF: https://docs.sentry.io/platforms/dotnet/guides/wpf/ (for WPF there was also #1036 )
That said, what would a specific Sentry.Avalonia
offer? What kind of hooks, etc does Avalonia have that we could leverage?
Taken from the Avalonia docs Avalonia UI does not offer any mechanism to handle exceptions globally
.
So I don't think there is anything a Sentry.Avalonia
would be able to provide there from an error-capturing perspective.
Subscribing to lifetime events for breadcrumbs might be nice tho.
Subscribing to lifetime events for breadcrumbs might be nice tho.
👍
we had to create bindings into Sentry's Android and iOS SDKs, to properly instrument the native code that gets produced when deploying to these platforms
@jamescrosswell Does that mean AvaloniaUI apps should add Maui or Android/iOS packages specifically so that native code crashes will be handled properly? My Avalonia app runs on Windows/Linux/MacOS as will as Android and iOS. Do I need to add several packages with #if
code to activate OS-specific hooks?
@jamescrosswell Does that mean AvaloniaUI apps should add Maui or Android/iOS packages specifically so that native code crashes will be handled properly?
@AArnott you definitely wouldn't use the Maui package as that depends on Microsoft.Maui.Hosting.MauiAppBuilder
(you won't have one of those in an AvaloniaUI app).
I'm not sure how you would use the Android, iOS and Native bindings from AvaloniaUI.
@bruno-garcia or @vaind might be able to answer as they were more involved in the Maui and Native integrations.
The core Sentry package handles the import of the bindings based on the targeted platform here https://github.com/getsentry/sentry-dotnet/blob/5152a3c8cda39bacfce913fdb4799becc8e1d479/src/Sentry/Sentry.csproj#L21-L25
If AvaloniaUI has some different TargetPlatformIdentifiers
that might be an additional thing a dedicated package could provide.
That's very useful. I don't target maccatalyst explicitly. I just run the net8.0
targeted project on macos. It looks then like I'll get more out of sentry by targeting macos specifically, which I should be able to do.
And I was already targeting android explicitly.
Thanks!
It looks then like I'll get more out of sentry by targeting macos specifically, which I should be able to do.
With the macos support of .NET we have Native AOT support, with native crashes included. maccatalyst gives you bindings to the Sentry SDK for Cocoa which has many other features.
Problem Statement
I am attempting to integrate Sentry into my AvaloniaUI application for error monitoring and reporting. However, I have encountered challenges as there doesn't seem to be official support or guidance for using the Sentry .NET SDK with AvaloniaUI applications.
Solution Brainstorm
No response