Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: replace SharpRaven with Sentry #296

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/GWallet.Backend/GWallet.Backend-legacy.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,20 @@
<Reference Include="System.Runtime.InteropServices.RuntimeInformation">
<HintPath>..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
</Reference>
<Reference Include="SharpRaven">
<HintPath>..\..\packages\SharpRaven.2.4.0\lib\net45\SharpRaven.dll</HintPath>
<Reference Include="Sentry">
<HintPath>..\..\packages\Sentry.4.0.3\lib\netstandard2.0\Sentry.dll</HintPath>
</Reference>
<Reference Include="System.Reflection.Metadata">
<HintPath>..\..\packages\System.Reflection.Metadata.5.0.0\lib\net461\System.Reflection.Metadata.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web">
<HintPath>..\..\packages\System.Text.Encodings.Web.5.0.1\lib\net461\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces">
<HintPath>..\..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="System.Collections.Immutable">
<HintPath>..\..\packages\System.Collections.Immutable.5.0.0\lib\net461\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Buffers">
Expand All @@ -176,10 +188,10 @@
<HintPath>..\..\packages\NBitcoin.6.0.17\lib\net461\NBitcoin.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions">
<HintPath>..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
<HintPath>..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.IO.Pipelines">
<HintPath>..\..\packages\System.IO.Pipelines.8.0.0\lib\net462\System.IO.Pipelines.dll</HintPath>
<HintPath>..\..\packages\System.IO.Pipelines.8.0.0\lib\netstandard2.0\System.IO.Pipelines.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="FSharp.Core">
Expand Down
7 changes: 1 addition & 6 deletions src/GWallet.Backend/GWallet.Backend.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@
<PackageReference Include="Nethereum" Version="0.99.0--date20240303-0535.git-f0bc8be">
<GeneratePathProperty></GeneratePathProperty>
</PackageReference>
<PackageReference Include="SharpRaven" Version="2.4.0">
<GeneratePathProperty></GeneratePathProperty>
</PackageReference>
<PackageReference Include="FSharp.Data" Version="3.0.0">
<GeneratePathProperty></GeneratePathProperty>
</PackageReference>
Expand All @@ -83,8 +80,6 @@
<PackageReference Include="FSharpx.Collections" Version="3.1.0">
<GeneratePathProperty></GeneratePathProperty>
</PackageReference>
<PackageReference Include="JsonRpcSharp" Version="0.99.0--date20240303-0338.git-d673848">
<GeneratePathProperty></GeneratePathProperty>
</PackageReference>
<PackageReference Include="Sentry" Version="4.0.3" />
</ItemGroup>
</Project>
42 changes: 17 additions & 25 deletions src/GWallet.Backend/Infrastructure.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ open System.Text
open System.Diagnostics
open System.Runtime.Serialization

open SharpRaven
open SharpRaven.Data
open Sentry

open GWallet.Backend.FSharpUtil.UwpHacks

Expand All @@ -23,7 +22,7 @@ module Infrastructure =
let md5 = System.Security.Cryptography.MD5.Create()

let private sentryUrl = "https://4d1c6170ee37412fab20f8c63a2ade24:[email protected]/187797"
let private ravenClient = RavenClient(sentryUrl, Release = VersionHelper.CURRENT_VERSION)
let private sentryClient = new SentryClient(SentryOptions(Dsn = sentryUrl, Release = VersionHelper.CURRENT_VERSION))
let private captureLock = obj()

let private GetTelemetryDir (meta: bool) =
Expand Down Expand Up @@ -60,16 +59,9 @@ module Infrastructure =
let private ReportInner (sentryEvent: SentryEvent) =
try
lock captureLock (fun _ ->
let mutable exceptionWhenReporting: Option<Exception> = None
ravenClient.ErrorOnCapture <-
fun ex -> exceptionWhenReporting <- Some ex
ravenClient.Capture sentryEvent
|> ignore<string>
match exceptionWhenReporting with
| Some ex ->
// strangely enough this cannot be raised (doesn't have any effect) in the delegate assigned to ErrorOnCapture
raise ex
| _ -> true
sentryClient.CaptureEvent sentryEvent
|> ignore<SentryId>
true
)
with
| ex ->
Expand Down Expand Up @@ -99,15 +91,15 @@ module Infrastructure =

