Added GameAnalytics framework which can be used to collect usage statistics. When starting the game for the first time, the player can select whether they want to send usage data or not. Atm only used to collect crash reports.

This commit is contained in:
Joonas Rikkonen
2018-07-10 13:40:54 +03:00
parent 846291ff54
commit 51f2455ada
9 changed files with 135 additions and 10 deletions
+35 -2
View File
@@ -9,6 +9,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using GameAnalyticsSDK.Net;
namespace Barotrauma
{
@@ -144,7 +145,7 @@ namespace Barotrauma
Timing.Accumulator = 0.0f;
fixedTime = new GameTime();
World = new World(new Vector2(0, -9.82f));
FarseerPhysics.Settings.AllowSleep = true;
FarseerPhysics.Settings.ContinuousPhysics = false;
@@ -232,6 +233,36 @@ namespace Barotrauma
loadingCoroutine = CoroutineManager.StartCoroutine(Load());
}
private void InitUserStats()
{
if (GameSettings.ShowUserStatisticsPrompt)
{
var userStatsPrompt = new GUIMessageBox(
"Do you want to help us make Barotrauma better?",
"Do you allow Barotrauma to send usage statistics and error reports to the developers? The data is anonymous, " +
"does not contain any personal information and is only used to help us diagnose issues and improve Barotrauma.",
new string[] { "Yes", "No" });
userStatsPrompt.Buttons[0].OnClicked += (btn, userdata) =>
{
GameSettings.SendUserStatistics = true;
GameAnalytics.ConfigureBuild(Version.ToString());
GameAnalytics.Initialize("a3a073c20982de7c15d21e840e149122", "dbcdabf31c6481129a024df3ee6bad02aeddbab7");
return true;
};
userStatsPrompt.Buttons[0].OnClicked += userStatsPrompt.Close;
userStatsPrompt.Buttons[1].OnClicked += (btn, userdata) => { GameSettings.SendUserStatistics = false; return true; };
userStatsPrompt.Buttons[1].OnClicked += userStatsPrompt.Close;
}
else
{
if (GameSettings.SendUserStatistics)
{
GameAnalytics.ConfigureBuild(Version.ToString());
GameAnalytics.Initialize("a3a073c20982de7c15d21e840e149122", "dbcdabf31c6481129a024df3ee6bad02aeddbab7");
}
}
}
private IEnumerable<object> Load()
{
if (GameSettings.VerboseLogging)
@@ -241,6 +272,8 @@ namespace Barotrauma
GUI.GraphicsDevice = base.GraphicsDevice;
GUI.Init(Content);
InitUserStats();
GUIComponent.Init(Window);
DebugConsole.Init(Window);
DebugConsole.Log(SelectedPackage == null ? "No content package selected" : "Content package \"" + SelectedPackage.Name + "\" selected");
@@ -472,7 +505,7 @@ namespace Barotrauma
protected override void OnExiting(object sender, EventArgs args)
{
if (NetworkMember != null) NetworkMember.Disconnect();
if (GameSettings.SendUserStatistics) GameAnalytics.OnStop();
base.OnExiting(sender, args);
}
}