diff --git a/Unity/Assets/Scripts/TH1_Logic/CrashSight/CrashSightManager.cs b/Unity/Assets/Scripts/TH1_Logic/CrashSight/CrashSightManager.cs index 03c239576..6b9314a86 100644 --- a/Unity/Assets/Scripts/TH1_Logic/CrashSight/CrashSightManager.cs +++ b/Unity/Assets/Scripts/TH1_Logic/CrashSight/CrashSightManager.cs @@ -17,6 +17,7 @@ namespace Logic.CrashSight public static CrashSightManager Instance => new CrashSightManager(); private const string CrashSightDeviceIdFallbackKey = "TH1_CrashSightDeviceId"; private static string _runtimeFallbackDeviceId; + private static ulong _reportedSteamUserId; private CrashSightManager() { } public void Initialize() @@ -31,6 +32,24 @@ namespace Logic.CrashSight CrashSightAgent.SetUserValue("DeviceId", deviceId); } + public static void UpdateSteamUserId(ulong steamUserId) + { + if (steamUserId == 0 || !CrashSightAgent.IsInitialized || _reportedSteamUserId == steamUserId) return; + + try + { + var value = steamUserId.ToString(); + CrashSightAgent.SetUserId(value); + CrashSightAgent.SetUserValue("SteamId", value); + CrashSightAgent.SetUserValue("MemberId", value); + _reportedSteamUserId = steamUserId; + } + catch (System.Exception e) + { + Debug.LogWarning($"CrashSight SetSteamUserId failed: {e.Message}"); + } + } + public static string GetCrashSightDeviceId() { try diff --git a/Unity/Assets/Scripts/TH1_Logic/Steam/SteamLobbyManager.cs b/Unity/Assets/Scripts/TH1_Logic/Steam/SteamLobbyManager.cs index dbcf5cf69..22d7fbac9 100644 --- a/Unity/Assets/Scripts/TH1_Logic/Steam/SteamLobbyManager.cs +++ b/Unity/Assets/Scripts/TH1_Logic/Steam/SteamLobbyManager.cs @@ -371,6 +371,7 @@ namespace TH1_Logic.Steam { if (!TrySteamApi("RefreshLoginStatus.GetSteamID", SteamUser.GetSteamID, out _selfID)) return; if (!TrySteamApi("RefreshLoginStatus.GetPersonaName", SteamFriends.GetPersonaName, out _selfName)) return; + CrashSightManager.UpdateSteamUserId(_selfID.m_SteamID); LogSystem.LogInfo($"Steam用户已登录: {_selfName} ({_selfID})"); } else