Crashlytics for .NET MAUI with Sentry

As .NET MAUI has been officially released, a lot of people are still holding off on using it until their favorite packages are updated for MAUI. This includes for example frameworks for crash reports and analytis (crashlytic for short) like Firebase, App Center and the likes. Sentry seems to be one of the first to provide pre-release support for .NET MAUI. Here’s a quick guide on how you can set up Sentry in your .NET MAUI app.

Create Sentry project

Visit sentry.io, create a trial account and create a project. Take note of the DSN number in the sample, as you’ll need this in your MAUI project.

Configure MAUI project

In your .NET MAUI project, search for and install the Sentry.Maui package (make sure you’ve checked the pre-release box):

Sentry.Maui NuGet package.

In your MauiProgram.cs file, edit the builder code and add the .UseSentry()-method with the configuration that was provided when you created your Sentry project:

builder
	.UseMauiApp<App>()
	.UseSentry(options =>
	{
            options.Dsn = "https://xxxxxx@xxxxx.ingest.sentry.io/xxxxxxx";
        })
	...

To test your configuration, add this to a constructor or a click event handler:

SentrySdk.CaptureMessage("Hello Sentry");

Run the code and check your Sentry dashboard. There should now be a registered issue under “Issues” from the left-hand menu:

Registered issues in Sentry console.

This was a very simple way of showing how you can get started with Sentry in your .NET MAUI code. Sentry provides a lot of great options where you can track custom events, messages, even user feedback and more. To track performance you have to do some manual work at this time, but this will hopefully be fixed in a later release.

I hope this was helpful and I hope you check out and explore the Sentry documentation for .NET MAUI and all their offerings!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.