Skip to content

Commit

Permalink
Enable sentry caching to avoid sentry writing outside of game directory
Browse files Browse the repository at this point in the history
See #31412. Probably safe enough.
  • Loading branch information
peppy committed Jan 20, 2025
1 parent c20b836 commit 6b524ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions osu.Game/OsuGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ public OsuGame(string[] args = null)

forwardGeneralLogsToNotifications();
forwardTabletLogsToNotifications();

SentryLogger = new SentryLogger(this);
}

#region IOverlayManager
Expand Down Expand Up @@ -320,6 +318,12 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
private readonly List<string> dragDropFiles = new List<string>();
private ScheduledDelegate dragDropImportSchedule;

public override void SetupLogging(Storage gameStorage, Storage cacheStorage)
{
base.SetupLogging(gameStorage, cacheStorage);
SentryLogger = new SentryLogger(this, cacheStorage);
}

public override void SetHost(GameHost host)
{
base.SetHost(host);
Expand Down
4 changes: 3 additions & 1 deletion osu.Game/Utils/SentryLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using osu.Framework.Bindables;
using osu.Framework.Configuration;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Framework.Statistics;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
Expand All @@ -36,7 +37,7 @@ public class SentryLogger : IDisposable

private readonly OsuGame game;

public SentryLogger(OsuGame game)
public SentryLogger(OsuGame game, Storage? storage = null)
{
this.game = game;

Expand All @@ -49,6 +50,7 @@ public SentryLogger(OsuGame game)
options.AutoSessionTracking = true;
options.IsEnvironmentUser = false;
options.IsGlobalModeEnabled = true;
options.CacheDirectoryPath = storage?.GetFullPath(string.Empty);
// The reported release needs to match version as reported to Sentry in .github/workflows/sentry-release.yml
options.Release = $"osu@{game.Version.Replace($@"-{OsuGameBase.BUILD_SUFFIX}", string.Empty)}";
});
Expand Down

0 comments on commit 6b524ab

Please sign in to comment.