getsentry / sentry-dotnet

Sentry SDK for .NET
https://docs.sentry.io/platforms/dotnet
MIT License
603 stars 206 forks source link

Investigate Blazor+MAUI hybrid apps #1954

Open mattjohnsonpint opened 2 years ago

mattjohnsonpint commented 2 years ago

Problem Statement

Looks like MAUI Blazor hybrid apps are getting popular.

We should see if we can support it OOTB with the Sentry .NET MAUI SDK.

Solution Brainstorm

It may be helpful to bundle the Sentry JavaScript SDK, not sure.

kanadaj commented 2 years ago

It may be required to sign up to the NavigationManager.LocationChanged event for tracking page loads, but not sure if there is a good way to track page loading times in general otherwise.

kanadaj commented 1 year ago

From what we've observed, some JS errors never make it to the .NET side so they have to be logged by the JS SDK. On the other hand, this is also true for many .NET errors; they never make it to the JS console (or if they do, they lack metadata). So you basically need both SDKs.

The main issue is keeping scope in sync via asynchronous IPCs. I think for the most part you only need to push metadata to the JS side, not backwards; maybe even a pull approach could work before sending events to Sentry?

Some de-duplication mechanism is also needed if there are 2 SDKs since some events seem to make it through to both ends of the logging pipeline. Maybe just push events directly from the JS SDK to the .NET SDK and have the .NET side handle the messaging and de-duplication?

domagojmedo commented 2 weeks ago

Any info about this?

bruno-garcia commented 2 weeks ago

Any info about this?

We didn't make progress on this yet. But would be nice to add support. Do you have Sentry already in the app? I imagine at least the native crashes get captured, do the C# ones within the Blazor view also get captured?

domagojmedo commented 2 weeks ago

We started a new blazor hybrid project and are still exploring options so can't really tell how it behaves

bruno-garcia commented 2 weeks ago

We started a new blazor hybrid project and are still exploring options so can't really tell how it behaves

I recommend adding Sentry.Maui for now. You should be able to use SentrySdk.CaptureException for example from within the Blazor webview (it does run on Web, the core bits). But we didn't test/try this out ourselves yet