mirror of
https://github.com/ppy/osu
synced 2025-02-25 23:21:26 +00:00
Attach user to sentry later in startup flow
This commit is contained in:
parent
a5b454edc7
commit
3338bffce3
@ -258,6 +258,8 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
dependencies.CacheAs(this);
|
dependencies.CacheAs(this);
|
||||||
|
|
||||||
|
SentryLogger.AttachUser(API.LocalUser);
|
||||||
|
|
||||||
dependencies.Cache(osuLogo = new OsuLogo { Alpha = 0 });
|
dependencies.Cache(osuLogo = new OsuLogo { Alpha = 0 });
|
||||||
|
|
||||||
// bind config int to database RulesetInfo
|
// bind config int to database RulesetInfo
|
||||||
|
@ -125,7 +125,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
protected MusicController MusicController { get; private set; }
|
protected MusicController MusicController { get; private set; }
|
||||||
|
|
||||||
protected internal IAPIProvider API { get; protected set; }
|
protected IAPIProvider API { get; set; }
|
||||||
|
|
||||||
protected Storage Storage { get; set; }
|
protected Storage Storage { get; set; }
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
@ -19,10 +21,9 @@ namespace osu.Game.Utils
|
|||||||
{
|
{
|
||||||
private SentryClient sentry;
|
private SentryClient sentry;
|
||||||
private Scope sentryScope;
|
private Scope sentryScope;
|
||||||
private Exception lastException;
|
private Exception? lastException;
|
||||||
|
|
||||||
[UsedImplicitly]
|
private IBindable<APIUser>? localUser;
|
||||||
private readonly IBindable<APIUser> localUser;
|
|
||||||
|
|
||||||
public SentryLogger(OsuGame game)
|
public SentryLogger(OsuGame game)
|
||||||
{
|
{
|
||||||
@ -40,16 +41,21 @@ namespace osu.Game.Utils
|
|||||||
sentryScope = new Scope(options);
|
sentryScope = new Scope(options);
|
||||||
|
|
||||||
Logger.NewEntry += processLogEntry;
|
Logger.NewEntry += processLogEntry;
|
||||||
|
}
|
||||||
|
|
||||||
localUser = game.API.LocalUser.GetBoundCopy();
|
public void AttachUser(IBindable<APIUser> user)
|
||||||
localUser.BindValueChanged(user =>
|
{
|
||||||
|
Debug.Assert(localUser == null);
|
||||||
|
|
||||||
|
localUser = user.GetBoundCopy();
|
||||||
|
localUser.BindValueChanged(u =>
|
||||||
{
|
{
|
||||||
sentryScope.User = new User
|
sentryScope.User = new User
|
||||||
{
|
{
|
||||||
Username = user.NewValue.Username,
|
Username = u.NewValue.Username,
|
||||||
Id = user.NewValue.Id.ToString(),
|
Id = u.NewValue.Id.ToString(),
|
||||||
};
|
};
|
||||||
});
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processLogEntry(LogEntry entry)
|
private void processLogEntry(LogEntry entry)
|
||||||
@ -137,8 +143,6 @@ namespace osu.Game.Utils
|
|||||||
protected virtual void Dispose(bool isDisposing)
|
protected virtual void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
Logger.NewEntry -= processLogEntry;
|
Logger.NewEntry -= processLogEntry;
|
||||||
sentry = null;
|
|
||||||
sentryScope = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Loading…
Reference in New Issue
Block a user