Session Analytics: Data Access¶
It’s possible to access the information of all Events, Errors and Objectives of the Analytics module.
Important
Make sure to use
MAGES.Analytics;
namespace.Make sure to set
using Event = MAGES.Analytics.Event;
.
Events¶
This function prints all the data, of every single Event that has been performed so far.
It prints the time of the computer.
It prints the in-game time from the moment the simulation started.
It prints the name of the Event.
public void printEvents()
{
MAGESAnalytics magesAnalyticsModule = Hub.Instance.Get<MAGESAnalytics>();
foreach (var entry in magesAnalyticsModule.Events)
{
if (entry.Value is Event eventValue)
{
if (eventValue.GetTag() == "Event")
{
string[] names = eventValue.GetData<string>("Name").Split(".");
string name = names.Length > 1 ? names[1] : eventValue.GetData<string>("Name");
Debug.Log("["
+ TimeSpan.FromSeconds(eventValue.GetData<double>("Timestamp")).ToString(@"hh\:mm\:ss")
+ "] "
+ name);
}
}
}
}
Errors¶
This function prints all of the data, of every single Error that has been occurred so far.
It prints the time of the computer.
It prints the in-game time from the moment the simulation started.
It prints the name of the Error.
public void printErrors()
{
MAGESAnalytics magesAnalyticsModule = Hub.Instance.Get<MAGESAnalytics>();
foreach (var entry in magesAnalyticsModule.Events)
{
if (entry.Value is Event eventValue)
{
if (eventValue.GetTag() == "Error")
{
string[] names = eventValue.GetData<string>("Name").Split(".");
string name = names.Length > 1 ? names[1] : eventValue.GetData<string>("Name");
Debug.Log("["
+ TimeSpan.FromSeconds(eventValue.GetData<double>("Timestamp")).ToString(@"hh\:mm\:ss")
+ "] "
+ name);
}
}
}
}
Objectives¶
This function prints all of the Objectives the user has set.
public void printObjectives()
{
// Get the current session's analytics
MAGESAnalytics magesAnalyticsModule = Hub.Instance.Get<MAGESAnalytics>();
foreach (var entry in magesAnalyticsModule.Events)
{
if (entry.Value is Event eventValue)
{
if (eventValue.GetTag() == "Objective")
{
Debug.Log(eventValue.GetData<string>("Description")
+ " "
+ (eventValue.GetData<bool>("Succeeded") ? "Completed" : "Not Completed"));
}
}
}
}
Warning
Whether an objective has been completed or not is displayed only at the end of the session.
Scores¶
This function prints the Score for every single event that has been performed so far.
The initial data represents the total Score the user can get for this action.
The final Score represents the Score the user got after completing the action.
public void printScores()
{
// Get the current session's analytics
MAGESAnalytics magesAnalyticsModule = Hub.Instance.Get<MAGESAnalytics>();
foreach (var entry in magesAnalyticsModule.Events)
{
if (entry.Value is Event eventValue)
{
if (eventValue.GetTag() == "Score")
{
Debug.Log(eventValue.GetData<string>("Name") + " "
+ eventValue.GetData<float>("initial") + " "
+ eventValue.GetData<float>("final"));
}
}
}
}