Sentry 0.0.1-preview5

Official SDK for Sentry - Open-source error tracking that helps developers monitor and fix crashes in real time.

This is a prerelease version of Sentry.
There is a newer version of this package available.
See the version list below for details.
Install-Package Sentry -Version 0.0.1-preview5
dotnet add package Sentry --version 0.0.1-preview5
<PackageReference Include="Sentry" Version="0.0.1-preview5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sentry --version 0.0.1-preview5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Below you will find a basic introduction to the SDK and its API.

For more details, please: refer to the SDK documentation

Main features

  • Automatic Captures global unhandled exceptions (AppDomain)
  • Scope management
  • Duplicate events automatically dropped
  • Events from the same exception automatically dropped
  • Web proxy support
  • HttpClient/HttpClientHandler configuration callback
  • Compress request body
  • Event sampling opt-in
  • Event flooding protection (429 retry-after and internal bound queue)
  • DSN discovered via environment variable
  • Release (version) reported automatically
  • CLS Compliant
  • Strong named
  • SourceLink (including PDB in nuget package)
  • Device OS info sent
  • Device Runtime info sent
  • Tested on Windows, Linux and macOS
  • Tested on .NET Core, .NET Framework and Mono

Basics

Initialize the SDK:

void Main() 
{
    using (SentrySdk.Init("dsn"))
    {
        // App code
    }
}

The SDK by default will watch for unhandled exceptions in your app.
If the DSN is not explicitly passed by parameter to Init, the SDK will try to locate it via environment variable SENTRY_DSN.

To configure advanced settings, for example a proxy server:

void Main() 
{
    using (SentrySdk.Init(o =>
    {
        o.Dsn = new Dsn("dsn");
        o.Http(h =>
        {
            h.Proxy = new WebProxy("https://localhost:3128");
        });
    }))
    {
        // App code
    }
}

Capture an exception:

try
{
    throw null;
}
catch (Exception e)
{
    SentrySdk.CaptureException(e);
}

Capture a message:

SentrySdk.CaptureMessage("this just happened");

Internals/Testability

It's often the case we don't want to couple our code with static class like SentrySdk, especially to allow our code to be testable.
If that's your case, you can use 2 abstractions:

  • ISentryClient
  • IHub

The ISentryClient is responsible to queueing the event to be sent to Sentry and abstracting away the internal transport.
The IHub on the other hand, holds a client and the current scope. It in fact also implements ISentryClient and is able to dispatch calls to the right client depending on the current scope.

In order to allow different events hold different contextual data, you need to know in which scope you are in.
That's the job of the Hub. It holds the scope management as well as a client.

If all you are doing is sending events, without modification/access to the current scope, then you depend on ISentryClient. If on the other hand you would like to have access to the current scope by configuring it or binding a different client to it, etc. You'd depend on IHub.

An example using IHub for testability is SentryLogger and its unit tests SentryLoggerTests.
SentryLogger depends on IHub because it does modify the scope (through AddBreadcrumb). In case it only sent events, it should instead depend on ISentryClient

Compatibility

The packages target .NET Standard 2.0. That means it is compatible with the following versions or newer:

  • .NET Framework 4.6.1
  • .NET Core 2.0
  • Mono 5.4
  • Xamarin.Android 8.0
  • Xamarin.Mac 3.8
  • Xamarin.iOS 10.14
  • Universal Windows Platform 10.0.16299

Of those, we've tested (we run our unit/integration tests) against:

  • .NET Framework 4.6.2 on Windows (AppVeyor)
  • Mono 5.12 macOS and Linux (Travis-CI)
  • .NET Core 2.0 Windows (AppVeyor), macOS and Linux (Travis-CI)
  • .NET Core 2.1 Windows (AppVeyor), macOS and Linux (Travis-CI)

Below you will find a basic introduction to the SDK and its API.

For more details, please: refer to the SDK documentation

Main features

  • Automatic Captures global unhandled exceptions (AppDomain)
  • Scope management
  • Duplicate events automatically dropped
  • Events from the same exception automatically dropped
  • Web proxy support
  • HttpClient/HttpClientHandler configuration callback
  • Compress request body
  • Event sampling opt-in
  • Event flooding protection (429 retry-after and internal bound queue)
  • DSN discovered via environment variable
  • Release (version) reported automatically
  • CLS Compliant
  • Strong named
  • SourceLink (including PDB in nuget package)
  • Device OS info sent
  • Device Runtime info sent
  • Tested on Windows, Linux and macOS
  • Tested on .NET Core, .NET Framework and Mono

Basics

Initialize the SDK:

void Main() 
{
    using (SentrySdk.Init("dsn"))
    {
        // App code
    }
}

The SDK by default will watch for unhandled exceptions in your app.
If the DSN is not explicitly passed by parameter to Init, the SDK will try to locate it via environment variable SENTRY_DSN.

To configure advanced settings, for example a proxy server:

