Sentry 0.0.1-preview2

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-preview2
dotnet add package Sentry --version 0.0.1-preview2
<PackageReference Include="Sentry" Version="0.0.1-preview2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sentry --version 0.0.1-preview2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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:
```csharp`
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)

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:
```csharp`
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 724 2/12/2020
2.0.2 2,258 2/8/2020
2.0.1 15,808 1/28/2020
2.0.0-beta8 5,281 1/15/2020
2.0.0-beta7 19,522 12/17/2019
2.0.0-beta6 32,840 10/31/2019
2.0.0-beta5 2,151 10/29/2019
2.0.0-beta4 26,693 9/4/2019
2.0.0-beta3 9,539 7/26/2019
2.0.0-beta2 3,668 6/9/2019
2.0.0-beta 1,952 6/4/2019
1.2.1-beta 772 5/27/2019
1.2.0 712,744 5/23/2019
1.1.3-beta4 642 5/15/2019
1.1.3-beta3 435 5/13/2019
1.1.3-beta2 2,642 3/28/2019
1.1.3-beta 3,820 2/11/2019
1.1.2 315,920 1/16/2019
1.1.2-beta 2,150 1/8/2019
1.1.1 15,547 1/5/2019
1.1.0 46,502 12/5/2018
1.0.1-beta5 1,360 12/5/2018
1.0.1-beta4 1,995 12/3/2018
1.0.1-beta3 12,720 11/15/2018
1.0.1-beta2 1,778 11/14/2018
1.0.1-beta 15,359 10/24/2018
1.0.0 138,645 10/2/2018
1.0.0-rc2 16,284 9/7/2018
1.0.0-rc 4,487 8/24/2018
0.0.1-preview5 5,346 8/5/2018
0.0.1-preview4 3,645 7/30/2018
0.0.1-preview3 3,628 7/17/2018
0.0.1-preview2 4,461 7/3/2018
0.0.1-preview1 1,377 6/28/2018
Show less