mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:28:00 +08:00
Add config and clock time contexts to sentry
This commit is contained in:
parent
843e13a471
commit
b136677bb0
@ -2,8 +2,10 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Configuration.Tracking;
|
||||
using osu.Framework.Extensions;
|
||||
@ -164,6 +166,20 @@ namespace osu.Game.Configuration
|
||||
SetDefault(OsuSetting.EditorHitAnimations, false);
|
||||
}
|
||||
|
||||
public IDictionary<OsuSetting, string> GetLoggableState() =>
|
||||
new Dictionary<OsuSetting, string>(ConfigStore.Where(kvp => !keyContainsPrivateInformation(kvp.Key)).ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToString()));
|
||||
|
||||
private static bool keyContainsPrivateInformation(OsuSetting argKey)
|
||||
{
|
||||
switch (argKey)
|
||||
{
|
||||
case OsuSetting.Token:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public OsuConfigManager(Storage storage)
|
||||
: base(storage)
|
||||
{
|
||||
|
@ -7,9 +7,12 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using Sentry;
|
||||
using Sentry.Protocol;
|
||||
|
||||
@ -24,8 +27,11 @@ namespace osu.Game.Utils
|
||||
|
||||
private readonly IDisposable? sentrySession;
|
||||
|
||||
private readonly OsuGame game;
|
||||
|
||||
public SentryLogger(OsuGame game)
|
||||
{
|
||||
this.game = game;
|
||||
sentrySession = SentrySdk.Init(options =>
|
||||
{
|
||||
// Not setting the dsn will completely disable sentry.
|
||||
@ -92,6 +98,18 @@ namespace osu.Game.Utils
|
||||
{
|
||||
Message = entry.Message,
|
||||
Level = getSentryLevel(entry.Level),
|
||||
}, scope =>
|
||||
{
|
||||
scope.Contexts[@"config"] = new
|
||||
{
|
||||
Game = game.Dependencies.Get<OsuConfigManager>().GetLoggableState()
|
||||
// TODO: add framework config here. needs some consideration on how to expose.
|
||||
};
|
||||
scope.Contexts[@"clocks"] = new
|
||||
{
|
||||
Audio = game.Dependencies.Get<MusicController>().CurrentTrack.CurrentTime,
|
||||
Game = game.Clock.CurrentTime,
|
||||
};
|
||||
});
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user