|
|
|
|
|
|
#if MLA_UNITY_ANALYTICS_MODULE || !UNITY_2019_4_OR_NEWER
|
|
|
|
#define MLA_UNITY_ANALYTICS_MODULE_ENABLED
|
|
|
|
#endif
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Diagnostics; |
|
|
|
|
|
|
#if MLA_UNITY_ANALYTICS_MODULE_ENABLED
|
|
|
|
#if MLA_UNITY_ANALYTICS_MODULE
|
|
|
|
using UnityEngine.Analytics; |
|
|
|
#if UNITY_EDITOR
|
|
|
|
using UnityEditor.Analytics; |
|
|
|
|
|
|
|
|
|
|
static bool EnableAnalytics() |
|
|
|
{ |
|
|
|
#if MLA_UNITY_ANALYTICS_MODULE_ENABLED
|
|
|
|
#if MLA_UNITY_ANALYTICS_MODULE
|
|
|
|
if (s_EventsRegistered) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
|
|
|
return s_EventsRegistered; |
|
|
|
#else
|
|
|
|
return false; |
|
|
|
#endif // MLA_UNITY_ANALYTICS_MODULE_ENABLED
|
|
|
|
#endif // MLA_UNITY_ANALYTICS_MODULE
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
/// <param name="packageVersion"></param>
|
|
|
|
[Conditional("MLA_UNITY_ANALYTICS_MODULE_ENABLED")] |
|
|
|
[Conditional("MLA_UNITY_ANALYTICS_MODULE")] |
|
|
|
public static void SetTrainerInformation(string packageVersion, string communicationVersion) |
|
|
|
{ |
|
|
|
s_TrainerPackageVersion = packageVersion; |
|
|
|
|
|
|
public static bool IsAnalyticsEnabled() |
|
|
|
{ |
|
|
|
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE_ENABLED
|
|
|
|
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE
|
|
|
|
return EditorAnalytics.enabled; |
|
|
|
#else
|
|
|
|
return false; |
|
|
|
|
|
|
[Conditional("MLA_UNITY_ANALYTICS_MODULE_ENABLED")] |
|
|
|
[Conditional("MLA_UNITY_ANALYTICS_MODULE")] |
|
|
|
public static void TrainingEnvironmentInitialized(TrainingEnvironmentInitializedEvent tbiEvent) |
|
|
|
{ |
|
|
|
if (!IsAnalyticsEnabled()) |
|
|
|
|
|
|
// Debug.Log(
|
|
|
|
// $"Would send event {k_TrainingEnvironmentInitializedEventName} with body {JsonUtility.ToJson(tbiEvent, true)}"
|
|
|
|
// );
|
|
|
|
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE_ENABLED
|
|
|
|
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE
|
|
|
|
if (AnalyticsUtils.s_SendEditorAnalytics) |
|
|
|
{ |
|
|
|
EditorAnalytics.SendEventWithLimit(k_TrainingEnvironmentInitializedEventName, tbiEvent); |
|
|
|
|
|
|
|
|
|
|
[Conditional("MLA_UNITY_ANALYTICS_MODULE_ENABLED")] |
|
|
|
[Conditional("MLA_UNITY_ANALYTICS_MODULE")] |
|
|
|
public static void RemotePolicyInitialized( |
|
|
|
string fullyQualifiedBehaviorName, |
|
|
|
IList<ISensor> sensors, |
|
|
|
|
|
|
// Debug.Log(
|
|
|
|
// $"Would send event {k_RemotePolicyInitializedEventName} with body {JsonUtility.ToJson(data, true)}"
|
|
|
|
// );
|
|
|
|
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE_ENABLED
|
|
|
|
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE
|
|
|
|
if (AnalyticsUtils.s_SendEditorAnalytics) |
|
|
|
{ |
|
|
|
EditorAnalytics.SendEventWithLimit(k_RemotePolicyInitializedEventName, data); |
|
|
|
|
|
|
return fullyQualifiedBehaviorName.Substring(0, lastQuestionIndex); |
|
|
|
} |
|
|
|
|
|
|
|
[Conditional("MLA_UNITY_ANALYTICS_MODULE_ENABLED")] |
|
|
|
[Conditional("MLA_UNITY_ANALYTICS_MODULE")] |
|
|
|
public static void TrainingBehaviorInitialized(TrainingBehaviorInitializedEvent tbiEvent) |
|
|
|
{ |
|
|
|
if (!IsAnalyticsEnabled()) |
|
|
|
|
|
|
// Debug.Log(
|
|
|
|
// $"Would send event {k_TrainingBehaviorInitializedEventName} with body {JsonUtility.ToJson(tbiEvent, true)}"
|
|
|
|
// );
|
|
|
|
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE_ENABLED
|
|
|
|
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE
|
|
|
|
if (AnalyticsUtils.s_SendEditorAnalytics) |
|
|
|
{ |
|
|
|
EditorAnalytics.SendEventWithLimit(k_TrainingBehaviorInitializedEventName, tbiEvent); |
|
|
|