Skip to content

Commit

Permalink
Merge branch 'release/5.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
twopointzero committed Apr 9, 2020
2 parents 85fde87 + a91f579 commit 25e33cd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -135,7 +135,7 @@ Being an open source project supported only by free contribution of time, only a
- Only the latest official release package is supported, unless you've been asked to reproduce an issue with a specific pre-release package or by building from source using a specific commit.
- Only the SimpleStyle skin is supported, unless working on a pre-agreed effort to expand skinning capabilities (contact twopointzero.)
- There is no formal monitoring of, or support via, any other application or service (e.g. Discord.)
- twopointzero is present on Reddit from time to time, as [twopointzero_TJAP](https://www.reddit.com/user/twopointzero_TJAP/), but only on an informal basis.
- If, after troubleshooting, you have isolated a problem to the TJAPlayer3 software itself, please refer to the section below and open a GitHub Issue.

## Issue Tracking

Expand Down
9 changes: 9 additions & 0 deletions TJAPlayer3.Tests/ErrorReporting/ErrorReporterTests.cs
Expand Up @@ -6,6 +6,15 @@ namespace TJAPlayer3.Tests.ErrorReporting
[TestFixture]
public sealed class ErrorReporterTests
{
[Test]
[TestCase("This is only a test", "pPi+NdUkNVp81f+/9Vi7dvgVdtr6f6WpdqqjVD8ptCo=")]
public void TestToSha256InBase64(string input, string expected)
{
var actual = ErrorReporter.ToSha256InBase64(input);

Assert.That(actual, Is.EqualTo(expected));
}

[Test]
[TestCase("v0.0.0 (unknown informational version)", "development")]
[TestCase("4.8.0-update-notification.1+166.Branch.feature-update-notification.Sha.f000e042234cb00e7e03642d21bc0527603b267d", "development")]
Expand Down
18 changes: 18 additions & 0 deletions TJAPlayer3/ErrorReporting/ErrorReporter.cs
@@ -1,5 +1,7 @@
using System;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
Expand All @@ -22,11 +24,17 @@ public static void WithErrorReporting(Action action)
{
o.Dsn = new Dsn("https://d13a7e78ae024f678e110c64bbf7e7f2@sentry.io/3365560");
o.Environment = GetEnvironment(appInformationalVersion);
o.ServerName = ToSha256InBase64(Environment.MachineName);
o.ShutdownTimeout = TimeSpan.FromSeconds(5);
}))
{
try
{
SentrySdk.ConfigureScope(scope =>
{
scope.User.Username = ToSha256InBase64(Environment.UserName);
});

Application.ThreadException += (sender, args) =>
{
ReportError(args.Exception);
Expand All @@ -50,6 +58,16 @@ public static void WithErrorReporting(Action action)
}
}

public static string ToSha256InBase64(string value)
{
using (var sha256 = SHA256.Create())
{
var utf8Bytes = Encoding.UTF8.GetBytes(value);
var sha256Bytes = sha256.ComputeHash(utf8Bytes);
return Convert.ToBase64String(sha256Bytes);
}
}

public static string GetEnvironment(string informationalVersion)
{
switch (Regex.Match(informationalVersion, @"(?<=^.+?[+-])\w+").Value)
Expand Down

0 comments on commit 25e33cd

Please sign in to comment.