Migrate from RavenSharp to the SentrySDK
This commit is contained in:
parent
f19ddb30b2
commit
989057a0b0
3 changed files with 21 additions and 21 deletions
|
@ -29,7 +29,7 @@
|
|||
<PackageReference Include="MtgApiManager.Lib" Version="1.2.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="PokeApi.NET" Version="1.1.2" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
<PackageReference Include="Sentry" Version="3.9.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Storage\*">
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<PackageReference Include="NLog" Version="4.7.2" />
|
||||
<PackageReference Include="NLog.Config" Version="4.7.2" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.0-preview2" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
<PackageReference Include="Sentry" Version="3.9.2" />
|
||||
<PackageReference Include="SumoLogic.Logging.NLog" Version="1.0.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using Geekbot.Core.Logger;
|
||||
using SharpRaven;
|
||||
using SharpRaven.Data;
|
||||
using Sentry;
|
||||
using Exception = System.Exception;
|
||||
|
||||
namespace Geekbot.Core.ErrorHandling
|
||||
|
@ -12,7 +12,6 @@ namespace Geekbot.Core.ErrorHandling
|
|||
{
|
||||
private readonly IGeekbotLogger _logger;
|
||||
private readonly Func<string> _getDefaultErrorText;
|
||||
private readonly IRavenClient _raven;
|
||||
private readonly bool _errorsInChat;
|
||||
|
||||
public ErrorHandler(IGeekbotLogger logger, RunParameters runParameters, Func<string> getDefaultErrorText)
|
||||
|
@ -22,16 +21,16 @@ namespace Geekbot.Core.ErrorHandling
|
|||
_errorsInChat = runParameters.ExposeErrors;
|
||||
|
||||
var sentryDsn = runParameters.SentryEndpoint;
|
||||
if (!string.IsNullOrEmpty(sentryDsn))
|
||||
if (string.IsNullOrEmpty(sentryDsn)) return;
|
||||
|
||||
SentrySdk.Init(o =>
|
||||
{
|
||||
_raven = new RavenClient(sentryDsn) { Release = Constants.BotVersion(), Environment = "Production" };
|
||||
o.Dsn = sentryDsn;
|
||||
o.Release = Constants.BotVersion();
|
||||
o.Environment = "Production";
|
||||
});
|
||||
_logger.Information(LogSource.Geekbot, $"Command Errors will be logged to Sentry: {sentryDsn}");
|
||||
}
|
||||
else
|
||||
{
|
||||
_raven = null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task HandleCommandException(Exception e, ICommandContext context, string errorMessage = "def")
|
||||
{
|
||||
|
@ -83,18 +82,19 @@ namespace Geekbot.Core.ErrorHandling
|
|||
|
||||
private void ReportExternal(Exception e, MessageDto errorObj)
|
||||
{
|
||||
if (_raven == null) return;
|
||||
if (!SentrySdk.IsEnabled) return;
|
||||
|
||||
var sentryEvent = new SentryEvent(e)
|
||||
{
|
||||
Tags =
|
||||
{
|
||||
["discord_server"] = errorObj.Guild.Name,
|
||||
["discord_user"] = errorObj.User.Name
|
||||
},
|
||||
Message = errorObj.Message.Content,
|
||||
Extra = errorObj
|
||||
};
|
||||
_raven.Capture(sentryEvent);
|
||||
sentryEvent.SetTag("discord_server", errorObj.Guild.Name);
|
||||
sentryEvent.SetExtra("Channel", errorObj.Channel);
|
||||
sentryEvent.SetExtra("Guild", errorObj.Guild);
|
||||
sentryEvent.SetExtra("Message", errorObj.Message);
|
||||
sentryEvent.SetExtra("User", errorObj.User);
|
||||
|
||||
SentrySdk.CaptureEvent(sentryEvent);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue