|
|
|
|
|
|
|
|
|
|
namespace Unity.MLAgents.Analytics |
|
|
|
{ |
|
|
|
internal class TrainingAnalytics |
|
|
|
internal static class TrainingAnalytics |
|
|
|
{ |
|
|
|
const string k_VendorKey = "unity.ml-agents"; |
|
|
|
const string k_TrainingEnvironmentInitializedEventName = "ml_agents_training_environment_initialized"; |
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Whether or not we've registered this particular event yet
|
|
|
|
/// </summary>
|
|
|
|
static bool s_EventsRegistered = false; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Hourly limit for this event name
|
|
|
|
/// </summary>
|
|
|
|
const int k_MaxEventsPerHour = 1000; |
|
|
|
|
|
|
const int k_MaxNumberOfElements = 1000; |
|
|
|
|
|
|
|
private static bool s_SentEnvironmentInitialized; |
|
|
|
|
|
|
|
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE
|
|
|
|
/// <summary>
|
|
|
|
/// Whether or not we've registered this particular event yet
|
|
|
|
/// </summary>
|
|
|
|
static bool s_EventsRegistered = false; |
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
private static Guid s_TrainingSessionGuid; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool EnableAnalytics() |
|
|
|
internal static bool EnableAnalytics() |
|
|
|
#if MLA_UNITY_ANALYTICS_MODULE
|
|
|
|
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE
|
|
|
|
if (s_EventsRegistered) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
#else
|
|
|
|
return false; |
|
|
|
#endif // UNITY_EDITOR
|
|
|
|
} |
|
|
|
s_EventsRegistered = true; |
|
|
|
|
|
|
|
|
|
|
IList<IActuator> actuators |
|
|
|
) |
|
|
|
{ |
|
|
|
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE
|
|
|
|
if (!IsAnalyticsEnabled()) |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
// Debug.Log(
|
|
|
|
// $"Would send event {k_RemotePolicyInitializedEventName} with body {JsonUtility.ToJson(data, true)}"
|
|
|
|
// );
|
|
|
|
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE
|
|
|
|
if (AnalyticsUtils.s_SendEditorAnalytics) |
|
|
|
{ |
|
|
|
EditorAnalytics.SendEventWithLimit(k_RemotePolicyInitializedEventName, data); |
|
|
|
|
|
|
[Conditional("MLA_UNITY_ANALYTICS_MODULE")] |
|
|
|
public static void TrainingBehaviorInitialized(TrainingBehaviorInitializedEvent tbiEvent) |
|
|
|
{ |
|
|
|
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE
|
|
|
|
if (!IsAnalyticsEnabled()) |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
// Debug.Log(
|
|
|
|
// $"Would send event {k_TrainingBehaviorInitializedEventName} with body {JsonUtility.ToJson(tbiEvent, true)}"
|
|
|
|
// );
|
|
|
|
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE
|
|
|
|
#else
|
|
|
|
return; |
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|