Merge branch 'analytics'

This commit is contained in:
Joonas Rikkonen
2018-07-11 10:37:33 +03:00
19 changed files with 198 additions and 18 deletions
@@ -198,7 +198,8 @@ namespace Barotrauma
private static bool QuitClicked(GUIButton button, object obj)
{
if (button.UserData as string == "save")
bool save = button.UserData as string == "save";
if (save)
{
SaveUtil.SaveGame(GameMain.GameSession.SavePath);
}
@@ -211,10 +212,15 @@ namespace Barotrauma
CoroutineManager.StopCoroutines("EndCinematic");
GameMain.GameSession = null;
if (GameMain.GameSession != null)
{
Mission mission = GameMain.GameSession.Mission;
GameAnalyticsSDK.Net.GameAnalytics.AddDesignEvent("QuitRound:" + (save ? "Save" : "NoSave"));
GameAnalyticsSDK.Net.GameAnalytics.AddDesignEvent("EndRound:" + (mission == null ? "NoMission" : (mission.Completed ? "MissionCompleted" : "MissionFailed")));
GameMain.GameSession = null;
}
GameMain.MainMenuScreen.Select();
//Game1.MainMenuScreen.SelectTab(null, (int)MainMenuScreen.Tabs.Main);
return true;
}
+30 -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,31 @@ 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;
GameAnalyticsManager.Init();
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)
{
GameAnalyticsManager.Init();
}
}
private IEnumerable<object> Load()
{
if (GameSettings.VerboseLogging)
@@ -241,6 +267,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 +500,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);
}
}
+15 -4
View File
@@ -6,6 +6,7 @@ using System.Text;
#if WINDOWS
using System.Windows.Forms;
using GameAnalyticsSDK.Net;
using Microsoft.Xna.Framework.Graphics;
#endif
@@ -135,7 +136,6 @@ namespace Barotrauma
sb.AppendLine("Barotrauma Client crash report (generated on " + DateTime.Now + ")");
sb.AppendLine("\n");
sb.AppendLine("Barotrauma seems to have crashed. Sorry for the inconvenience! ");
sb.AppendLine("If you'd like to help fix the bug that caused the crash, please send this file to the developers on the Undertow Games forums.");
sb.AppendLine("\n");
#if DEBUG
sb.AppendLine("Game version " + GameMain.Version + " (debug build)");
@@ -192,14 +192,25 @@ namespace Barotrauma
{
sb.AppendLine("[" + DebugConsole.Messages[i].Time + "] " + DebugConsole.Messages[i].Text);
}
string crashReport = sb.ToString();
sw.WriteLine(sb.ToString());
sw.WriteLine(crashReport);
sw.Close();
if (GameSettings.SaveDebugConsoleLogs) DebugConsole.SaveLogs();
CrashMessageBox( "A crash report (\"crashreport.log\") was saved in the root folder of the game."+
" If you'd like to help fix this bug, please post the report on Barotrauma's GitHub issue tracker: https://github.com/Regalis11/Barotrauma/issues/");
if (GameSettings.SendUserStatistics)
{
CrashMessageBox( "A crash report (\"crashreport.log\") was saved in the root folder of the game and sent to the developers.");
GameAnalytics.AddErrorEvent(EGAErrorSeverity.Error, crashReport);
GameAnalytics.OnStop();
}
else
{
CrashMessageBox("A crash report (\"crashreport.log\") was saved in the root folder of the game. The error was not sent to the developers because user statistics have been disabled, but" +
" if you'd like to help fix this bug, you may post it on Barotrauma's GitHub issue tracker: https://github.com/Regalis11/Barotrauma/issues/");
}
}
}
#endif
@@ -87,6 +87,9 @@ namespace Barotrauma
campaignUI.StartRound = StartRound;
campaignUI.OnLocationSelected = SelectLocation;
campaignUI.UpdateCharacterLists();
GameAnalyticsSDK.Net.GameAnalytics.SetCustomDimension01("singleplayer");
}
public override void AddToGUIUpdateList()
@@ -142,6 +142,8 @@ namespace Barotrauma
campaignSetupUI.UpdateSubList();
SelectTab(null, 0);
GameAnalyticsSDK.Net.GameAnalytics.SetCustomDimension01("");
}
public bool SelectTab(GUIButton button, object obj)
@@ -501,6 +501,8 @@ namespace Barotrauma
}
}
GameAnalyticsSDK.Net.GameAnalytics.SetCustomDimension01("multiplayer");
if (GameModePreset.list.Count > 0 && modeList.Selected == null) modeList.Select(0);
GameMain.Server.Voting.ResetVotes(GameMain.Server.ConnectedClients);
@@ -348,6 +348,8 @@ namespace Barotrauma
}
cam.UpdateTransform();
GameAnalyticsSDK.Net.GameAnalytics.SetCustomDimension01("editor");
}
public override void Deselect()