mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Update sentry SDK usage in line with more recent specifications
This commit is contained in:
@ -19,26 +19,24 @@ namespace osu.Game.Utils
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SentryLogger : IDisposable
|
public class SentryLogger : IDisposable
|
||||||
{
|
{
|
||||||
private SentryClient sentry;
|
|
||||||
private Scope sentryScope;
|
|
||||||
private Exception? lastException;
|
private Exception? lastException;
|
||||||
|
|
||||||
private IBindable<APIUser>? localUser;
|
private IBindable<APIUser>? localUser;
|
||||||
|
|
||||||
|
private readonly IDisposable? sentrySession;
|
||||||
|
|
||||||
public SentryLogger(OsuGame game)
|
public SentryLogger(OsuGame game)
|
||||||
{
|
{
|
||||||
if (!game.IsDeployedBuild) return;
|
sentrySession = SentrySdk.Init(options =>
|
||||||
|
|
||||||
var options = new SentryOptions
|
|
||||||
{
|
{
|
||||||
Dsn = "https://ad9f78529cef40ac874afb95a9aca04e@sentry.ppy.sh/2",
|
// Not setting the dsn will completely disable sentry.
|
||||||
AutoSessionTracking = true,
|
if (game.IsDeployedBuild)
|
||||||
IsEnvironmentUser = false,
|
options.Dsn = "https://ad9f78529cef40ac874afb95a9aca04e@sentry.ppy.sh/2";
|
||||||
Release = game.Version
|
|
||||||
};
|
|
||||||
|
|
||||||
sentry = new SentryClient(options);
|
options.AutoSessionTracking = true;
|
||||||
sentryScope = new Scope(options);
|
options.IsEnvironmentUser = false;
|
||||||
|
options.Release = game.Version;
|
||||||
|
});
|
||||||
|
|
||||||
Logger.NewEntry += processLogEntry;
|
Logger.NewEntry += processLogEntry;
|
||||||
}
|
}
|
||||||
@ -50,11 +48,11 @@ namespace osu.Game.Utils
|
|||||||
localUser = user.GetBoundCopy();
|
localUser = user.GetBoundCopy();
|
||||||
localUser.BindValueChanged(u =>
|
localUser.BindValueChanged(u =>
|
||||||
{
|
{
|
||||||
sentryScope.User = new User
|
SentrySdk.ConfigureScope(scope => scope.User = new User
|
||||||
{
|
{
|
||||||
Username = u.NewValue.Username,
|
Username = u.NewValue.Username,
|
||||||
Id = u.NewValue.Id.ToString(),
|
Id = u.NewValue.Id.ToString(),
|
||||||
};
|
});
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,14 +71,14 @@ namespace osu.Game.Utils
|
|||||||
|
|
||||||
lastException = exception;
|
lastException = exception;
|
||||||
|
|
||||||
sentry.CaptureEvent(new SentryEvent(exception)
|
SentrySdk.CaptureEvent(new SentryEvent(exception)
|
||||||
{
|
{
|
||||||
Message = entry.Message,
|
Message = entry.Message,
|
||||||
Level = getSentryLevel(entry.Level),
|
Level = getSentryLevel(entry.Level),
|
||||||
}, sentryScope);
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sentryScope.AddBreadcrumb(DateTimeOffset.Now, entry.Message, entry.Target.ToString(), "navigation");
|
SentrySdk.AddBreadcrumb(entry.Message, entry.Target.ToString(), "navigation");
|
||||||
}
|
}
|
||||||
|
|
||||||
private SentryLevel? getSentryLevel(LogLevel entryLevel)
|
private SentryLevel? getSentryLevel(LogLevel entryLevel)
|
||||||
@ -143,6 +141,7 @@ namespace osu.Game.Utils
|
|||||||
protected virtual void Dispose(bool isDisposing)
|
protected virtual void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
Logger.NewEntry -= processLogEntry;
|
Logger.NewEntry -= processLogEntry;
|
||||||
|
sentrySession?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Reference in New Issue
Block a user