mirror of https://github.com/ppy/osu
Add local user tracking to sentry reporting
This commit is contained in:
parent
09c21cde8c
commit
64cc6ebddb
|
@ -125,7 +125,7 @@ public virtual string Version
|
||||||
|
|
||||||
protected MusicController MusicController { get; private set; }
|
protected MusicController MusicController { get; private set; }
|
||||||
|
|
||||||
protected IAPIProvider API { get; set; }
|
protected internal IAPIProvider API { get; protected set; }
|
||||||
|
|
||||||
protected Storage Storage { get; set; }
|
protected Storage Storage { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using Sentry;
|
using Sentry;
|
||||||
|
|
||||||
namespace osu.Game.Utils
|
namespace osu.Game.Utils
|
||||||
|
@ -18,6 +21,9 @@ public class SentryLogger : IDisposable
|
||||||
private Scope sentryScope;
|
private Scope sentryScope;
|
||||||
private Exception lastException;
|
private Exception lastException;
|
||||||
|
|
||||||
|
[UsedImplicitly]
|
||||||
|
private readonly IBindable<APIUser> localUser;
|
||||||
|
|
||||||
public SentryLogger(OsuGame game)
|
public SentryLogger(OsuGame game)
|
||||||
{
|
{
|
||||||
if (!game.IsDeployedBuild) return;
|
if (!game.IsDeployedBuild) return;
|
||||||
|
@ -34,6 +40,16 @@ public SentryLogger(OsuGame game)
|
||||||
sentryScope = new Scope(options);
|
sentryScope = new Scope(options);
|
||||||
|
|
||||||
Logger.NewEntry += processLogEntry;
|
Logger.NewEntry += processLogEntry;
|
||||||
|
|
||||||
|
localUser = game.API.LocalUser.GetBoundCopy();
|
||||||
|
localUser.BindValueChanged(user =>
|
||||||
|
{
|
||||||
|
sentryScope.User = new User
|
||||||
|
{
|
||||||
|
Username = user.NewValue.Username,
|
||||||
|
Id = user.NewValue.Id.ToString(),
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processLogEntry(LogEntry entry)
|
private void processLogEntry(LogEntry entry)
|
||||||
|
@ -50,6 +66,7 @@ private void processLogEntry(LogEntry entry)
|
||||||
if (lastException != null && lastException.Message == exception.Message && exception.StackTrace.StartsWith(lastException.StackTrace, StringComparison.Ordinal)) return;
|
if (lastException != null && lastException.Message == exception.Message && exception.StackTrace.StartsWith(lastException.StackTrace, StringComparison.Ordinal)) return;
|
||||||
|
|
||||||
lastException = exception;
|
lastException = exception;
|
||||||
|
|
||||||
sentry.CaptureEvent(new SentryEvent(exception)
|
sentry.CaptureEvent(new SentryEvent(exception)
|
||||||
{
|
{
|
||||||
Message = entry.Message,
|
Message = entry.Message,
|
||||||
|
|
Loading…
Reference in New Issue