let internal ReportMessage (message: string)
#if DEBUG
(_ : ErrorLevel)
(_ : SentryLevel)
#else
(errorLevel: ErrorLevel)
(errorLevel: SentryLevel)
#endif
: bool =
#if DEBUG
failwith message
#else
let sentryEvent = SentryEvent(SentryMessage message, Level = errorLevel)
let sentryEvent = SentryEvent(Message = SentryMessage(Message = message), Level = Nullable errorLevel)
ReportInner sentryEvent
#endif

Expand All @@ -116,13 +108,13 @@ module Infrastructure =
SPrintF2 "Recovered exception details from off-line crash at %s UTC: %s"
(marshalledEx.DateTimeUtc.ToString())
marshalledEx.FullDescription
ReportMessage exReport ErrorLevel.Fatal
ReportMessage exReport SentryLevel.Fatal

let internal ReportError (errorMessage: string): bool =
ReportMessage errorMessage ErrorLevel.Error
ReportMessage errorMessage SentryLevel.Error

let private Report (ex: Exception)
(errorLevel: ErrorLevel)
(errorLevel: SentryLevel)
: bool =

// TODO: log this in a file (log4net?), as well as printing to the console, before sending to sentry
Expand All @@ -131,16 +123,16 @@ module Infrastructure =
Flush ()

#if DEBUG
if errorLevel = ErrorLevel.Error then
if errorLevel = SentryLevel.Error then
raise ex
false
#else
try
let ev = SentryEvent(ex, Level = errorLevel)
let ev = SentryEvent(ex, Level = Nullable errorLevel)
ReportInner ev
with
| ex ->
if errorLevel = ErrorLevel.Error then
if errorLevel = SentryLevel.Error then
reraise()

//unreachable
Expand All @@ -152,10 +144,10 @@ module Infrastructure =
#endif

let ReportWarning (ex: Exception): bool =
Report ex ErrorLevel.Warning
Report ex SentryLevel.Warning

let ReportWarningMessage (warning: string): bool =
ReportMessage warning ErrorLevel.Warning
ReportMessage warning SentryLevel.Warning

let LogOrReportCrash (ex: Exception) =
#if !DEBUG
Expand All @@ -164,7 +156,7 @@ module Infrastructure =
#else
let _reported =
#endif
Report ex ErrorLevel.Fatal
Report ex SentryLevel.Fatal

