// Send custom event
Dictionary<string, object> parameters = new Dictionary<string, object>()
{
{ "fabulousString", "hello there" },
{ "sparklingInt", 1337 },
{ "spectacularFloat", 0.451f },
{ "peculiarBool", true },
};
// The ‘myEvent’ event will get queued up and sent every minute
AnalyticsService.Instance.CustomData("myEvent", parameters);
// Optional - You can call Events.Flush() to send the event immediately
AnalyticsService.Instance.Flush();
As for your use-case, you could potentially do something like this, however this is untested so may need a little work.
public static void LevelStarted(int chapter, int level)
{
Dictionary<string, object> eventData = new Dictionary<string, object>();
eventData.Add("Chapter", chapter);
eventData.Add("Level", level);
eventData.Add("PlayerId", UserId);
// The ‘LevelStarted’ event will get queued up and sent every minute
AnalyticsService.Instance.CustomEvent("LevelStarted", eventData);
}
Hi there! After having UGS Analytics perfectly work for a while, I have created a new build (without any major changes related to analytics itself) - and have everything stuck. My errors during initialization:
1:
Error Unity ServicesInitializationException: The Analytics service has not been initialized. Please initialize Unity Services.
2:
Error Unity [ServicesCore]: An error occured while trying to get the project configuration for services.
3:
Error Unity Can not initialize UGS Analytics! Consent error, reason: DeserializationIssue
My UGS Analytics version from package manager is 4.4.2 (and I can’t get the docs for exactly this version)
My unity engine version is 2020.3.38f1
How I initialize:
await UnityServices.InitializeAsync();
// checking consent identifiers and showing popup, if needed - no errors here