Skip to content

Commit 27a91af

Browse files
update
Adjusting to final first pass analytics data being gathered.
1 parent fac8ae1 commit 27a91af

File tree

4 files changed

+33
-75
lines changed

4 files changed

+33
-75
lines changed

com.unity.netcode.gameobjects/Editor/Analytics/NetworkManagerAnalytics.cs

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,66 +7,41 @@
77
namespace Unity.Netcode.Editor
88
{
99
[Serializable]
10-
internal struct NetworkManagerAnalytics : IAnalytic.IData
10+
internal struct NetworkManagerAnalytics : IAnalytic.IData, IEquatable<NetworkManagerAnalytics>
1111
{
12-
public bool IsUsingMultiplayerSDK;
12+
public bool IsDistributedAuthority;
13+
public bool WasServer;
14+
public bool WasClient;
1315
public bool UsedCMBService;
14-
public string NetworkTopology;
16+
public bool IsUsingMultiplayerSDK;
1517
public string NetworkTransport;
16-
public bool PlayerPrefabSet;
17-
public bool ConnectionApproval;
18-
public int ClientConnectionBufferTimeout;
19-
public bool EnsureNetworkVariableLengthSafety;
2018
public bool EnableSceneManagement;
21-
public int LoadSceneTimeOut;
22-
public float SpawnTimeout;
23-
public bool ForceSamePrefabs;
24-
public bool RecycleNetworkIds;
25-
public float NetworkIdRecycleDelay;
26-
public int RpcHashSize;
27-
public bool EnableTimeResync;
28-
public int TimeResyncInterval;
2919
public int TickRate;
30-
public bool IsUsingMultiplayerTools;
31-
public bool NetworkMessageMetrics;
32-
public bool NetworkProfilingMetrics;
33-
public bool WasServer;
34-
public bool WasClient;
35-
public float SessionDuration;
36-
3720
public override string ToString()
3821
{
3922
var message = new StringBuilder();
23+
message.AppendLine($"{nameof(IsDistributedAuthority)}: {IsDistributedAuthority}");
4024
message.AppendLine($"{nameof(WasServer)}: {WasServer}");
41-
message.AppendLine($"{nameof(WasClient)}: {WasClient}");
42-
message.AppendLine($"{nameof(SessionDuration)}: {SessionDuration}");
43-
message.AppendLine($"{nameof(IsUsingMultiplayerSDK)}: {IsUsingMultiplayerSDK}");
25+
message.AppendLine($"{nameof(WasClient)}: {WasClient}");
4426
message.AppendLine($"{nameof(UsedCMBService)}: {UsedCMBService}");
45-
message.AppendLine($"{nameof(NetworkTopology)}: {NetworkTopology}");
27+
message.AppendLine($"{nameof(IsUsingMultiplayerSDK)}: {IsUsingMultiplayerSDK}");
4628
message.AppendLine($"{nameof(NetworkTransport)}: {NetworkTransport}");
47-
message.AppendLine($"{nameof(PlayerPrefabSet)}: {PlayerPrefabSet}");
48-
message.AppendLine($"{nameof(ConnectionApproval)}: {ConnectionApproval}");
49-
message.AppendLine($"{nameof(ClientConnectionBufferTimeout)}: {ClientConnectionBufferTimeout}");
50-
message.AppendLine($"{nameof(EnsureNetworkVariableLengthSafety)}: {EnsureNetworkVariableLengthSafety}");
5129
message.AppendLine($"{nameof(EnableSceneManagement)}: {EnableSceneManagement}");
52-
message.AppendLine($"{nameof(LoadSceneTimeOut)}: {LoadSceneTimeOut}");
53-
message.AppendLine($"{nameof(SpawnTimeout)}: {SpawnTimeout}");
54-
message.AppendLine($"{nameof(ForceSamePrefabs)}: {ForceSamePrefabs}");
55-
message.AppendLine($"{nameof(RecycleNetworkIds)}: {RecycleNetworkIds}");
56-
message.AppendLine($"{nameof(NetworkIdRecycleDelay)}: {NetworkIdRecycleDelay}");
57-
message.AppendLine($"{nameof(RpcHashSize)}: {RpcHashSize}");
58-
message.AppendLine($"{nameof(EnableTimeResync)}: {EnableTimeResync}");
59-
message.AppendLine($"{nameof(TimeResyncInterval)}: {TimeResyncInterval}");
6030
message.AppendLine($"{nameof(TickRate)}: {TickRate}");
61-
message.AppendLine($"{nameof(IsUsingMultiplayerTools)}: {IsUsingMultiplayerTools}");
62-
message.AppendLine($"{nameof(NetworkMessageMetrics)}: {NetworkMessageMetrics}");
63-
message.AppendLine($"{nameof(NetworkProfilingMetrics)}: {NetworkProfilingMetrics}");
6431
return message.ToString();
6532
}
6633
internal void LogAnalytics(int sessionNumber)
6734
{
6835
Debug.Log($"{ToString()}");
6936
}
37+
38+
public bool Equals(NetworkManagerAnalytics other)
39+
{
40+
return IsDistributedAuthority == other.IsDistributedAuthority && WasServer == other.WasServer && WasClient == other.WasClient
41+
&& UsedCMBService == other.UsedCMBService && IsUsingMultiplayerSDK == other.IsUsingMultiplayerSDK
42+
&& EnableSceneManagement == other.EnableSceneManagement && TickRate == other.TickRate
43+
&& NetworkTransport.Equals(other.NetworkTransport);
44+
}
7045
}
7146
}
7247
#endif

