Skip to content

getsentry/sentry-xamarin

Repository files navigation

Sentry

Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us, check out our open positions.

Sentry SDK for Xamarin

build Discord Chat

Integrations Downloads NuGet Stable NuGet Preview
Sentry.Xamarin.Forms Downloads NuGet NuGet
Sentry.Xamarin Downloads NuGet NuGet

Sentry.Xamarin is the tool to go for Xamarin that enriches your errors with valuable data, like breadcrumbs, tags, issue grouping and more!.

Includes for all Platforms supported by Xamarin Essentials:

  • Automatic Navigation breacrumbs. (Xamarin.Forms)
  • Xaml warnings as breadcrumbs. (Xamarin.Forms)
  • Simulator flag.
  • Device manufacturer.
  • Device model.
  • Operational system name and version.
  • Screen information (Pixel density and resolution).
  • Connectivity status.

Additionaly, Android and IOS will include additional information:

  • Free Internal memory (Android/iOS).
  • Total RAM (Android/iOS).
  • CPU model (Android).

BEFORE

Screenshot of Sentry before applying Sentry.Xamarin

AFTER

Screenshot of Sentry after applying Sentry.Xamarin

Setup

All you need to do is to initialize Xamarin integration by calling SentryXamarin.Init, and, it's recommended to start Sentry Xamarin SDK as early as possible, for an example, the start of OnCreate on MainActivity for Android, and, the top of FinishedLaunching on AppDelegate for iOS)

SentryXamarin.Init(options =>
{
    options.Dsn = "__YOUR__DSN__";
    options.AddXamarinFormsIntegration();
});

If your app uses Xamarin.Forms you can also use the package Sentry.Xamarin.Forms and initialize the SDK with additional line options.AddXamarinFormsIntegration().

Android

On your MainActivity

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
    protected override void OnCreate(Bundle savedInstanceState)
    {
        SentryXamarin.Init(options =>
        {
            options.Dsn = "__YOUR__DSN__";
            options.AddXamarinFormsIntegration();
        });
        ...

iOS

On AppDelegate.cs

public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        SentryXamarin.Init(options =>
        {
            options.Dsn = "__YOUR__DSN__";
            options.AddXamarinFormsIntegration();
        });
        ...

UWP

On App.Xaml.cs

sealed partial class App : Application
{
    protected override void OnLaunched(LaunchActivatedEventArgs e)
    {
        SentryXamarin.Init(options =>
        {
            options.Dsn = "__YOUR__DSN__";
            options.AddXamarinFormsIntegration();
        });
    ...        

Compatibility

The package requires the following versions or newer:

  • Tizen 4.0 (for Tizen)
  • Xamarin.Android 11.0 (for Android)
  • Xamarin.iOS 10.14 (for iOS)
  • Universal Windows Platform 10.0.16299 (for UWP)
  • Xamarin.Forms 4.6.0.726 (for Xamarin.Forms integration)
  • Xamarin.Essentials 1.4.0
  • Sentry 4.0.3

Resources

  • Documentation
  • Forum
  • Discord Chat
  • Stack Overflow
  • Twitter Follow