getsentry / sentry-dotnet

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

Add ServiceCollection extensions for native Android and iOS projects #3292

Open Cheesebaron opened 1 month ago

Cheesebaron commented 1 month ago

Problem Statement

For projecs not using the MAUI UI framework and not relying on its MauiAppBuilder it would be nice to have extensions to set up in a net?-android and net?-ios App.

Solution Brainstorm

I guess the main issue here would be to have to hook into lifecycle events yourself, instead of relying on the interfaces MAUI framework provides. But it would behave exactly the same as a native Android and iOS App would.

bitsandfoxes commented 4 weeks ago

Hey @Cheesebaron, thanks for the feature request. That does sound interesting. Do you have an idea/snippet of what that could look like?

Cheesebaron commented 4 weeks ago

So in a couple of my Android and iOS Apps I just create a ServiceCollection like this and add dependencies to it:

var serviceCollection = new ServiceCollection();

So ideally I would just be able to add Sentry there with:

serviceCollection.AddSentry();

I had a look at what you are doing in the MAUI package for adding stuff to the service collection, I see you add:

The last one is very interesting and not sure if that comes out of the box if you just initialize Sentry directly through SentrySdk. Will lifecycle get observed? Perhaps these are mainly to hook into MAUI specific events to know when pages/windows/shell events are triggered?

EDIT:

After digging more into the code it also seems that you have extra handling for:

bitsandfoxes commented 3 weeks ago

I see. Thanks again for your input! We've seen an uptick in interest in mobile projects outside of MAUI. We'll have to see how we can prioritize this.