com.unity.netcode.gameobjects/Editor/Analytics/NetworkManagerAnalyticsHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Unity.Netcode.Editor
55
{
6-
[AnalyticInfo("NGO_NetworkManager", "unity.netcode", 3, 100, 1000)]
6+
[AnalyticInfo("NGO_NetworkManager", "unity.netcode", 5, 100, 1000)]
77
internal class NetworkManagerAnalyticsHandler : AnalyticsHandler<NetworkManagerAnalytics>
88
{
99
public NetworkManagerAnalyticsHandler(NetworkManagerAnalytics networkManagerAnalytics) : base(networkManagerAnalytics) { }

com.unity.netcode.gameobjects/Editor/NetworkManagerHelper.cs

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -231,25 +231,33 @@ public bool NotifyUserOfNestedNetworkManager(NetworkManager networkManager, bool
231231
public void UpdateAnalytics()
232232
{
233233
// Exit early if analytics is disabled
234-
if (!EditorAnalytics.enabled)
234+
if (!EditorAnalytics.enabled || NetworkManager.RecentSessions.Count == 0)
235235
{
236236
return;
237237
}
238238

239+
var previousAnalytics = new NetworkManagerAnalytics();
239240
// Parse through all of the recent network sessions to generate and send NetworkManager analytics
240241
for (int i = 0; i < NetworkManager.RecentSessions.Count; i++)
241242
{
242243
var networkManagerAnalytics = GetNetworkManagerAnalytics(NetworkManager.RecentSessions[i]);
244+
243245
#if ENABLE_NGO_ANALYTICS_LOGGING
244246
networkManagerAnalytics.LogAnalytics(NetworkManager.RecentSessions[i].SessionIndex);
245247
#endif
248+
// If the previous session has no changes to the configuration then skip it (only unique configurations)
249+
if (previousAnalytics.Equals(networkManagerAnalytics))
250+
{
251+
continue;
252+
}
246253
var result = EditorAnalytics.SendAnalytic(new NetworkManagerAnalyticsHandler(networkManagerAnalytics));
247254
#if ENABLE_NGO_ANALYTICS_LOGGING
248255
if (result != AnalyticsResult.Ok)
249256
{
250257
Debug.LogWarning($"[Analytics] Problem sending analytics: {result}");
251258
}
252259
#endif
260+
previousAnalytics = networkManagerAnalytics;
253261
}
254262
}
255263

@@ -261,45 +269,26 @@ public void UpdateAnalytics()
261269
private NetworkManagerAnalytics GetNetworkManagerAnalytics(NetworkManager.NetworkSessionInfo networkSession)
262270
{
263271
var multiplayerSDKInstalled = false;
264-
var multiplayerToolsInstalled = false;
265-
var networkMessageMetrics = false;
266272
#if MULTIPLAYER_SERVICES_SDK_INSTALLED
267273
multiplayerSDKInstalled = true;
268274
#endif
269-
#if MULTIPLAYER_TOOLS
270-
multiplayerToolsInstalled = true;
271-
networkMessageMetrics = networkSession.NetworkConfig.NetworkMessageMetrics;
272-
#endif
275+
#if ENABLE_NGO_ANALYTICS_LOGGING
273276
if (!networkSession.SessionStopped)
274277
{
275278
Debug.LogWarning($"Session-{networkSession.SessionIndex} was not considered stopped!");
276279
}
280+
#endif
281+
277282
var networkManagerAnalytics = new NetworkManagerAnalytics()
278283
{
279-
NetworkTopology = networkSession.NetworkConfig.NetworkTopology.ToString(),
284+
IsDistributedAuthority = networkSession.NetworkConfig.NetworkTopology == NetworkTopologyTypes.DistributedAuthority,
285+
WasServer = networkSession.WasServer,
286+
WasClient = networkSession.WasClient,
280287
UsedCMBService = networkSession.UsedCMBService,
281-
NetworkTransport = networkSession.Transport,
282288
IsUsingMultiplayerSDK = multiplayerSDKInstalled,
283-
IsUsingMultiplayerTools = multiplayerToolsInstalled,
284-
PlayerPrefabSet = networkSession.PlayerPrefab,
285-
ConnectionApproval = networkSession.NetworkConfig.ConnectionApproval,
286-
ClientConnectionBufferTimeout = networkSession.NetworkConfig.ClientConnectionBufferTimeout,
287-
EnsureNetworkVariableLengthSafety = networkSession.NetworkConfig.EnsureNetworkVariableLengthSafety,
289+
NetworkTransport = networkSession.Transport,
288290
EnableSceneManagement = networkSession.NetworkConfig.EnableSceneManagement,
289-
LoadSceneTimeOut = networkSession.NetworkConfig.LoadSceneTimeOut,
290-
SpawnTimeout = networkSession.NetworkConfig.SpawnTimeout,
291-
ForceSamePrefabs = networkSession.NetworkConfig.ForceSamePrefabs,
292-
RecycleNetworkIds = networkSession.NetworkConfig.RecycleNetworkIds,
293-
NetworkIdRecycleDelay = networkSession.NetworkConfig.NetworkIdRecycleDelay,
294-
RpcHashSize = networkSession.NetworkConfig.RpcHashSize == HashSize.VarIntFourBytes ? 4 : 8,
295-
EnableTimeResync = networkSession.NetworkConfig.EnableTimeResync,
296-
TimeResyncInterval = networkSession.NetworkConfig.TimeResyncInterval,
297291
TickRate = (int)networkSession.NetworkConfig.TickRate,
298-
NetworkMessageMetrics = networkMessageMetrics,
299-
NetworkProfilingMetrics = networkSession.NetworkConfig.NetworkProfilingMetrics,
300-
WasClient = networkSession.WasClient,
301-
WasServer = networkSession.WasServer,
302-
SessionDuration = networkSession.SessionEnd - networkSession.SessionStart,
303292
};
304293
return networkManagerAnalytics;
305294
}

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -918,11 +918,8 @@ internal struct NetworkSessionInfo
918918
{
919919
public int SessionIndex;
920920
public bool SessionStopped;
921-
public bool PlayerPrefab;
922921
public bool WasServer;
923922
public bool WasClient;
924-
public float SessionStart;
925-
public float SessionEnd;
926923
public bool UsedCMBService;
927924
public string Transport;
928925
public NetworkConfig NetworkConfig;
@@ -1078,9 +1075,7 @@ private void BeginNetworkSession()
10781075
SessionIndex = RecentSessions.Count,
10791076
WasClient = IsClient,
10801077
WasServer = IsServer,
1081-
SessionStart = Time.realtimeSinceStartup,
10821078
NetworkConfig = NetworkConfig.Copy(),
1083-
PlayerPrefab = NetworkConfig.PlayerPrefab != null,
10841079
Transport = NetworkConfig.NetworkTransport != null ? NetworkConfig.NetworkTransport.GetType().Name : "None",
10851080
};
10861081
RecentSessions.Add(newSession);
@@ -1108,7 +1103,6 @@ private void EndNetworkSession()
11081103
{
11091104
return;
11101105
}
1111-
recentSession.SessionEnd = Time.realtimeSinceStartup;
11121106
recentSession.UsedCMBService = CMBServiceConnection;
11131107
recentSession.SessionStopped = true;
11141108
RecentSessions[lastIndex] = recentSession;

0 commit comments

Comments
 (0)