void Main() 
{
    using (SentrySdk.Init(o =>
    {
        o.Dsn = new Dsn("dsn");
        o.Http(h =>
        {
            h.Proxy = new WebProxy("https://localhost:3128");
        });
    }))
    {
        // App code
    }
}

Capture an exception:

try
{
    throw null;
}
catch (Exception e)
{
    SentrySdk.CaptureException(e);
}

Capture a message:

SentrySdk.CaptureMessage("this just happened");

Internals/Testability

It's often the case we don't want to couple our code with static class like SentrySdk, especially to allow our code to be testable.
If that's your case, you can use 2 abstractions:

  • ISentryClient
  • IHub

The ISentryClient is responsible to queueing the event to be sent to Sentry and abstracting away the internal transport.
The IHub on the other hand, holds a client and the current scope. It in fact also implements ISentryClient and is able to dispatch calls to the right client depending on the current scope.

In order to allow different events hold different contextual data, you need to know in which scope you are in.
That's the job of the Hub. It holds the scope management as well as a client.

If all you are doing is sending events, without modification/access to the current scope, then you depend on ISentryClient. If on the other hand you would like to have access to the current scope by configuring it or binding a different client to it, etc. You'd depend on IHub.

An example using IHub for testability is SentryLogger and its unit tests SentryLoggerTests.
SentryLogger depends on IHub because it does modify the scope (through AddBreadcrumb). In case it only sent events, it should instead depend on ISentryClient

Compatibility

The packages target .NET Standard 2.0. That means it is compatible with the following versions or newer:

  • .NET Framework 4.6.1
  • .NET Core 2.0
  • Mono 5.4
  • Xamarin.Android 8.0
  • Xamarin.Mac 3.8
  • Xamarin.iOS 10.14
  • Universal Windows Platform 10.0.16299

Of those, we've tested (we run our unit/integration tests) against:

  • .NET Framework 4.6.2 on Windows (AppVeyor)
  • Mono 5.12 macOS and Linux (Travis-CI)
  • .NET Core 2.0 Windows (AppVeyor), macOS and Linux (Travis-CI)
  • .NET Core 2.1 Windows (AppVeyor), macOS and Linux (Travis-CI)

Release Notes

Can be found at: https://github.com/getsentry/sentry-dotnet/releases

Showing the top 10 GitHub repositories that depend on Sentry:

Repository Stars
Sonarr/Sonarr
Smart PVR for newsgroup and bittorrent users.
ppy/osu
rhythm is just a *click* away!
Radarr/Radarr
A fork of Sonarr to work with movies à la Couchpotato.
lidarr/Lidarr
Looks and smells like Sonarr but made for music.
OpenCover/opencover
A code coverage tool for .NET 2 and above (WINDOWS OS only), support for 32 and 64 processes with both branch and sequence points
bombomby/optick
C++ Profiler For Games
Depressurizer/Depressurizer
A Steam library categorizing tool.
AlbertMN/AssistantComputerControl
Control your computer with your Google Home or Amazon Alexa assistant!
ProtonVPN/win-app
Official ProtonVPN Windows app
goaaats/FFXIVQuickLauncher
Custom launcher for Final Fantasy XIV

Read more about the GitHub Usage information on our documentation.

Version History

Version Downloads Last updated
2.0.3 6,742 2/12/2020
2.0.2 3,767 2/8/2020
2.0.1 20,163 1/28/2020
2.0.0-beta8 5,958 1/15/2020
2.0.0-beta7 21,116 12/17/2019
2.0.0-beta6 34,894 10/31/2019
2.0.0-beta5 2,220 10/29/2019
2.0.0-beta4 27,367 9/4/2019
2.0.0-beta3 9,792 7/26/2019
2.0.0-beta2 3,697 6/9/2019
2.0.0-beta 1,957 6/4/2019
1.2.1-beta 774 5/27/2019
1.2.0 738,132 5/23/2019
1.1.3-beta4 642 5/15/2019
1.1.3-beta3 435 5/13/2019
1.1.3-beta2 2,654 3/28/2019
1.1.3-beta 3,829 2/11/2019
1.1.2 318,584 1/16/2019
1.1.2-beta 2,167 1/8/2019
1.1.1 15,692 1/5/2019
1.1.0 47,015 12/5/2018
1.0.1-beta5 1,361 12/5/2018
1.0.1-beta4 2,001 12/3/2018
1.0.1-beta3 12,876 11/15/2018
1.0.1-beta2 1,783 11/14/2018
1.0.1-beta 15,418 10/24/2018
1.0.0 139,268 10/2/2018
1.0.0-rc2 16,502 9/7/2018
1.0.0-rc 4,493 8/24/2018
0.0.1-preview5 5,363 8/5/2018
0.0.1-preview4 3,652 7/30/2018
0.0.1-preview3 3,638 7/17/2018
0.0.1-preview2 4,466 7/3/2018
0.0.1-preview1 1,379 6/28/2018
Show less