How are we supposed to send custom event these days ?
The doc Record Custom Events says :
CustomEvent myEvent = new CustomEvent(“MyEvent”)
{
{ “fabulousString”, “woah!” },
{ “peculiarBool”, true },
{ “sparklingInt”, 1337 },
{ “spectacularFloat”, 313.37f }
};
AnalyticsService.Instance.RecordEvent(myEvent);
but CustomEvent does not have a string constructor for name in the latest version if the Analytics package… (5.1.1 April 18, 2024)
AnalyticsService.Instance.RecordEvent(“MyCustomEvent”);
seems to work.
but how to send parameters ?
Is the doc out of date ?
Here’s how it needs to be done :
Unity.Services.Analytics.CustomEvent endRunEvent = new Unity.Services.Analytics.CustomEvent(“EndRun”);
endRunEvent.Add(“runTime”, “test parameter”);
AnalyticsService.Instance.RecordEvent(endRunEvent);
Why CustomEvent does not have a Dictionary<string, object> as constructor parameter baffles me.
Why I am the one answering my own question after 3 days on the unity forum for what seems to be a core Analytics functionality baffles me even more.
@OctoSharko
I agree, the latest documentation seems broken and I had found the solution checking a forum in JAPANESE last night before finding your post here this morning. By the way did you have any problem getting the custom event displayed on the event browser? When I run my code nothing gets displayed on it (I checked all environment and both valid/invalid events tables).
I know there was a major incident affecting the main dashboard:
@hotlabs_1
The events are displayed fine in the event browser. I have to wait 5-10mn and they appear, it’s not that bad.
2 Likes