From 7799e053695b27eb12faae3fed8976e7058e4d35 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Wed, 18 Jul 2018 12:59:17 +0300 Subject: [PATCH] GameAnalyticsManager sends the name and MD5 hash of the currently running exe (can be used to recognize code modifications that use the vanilla content package) --- .../Source/GameAnalyticsManager.cs | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/Source/GameAnalyticsManager.cs b/Barotrauma/BarotraumaShared/Source/GameAnalyticsManager.cs index c9983f7a5..81374dab6 100644 --- a/Barotrauma/BarotraumaShared/Source/GameAnalyticsManager.cs +++ b/Barotrauma/BarotraumaShared/Source/GameAnalyticsManager.cs @@ -1,5 +1,9 @@ using GameAnalyticsSDK.Net; using System; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Security.Cryptography; namespace Barotrauma { @@ -11,9 +15,31 @@ namespace Barotrauma GameAnalytics.SetEnabledInfoLog(true); #endif GameAnalytics.ConfigureBuild(GameMain.Version.ToString()); + + string exePath = Assembly.GetEntryAssembly().Location; + string exeName = null; + Md5Hash exeHash = null; + exeName = Path.GetFileNameWithoutExtension(exePath).Replace(":", ""); + var md5 = MD5.Create(); + try + { + using (var stream = File.OpenRead(exePath)) + { + exeHash = new Md5Hash(stream); + } + } + catch (Exception e) + { + DebugConsole.ThrowError("Error while calculating MD5 hash for the executable \"" + exePath + "\"", e); + } + + GameAnalytics.AddDesignEvent("Executable:" + + (string.IsNullOrEmpty(exeName) ? "Unknown" : exeName) + ":" + + ((exeHash == null) ? "Unknown" : exeHash.ShortHash)); + GameAnalytics.ConfigureAvailableCustomDimensions01("singleplayer", "multiplayer", "editor"); GameAnalytics.Initialize("a3a073c20982de7c15d21e840e149122", "9010ad9a671233b8d9610d76cec8c897d9ff3ba7"); - + string contentPackageName = GameMain.Config?.SelectedContentPackage?.Name; if (!string.IsNullOrEmpty(contentPackageName)) {