Collecting some more usage statistics: selected game mode, mission, submarine, content package, traitors on/off, kills

This commit is contained in:
Joonas Rikkonen
2018-07-10 14:05:27 +03:00
parent 51f2455ada
commit c7e220d222
13 changed files with 72 additions and 18 deletions
@@ -198,7 +198,8 @@ namespace Barotrauma
private static bool QuitClicked(GUIButton button, object obj) 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); SaveUtil.SaveGame(GameMain.GameSession.SavePath);
} }
@@ -211,10 +212,15 @@ namespace Barotrauma
CoroutineManager.StopCoroutines("EndCinematic"); 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(); GameMain.MainMenuScreen.Select();
//Game1.MainMenuScreen.SelectTab(null, (int)MainMenuScreen.Tabs.Main);
return true; return true;
} }
@@ -245,21 +245,16 @@ namespace Barotrauma
userStatsPrompt.Buttons[0].OnClicked += (btn, userdata) => userStatsPrompt.Buttons[0].OnClicked += (btn, userdata) =>
{ {
GameSettings.SendUserStatistics = true; GameSettings.SendUserStatistics = true;
GameAnalytics.ConfigureBuild(Version.ToString()); GameAnalyticsManager.Init();
GameAnalytics.Initialize("a3a073c20982de7c15d21e840e149122", "dbcdabf31c6481129a024df3ee6bad02aeddbab7");
return true; return true;
}; };
userStatsPrompt.Buttons[0].OnClicked += userStatsPrompt.Close; userStatsPrompt.Buttons[0].OnClicked += userStatsPrompt.Close;
userStatsPrompt.Buttons[1].OnClicked += (btn, userdata) => { GameSettings.SendUserStatistics = false; return true; }; userStatsPrompt.Buttons[1].OnClicked += (btn, userdata) => { GameSettings.SendUserStatistics = false; return true; };
userStatsPrompt.Buttons[1].OnClicked += userStatsPrompt.Close; userStatsPrompt.Buttons[1].OnClicked += userStatsPrompt.Close;
} }
else else if (GameSettings.SendUserStatistics)
{ {
if (GameSettings.SendUserStatistics) GameAnalyticsManager.Init();
{
GameAnalytics.ConfigureBuild(Version.ToString());
GameAnalytics.Initialize("a3a073c20982de7c15d21e840e149122", "dbcdabf31c6481129a024df3ee6bad02aeddbab7");
}
} }
} }
@@ -87,6 +87,9 @@ namespace Barotrauma
campaignUI.StartRound = StartRound; campaignUI.StartRound = StartRound;
campaignUI.OnLocationSelected = SelectLocation; campaignUI.OnLocationSelected = SelectLocation;
campaignUI.UpdateCharacterLists(); campaignUI.UpdateCharacterLists();
GameAnalyticsSDK.Net.GameAnalytics.SetCustomDimension01("singleplayer");
} }
public override void AddToGUIUpdateList() public override void AddToGUIUpdateList()
@@ -142,6 +142,8 @@ namespace Barotrauma
campaignSetupUI.UpdateSubList(); campaignSetupUI.UpdateSubList();
SelectTab(null, 0); SelectTab(null, 0);
GameAnalyticsSDK.Net.GameAnalytics.SetCustomDimension01("");
} }
public bool SelectTab(GUIButton button, object obj) 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); if (GameModePreset.list.Count > 0 && modeList.Selected == null) modeList.Select(0);
GameMain.Server.Voting.ResetVotes(GameMain.Server.ConnectedClients); GameMain.Server.Voting.ResetVotes(GameMain.Server.ConnectedClients);
@@ -348,6 +348,8 @@ namespace Barotrauma
} }
cam.UpdateTransform(); cam.UpdateTransform();
GameAnalyticsSDK.Net.GameAnalytics.SetCustomDimension01("editor");
} }
public override void Deselect() public override void Deselect()
@@ -75,8 +75,7 @@ namespace Barotrauma
if (GameSettings.SendUserStatistics) if (GameSettings.SendUserStatistics)
{ {
GameAnalytics.ConfigureBuild(Version.ToString()); GameAnalyticsManager.Init();
GameAnalytics.Initialize("a3a073c20982de7c15d21e840e149122", "dbcdabf31c6481129a024df3ee6bad02aeddbab7");
} }
GameScreen = new GameScreen(); GameScreen = new GameScreen();
@@ -1475,6 +1475,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Source\Characters\CharacterNetworking.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Source\Characters\CharacterNetworking.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\Characters\DamageModifier.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Source\Characters\DamageModifier.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\Events\Missions\MissionPrefab.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Source\Events\Missions\MissionPrefab.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\GameAnalyticsManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\Items\Components\Signal\AdderComponent.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Source\Items\Components\Signal\AdderComponent.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\StatusEffects\DelayedEffect.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Source\StatusEffects\DelayedEffect.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\Characters\HuskInfection.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Source\Characters\HuskInfection.cs" />
@@ -1948,8 +1948,19 @@ namespace Barotrauma
AnimController.Frozen = false; AnimController.Frozen = false;
GameServer.Log(LogName+" has died (Cause of death: "+causeOfDeath+")", ServerLog.MessageType.Attack); GameServer.Log(LogName + " has died (Cause of death: " + causeOfDeath + ")", ServerLog.MessageType.Attack);
string characterType = "Unknown";
if (this == controlled)
characterType = "Player";
else if (IsRemotePlayer)
characterType = "RemotePlayer";
else if (AIController is EnemyAIController)
characterType = "Enemy";
else if (AIController is HumanAIController)
characterType = "AICrew";
GameAnalyticsSDK.Net.GameAnalytics.AddDesignEvent("Kill:" + characterType + ":" + SpeciesName + ":" + causeOfDeath);
if (OnDeath != null) OnDeath(this, causeOfDeath); if (OnDeath != null) OnDeath(this, causeOfDeath);
KillProjSpecific(); KillProjSpecific();
@@ -0,0 +1,23 @@
using GameAnalyticsSDK.Net;
using System;
namespace Barotrauma
{
public static class GameAnalyticsManager
{
public static void Init()
{
GameAnalytics.SetEnabledInfoLog(true);
GameAnalytics.ConfigureBuild(GameMain.Version.ToString());
GameAnalytics.ConfigureAvailableCustomDimensions01("singleplayer", "multiplayer", "editor");
GameAnalytics.Initialize("a3a073c20982de7c15d21e840e149122", "9010ad9a671233b8d9610d76cec8c897d9ff3ba7");
string contentPackageName = GameMain.Config?.SelectedContentPackage?.Name;
if (!string.IsNullOrEmpty(contentPackageName))
{
GameAnalytics.AddDesignEvent("ContentPackage:" +
contentPackageName.Replace(":", "").Substring(0, Math.Min(32, contentPackageName.Length)));
}
}
}
}
@@ -228,6 +228,10 @@ namespace Barotrauma
if (GameMode != null) GameMode.MsgBox(); if (GameMode != null) GameMode.MsgBox();
GameAnalyticsSDK.Net.GameAnalytics.AddDesignEvent("Submarine:" + submarine.Name);
GameAnalyticsSDK.Net.GameAnalytics.AddProgressionEvent(GameAnalyticsSDK.Net.EGAProgressionStatus.Start,
GameMode.Name, (Mission == null ? "None" : Mission.GetType().ToString()));
#if CLIENT #if CLIENT
roundSummary = new RoundSummary(this); roundSummary = new RoundSummary(this);
@@ -239,6 +243,9 @@ namespace Barotrauma
public void EndRound(string endMessage) public void EndRound(string endMessage)
{ {
if (Mission != null) Mission.End(); if (Mission != null) Mission.End();
GameAnalyticsSDK.Net.GameAnalytics.AddProgressionEvent((Mission == null || Mission.Completed) ? GameAnalyticsSDK.Net.EGAProgressionStatus.Complete : GameAnalyticsSDK.Net.EGAProgressionStatus.Fail,
GameMode.Name, (Mission == null ? "None" : Mission.GetType().ToString()));
#if CLIENT #if CLIENT
if (roundSummary != null) if (roundSummary != null)
@@ -279,10 +279,8 @@ namespace Barotrauma
{ {
case "contentpackage": case "contentpackage":
string path = subElement.GetAttributeString("path", ""); string path = subElement.GetAttributeString("path", "");
SelectedContentPackage = ContentPackage.list.Find(cp => cp.Path == path); SelectedContentPackage = ContentPackage.list.Find(cp => cp.Path == path);
if (SelectedContentPackage == null) SelectedContentPackage = new ContentPackage(path); if (SelectedContentPackage == null) SelectedContentPackage = new ContentPackage(path);
break; break;
} }
@@ -208,6 +208,8 @@ namespace Barotrauma.Networking
GameMain.NetLobbyScreen.Select(); GameMain.NetLobbyScreen.Select();
GameMain.NetLobbyScreen.RandomizeSettings(); GameMain.NetLobbyScreen.RandomizeSettings();
started = true; started = true;
GameAnalyticsSDK.Net.GameAnalytics.AddDesignEvent("GameServer:Start");
yield return CoroutineStatus.Success; yield return CoroutineStatus.Success;
} }
@@ -1357,6 +1359,8 @@ namespace Barotrauma.Networking
} }
} }
GameAnalyticsSDK.Net.GameAnalytics.AddDesignEvent("Traitors:" + (TraitorManager == null ? "Disabled" : "Enabled"));
SendStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.GameMode.Preset, connectedClients); SendStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.GameMode.Preset, connectedClients);
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
@@ -2249,7 +2253,8 @@ namespace Barotrauma.Networking
Log("Shutting down the server...", ServerLog.MessageType.ServerMessage); Log("Shutting down the server...", ServerLog.MessageType.ServerMessage);
log.Save(); log.Save();
} }
GameAnalyticsSDK.Net.GameAnalytics.AddDesignEvent("GameServer:ShutDown");
server.Shutdown("The server has been shut down"); server.Shutdown("The server has been shut down");
} }
} }