doc/articles/guides/raygun-monitoring.md
[!TIP] This article covers the basic setup and Uno-specific information for using Raygun with Uno. For a full description of the feature and instructions on using it, see the official .NET 6+ | Raygun documentation.
Crash reporting is crucial for developing mobile and desktop applications. It ensures you are alerted when exceptions occur, whether they are unhandled or caught exceptions you want to report. With Visual Studio App Center's retirement on the horizon, what diagnostic tool should we turn to?
Raygun provides various products, including crash reporting, real user monitoring, and application performance monitoring (APM). It supports a wide range of frameworks, including .NET.
Raygun offers a free trial, allowing you to explore its features before committing to a subscription. Follow these steps to get started:
Visit the Raygun website and sign up for an account.
Let's start with a new Uno Platform application using the default template provided by the Uno Template Wizard.
Start by creating a new Uno Platform project using your preferred development environment.
Install the Raygun package in your Uno Platform application. Use the Manage NuGet Packages option or the following dotnet CLI command:
dotnet add package Mindscape.Raygun4Net.NetCore --project [YourProjectName]
Create an instance of RaygunClient by passing it a RaygunSettings object with your application API key. You can also enable automatic catching of unhandled exceptions:
using Mindscape.Raygun4Net;
private static RaygunClient _raygunClient = new RaygunClient(new RaygunSettings()
{
ApiKey = "YOUR_API_KEY_HERE",
CatchUnhandledExceptions = true // Enable to log all unhandled exceptions
});
Replace "YOUR_API_KEY_HERE" with the actual API key provided by Raygun when you created your application.
Deploy Raygun into your production environment for optimal results. To test the integration, you can raise a test exception:
try
{
throw new Exception("Temporary example exception to send to Raygun");
}
catch (Exception ex)
{
_raygunClient.SendInBackground(ex);
}
[!IMPORTANT] If you are setting up Raygun on Wasm, you need to either enable support for multithreading (see the Wasm threading documentation for more information) or use the
SendAsyncmethod instead ofSendInBackground.
Once Raygun detects your first error event, the dashboard will automatically update, allowing you to start monitoring.