#if DEBUG
|> ignore<bool>
Expand Down
8 changes: 7 additions & 1 deletion src/GWallet.Backend/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<package id="FSharpx.Collections" version="3.1.0" targetFramework="net471" />
<package id="HtmlAgilityPack" version="1.11.24" targetFramework="net471" />
<package id="JsonRpcSharp" version="0.99.0--date20240303-0338.git-d673848" targetFramework="net471" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="5.0.0" targetFramework="net461" />
<package id="Microsoft.CSharp" version="4.3.0" targetFramework="net471" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="1.0.2" targetFramework="net46" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net46" />
Expand All @@ -18,11 +19,13 @@
<package id="NETStandard.Library" version="2.0.3" targetFramework="net471" />
<package id="Newtonsoft.Json" version="13.0.2" targetFramework="net46" />
<package id="Portable.BouncyCastle" version="1.8.5.2" targetFramework="net461" />
<package id="SharpRaven" version="2.4.0" targetFramework="net46" />
<package id="Sentry" version="4.0.3" targetFramework="net461" />
<package id="System.AppContext" version="4.3.0" targetFramework="net46" />
<package id="System.Buffers" version="4.5.1" targetFramework="net471" />
<package id="System.Collections" version="4.3.0" targetFramework="net46" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net46" />
<package id="System.Collections.Immutable" version="5.0.0" targetFramework="net461" />
<package id="System.Console" version="4.3.0" targetFramework="net46" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net46" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net46" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net46" />
Expand All @@ -47,6 +50,7 @@
<package id="System.ObjectModel" version="4.3.0" targetFramework="net46" />
<package id="System.Reflection" version="4.3.0" targetFramework="net46" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net46" />
<package id="System.Reflection.Metadata" version="5.0.0" targetFramework="net461" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net46" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net46" />
<package id="System.Runtime" version="4.3.0" targetFramework="net46" />
Expand All @@ -62,6 +66,8 @@
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net46" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net46" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net46" />
<package id="System.Text.Encodings.Web" version="5.0.1" targetFramework="net461" />
<package id="System.Text.Json" version="5.0.2" targetFramework="net461" />
<package id="System.Text.RegularExpressions" version="4.3.1" targetFramework="net46" />
<package id="System.Threading" version="4.3.0" targetFramework="net46" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net46" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,23 @@
<Reference Include="FSharp.Core">
<HintPath>..\..\packages\FSharp.Core.4.7.0\lib\net45\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="SharpRaven">
<HintPath>..\..\packages\SharpRaven.2.4.0\lib\net471\SharpRaven.dll</HintPath>
<Reference Include="Sentry">
<HintPath>..\..\packages\Sentry.4.0.3\lib\netstandard2.0\Sentry.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json">
<HintPath>..\..\packages\System.Text.Json.5.0.2\lib\net461\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Reflection.Metadata">
<HintPath>..\..\packages\System.Reflection.Metadata.5.0.0\lib\net461\System.Reflection.Metadata.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web">
<HintPath>..\..\packages\System.Text.Encodings.Web.5.0.1\lib\net461\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions">
<HintPath>..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe">
<HintPath>..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Configuration" />
Expand Down
3 changes: 2 additions & 1 deletion src/GWallet.Frontend.Console/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<package id="FSharp.Core" version="4.7.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="13.0.2" targetFramework="net46" />
<package id="Portable.BouncyCastle" version="1.8.5.2" targetFramework="net461" />
<package id="SharpRaven" version="2.4.0" targetFramework="net471" />
<package id="Sentry" version="4.0.3" targetFramework="net471" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net471" />
</packages>
4 changes: 4 additions & 0 deletions src/GWallet.Frontend.ConsoleApp/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.Pipelines" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup>
Expand Down
19 changes: 17 additions & 2 deletions src/GWallet.Frontend.XF.Android/GWallet.Frontend.XF.Android.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,23 @@
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\packages\Newtonsoft.Json.13.0.2\lib\netstandard2.0\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="SharpRaven">
<HintPath>..\..\packages\SharpRaven.2.4.0\lib\netstandard2.0\SharpRaven.dll</HintPath>
<Reference Include="Sentry">
<HintPath>..\..\packages\Sentry.4.0.3\lib\netstandard2.0\Sentry.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json">
<HintPath>..\..\packages\System.Text.Json.5.0.2\lib\net461\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Reflection.Metadata">
<HintPath>..\..\packages\System.Reflection.Metadata.5.0.0\lib\net461\System.Reflection.Metadata.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web">
<HintPath>..\..\packages\System.Text.Encodings.Web.5.0.1\lib\net461\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces">
<HintPath>..\..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="System.Collections.Immutable">
<HintPath>..\..\packages\System.Collections.Immutable.5.0.0\lib\net461\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.Buffers">
<Private>True</Private>
Expand Down
2 changes: 1 addition & 1 deletion src/GWallet.Frontend.XF.Android/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<package id="NETStandard.Library" version="2.0.3" targetFramework="monoandroid90" />
<package id="Newtonsoft.Json" version="13.0.2" targetFramework="monoandroid90" />
<package id="Portable.BouncyCastle" version="1.8.5.2" targetFramework="monoandroid90" />
<package id="SharpRaven" version="2.4.0" targetFramework="monoandroid90" />
<package id="Sentry" version="4.0.3" targetFramework="monoandroid90" />
<package id="System.AppContext" version="4.3.0" targetFramework="monoandroid90" />
<package id="System.Buffers" version="4.5.1" targetFramework="monoandroid10.0" />
<package id="System.Collections" version="4.3.0" targetFramework="monoandroid90" />
Expand Down
19 changes: 17 additions & 2 deletions src/GWallet.Frontend.XF.Gtk/GWallet.Frontend.XF.Gtk.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,23 @@
<Reference Include="System.Runtime.InteropServices.RuntimeInformation">
<HintPath>..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
</Reference>
<Reference Include="SharpRaven">
<HintPath>..\..\packages\SharpRaven.2.4.0\lib\net45\SharpRaven.dll</HintPath>
<Reference Include="Sentry">
<HintPath>..\..\packages\Sentry.4.0.3\lib\netstandard2.0\Sentry.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json">
<HintPath>..\..\packages\System.Text.Json.5.0.2\lib\net461\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Reflection.Metadata">
<HintPath>..\..\packages\System.Reflection.Metadata.5.0.0\lib\net461\System.Reflection.Metadata.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web">
<HintPath>..\..\packages\System.Text.Encodings.Web.5.0.1\lib\net461\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces">
<HintPath>..\..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="System.Collections.Immutable">
<HintPath>..\..\packages\System.Collections.Immutable.5.0.0\lib\net461\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Runtime.CompilerServices.Unsafe">
Expand Down
2 changes: 1 addition & 1 deletion src/GWallet.Frontend.XF.Gtk/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<package id="Newtonsoft.Json" version="13.0.2" targetFramework="net461" />
<package id="OpenTK" version="3.0.1" targetFramework="net461" />
<package id="Portable.BouncyCastle" version="1.8.5.2" targetFramework="net461" />
<package id="SharpRaven" version="2.4.0" targetFramework="net461" />
<package id="Sentry" version="4.0.3" targetFramework="net461" />
<package id="System.Buffers" version="4.5.1" targetFramework="net471" />
<package id="System.Collections" version="4.3.0" targetFramework="net471" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net471" />
Expand Down
23 changes: 19 additions & 4 deletions src/GWallet.Frontend.XF.Mac/GWallet.Frontend.XF.Mac.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,29 @@
<Reference Include="System.Configuration.ConfigurationManager">
<HintPath>..\..\packages\System.Configuration.ConfigurationManager.4.4.0\lib\netstandard2.0\System.Configuration.ConfigurationManager.dll</HintPath>
</Reference>
<Reference Include="SharpRaven">
<HintPath>..\..\packages\SharpRaven.2.4.0\lib\netstandard2.0\SharpRaven.dll</HintPath>
<Reference Include="Sentry">
<HintPath>..\..\packages\Sentry.4.0.3\lib\netstandard2.0\Sentry.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json">
<HintPath>..\..\packages\System.Text.Json.5.0.2\lib\net461\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Reflection.Metadata">
<HintPath>..\..\packages\System.Reflection.Metadata.5.0.0\lib\net461\System.Reflection.Metadata.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web">
<HintPath>..\..\packages\System.Text.Encodings.Web.5.0.1\lib\net461\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces">
<HintPath>..\..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="System.Collections.Immutable">
<HintPath>..\..\packages\System.Collections.Immutable.5.0.0\lib\net461\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe">
<HintPath>..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Memory">
<HintPath>..\..\packages\System.Memory.4.5.4\lib\netstandard2.0\System.Memory.dll</HintPath>
<HintPath>..\..\packages\System.Memory.4.5.5\lib\netstandard2.0\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Buffers">
<HintPath>..\..\packages\System.Buffers.4.5.1\lib\netstandard2.0\System.Buffers.dll</HintPath>
Expand Down Expand Up @@ -106,7 +121,7 @@
<HintPath>..\..\packages\FSharp.Data.3.0.0\lib\netstandard2.0\FSharp.Data.dll</HintPath>
</Reference>
<Reference Include="System.IO.Pipelines">
<HintPath>..\..\packages\System.IO.Pipelines.4.5.3\lib\netstandard2.0\System.IO.Pipelines.dll</HintPath>
<HintPath>..\..\packages\System.IO.Pipelines.8.0.0\lib\netstandard2.0\System.IO.Pipelines.dll</HintPath>
</Reference>
<Reference Include="ZXingNetMobile">
<HintPath>..\..\packages\ZXing.Net.Xamarin.3.0.0--date20220902-0549.git-462686e\lib\xamarinmac20\ZXingNetMobile.dll</HintPath>
Expand Down
Loading
Loading