|
|
|
|
|
|
const int k_MaxElementsInStruct = 100; |
|
|
|
const int k_MaxEventsPerHour = 100; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Stores whether each event has been registered successfully or not.
|
|
|
|
/// </summary>
|
|
|
|
"perceptionScenarioInformation", AnalyticsEventType.RuntimeAndEditor, 1, |
|
|
|
"ai.cv" |
|
|
|
"perceptionScenarioInformation", AnalyticsEventType.RuntimeAndEditor, 1 |
|
|
|
); |
|
|
|
static readonly AnalyticsEvent k_EventRunInUnitySimulation = new AnalyticsEvent( |
|
|
|
"runinunitysimulation", AnalyticsEventType.Editor, 1 |
|
|
|
|
|
|
}; |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Common
|
|
|
|
#region Helpers
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Tries to register an event and returns whether it was registered successfully. The result is also cached in
|
|
|
|
|
|
|
/// <returns>Whether the event was successfully registered/</returns>
|
|
|
|
static bool TryRegisterPerceptionAnalyticsEvent(AnalyticsEvent theEvent) |
|
|
|
{ |
|
|
|
// Make sure the event exists in the dictionary
|
|
|
|
if (!s_EventRegistrationStatus.ContainsKey(theEvent)) |
|
|
|
{ |
|
|
|
if (allEvents.Contains(theEvent)) |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// If registered previously, return true
|
|
|
|
// Try registering the event and update the dictionary accordingly
|
|
|
|
s_EventRegistrationStatus[theEvent] = true; |
|
|
|
#if UNITY_EDITOR
|
|
|
|
var status = EditorAnalytics.RegisterEventWithLimit(theEvent.name, k_MaxEventsPerHour, k_MaxElementsInStruct, k_VendorKey); |
|
|
|
|
|
|
s_EventRegistrationStatus[theEvent] &= status == AnalyticsResult.Ok; |
|
|
|
|
|
|
|
// Debug.Log($"Registering event {theEvent.name}. Operation {(s_EventRegistrationStatus[theEvent] ? "" : "un")}successful.");
|
|
|
|
|
|
|
|
return s_EventRegistrationStatus[theEvent]; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
/// <param name="data">Payload of the event.</param>
|
|
|
|
static void SendPerceptionAnalyticsEvent(AnalyticsEvent theEvent, object data) |
|
|
|
{ |
|
|
|
// Debug.Log($"Reporting {theEvent.name}.");
|
|
|
|
try |
|
|
|
{ |
|
|
|
if (theEvent.type == AnalyticsEventType.Editor || theEvent.type == AnalyticsEventType.RuntimeAndEditor) |
|
|
|
{ |
|
|
|
EditorAnalytics.SendEventWithLimit(theEvent.name, data, theEvent.versionId); |
|
|
|
} |
|
|
|
if (theEvent.type == AnalyticsEventType.Editor || theEvent.type == AnalyticsEventType.RuntimeAndEditor) |
|
|
|
{ |
|
|
|
EditorAnalytics.SendEventWithLimit(theEvent.name, data, theEvent.versionId); |
|
|
|
} |
|
|
|
#else
|
|
|
|
if (theEvent.type == AnalyticsEventType.Runtime || theEvent.type == AnalyticsEventType.RuntimeAndEditor) |
|
|
|
{ |
|
|
|
|
|
|
} |
|
|
|
catch (Exception exc) |
|
|
|
{ |
|
|
|
Debug.Log($"Unable to report ${theEvent.name}: {exc.Message}"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|