Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Bug Float parameters in custom events dont work

Discussion in 'Unity Analytics' started by arhodar, Nov 25, 2021.

  1. arhodar

    arhodar

    Joined:
    Mar 30, 2021
    Posts:
    6
    Hi, I was using the new Analytics package and I realized after hours of debugging that floating numbers are not correctly serialized when sending custom events from Unity. I have rounded the float to int (without even changing the schema in the dashboard to be still a float) and it works perfectly. Just try to send a custom event with a float/double parameter, and Unity will tell you this:

    Incorrect response, check your JSON for errors.
    Events failed to upload (code 400) -- will retry at next heartbeat.
     
  2. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    Hi, can you share the code used to send the event here so we can investigate it? Thanks.
     
  3. arhodar

    arhodar

    Joined:
    Mar 30, 2021
    Posts:
    6
    Sure, here you have the function that sends any custom event I have.

    Code (CSharp):
    1.  
    2. private static void SendEvent(string eventName, Dictionary<string, object> parameters)
    3.     {
    4.         Debug.Log($"Event name: {eventName}");
    5.         foreach (var p in parameters) Debug.Log($"Event parameter: {p.Key} - {p.Value}");
    6.         Events.CustomData(eventName, parameters);
    7.         Events.Flush();
    8.     }
    9.  
    And here is the configured event in the dashboard:



    With 2 test samples the output is the following one:

    Code (CSharp):
    1. SendEvent("tiempoSala", new Dictionary<string, object>() {
    2.    { "tiempo", 1 },
    3.    { "sala", currentScene }
    4. });


    Code (CSharp):
    1. SendEvent("tiempoSala", new Dictionary<string, object>() {
    2.    { "tiempo", 0.4f },
    3.    { "sala", currentScene }
    4. });
     
  4. arhodar

    arhodar

    Joined:
    Mar 30, 2021
    Posts:
    6
    More info: REST API works perfectly with floats, so it seems to be something internal to the event serialization in the SDK
     
  5. unity_Ctri

    unity_Ctri

    Unity Technologies

    Joined:
    Oct 20, 2020
    Posts:
    83
    Hey everyone,

    Just to update you: we verified this is a bug with the SDK.
    Our teams will pick this up with urgency and we'll update you as and when there's a change.

    We'll update you as appropriate and when there's a solution for you.
     
  6. MileyUnity

    MileyUnity

    Joined:
    Jan 3, 2020
    Posts:
    92
    Hi there,

    Sorry for the delay on this one, I've had a look at this but was unable to reproduce it locally. Could you confirm whether this is still an issue? If so I'll have to look a bit further.

    My initial thought was that the system locale may be set to Spanish where it's apparently conventional to use a comma for a decimal separator rather than a dot but when I tested this locally on macOS I was unable to reproduce this after setting my locale to Spain (internally we use StringBuilder to convert the Analytics data into Json, it appears to handle these kinds of locale discrepancies as expected at least).

    Please let me know if this is still an issue for you with the latest Analytics package or if we can close this bug :)

    Greets,
    Miley
     
  7. MileyUnity

    MileyUnity

    Joined:
    Jan 3, 2020
    Posts:
    92
    Quick update, just saw a different report come in that confirmed my suspicion, I'll be having a look at this bug today, should be easy enough to fix once I'm able to reproduce it :)
     
    unity_Ctri likes this.
  8. solmyr-fr

    solmyr-fr

    Joined:
    Jun 18, 2009
    Posts:
    24
    If it helps, I had the same problem (operating system in french if its a problem of parsing float with different culture) : all custom events containing a float parameter didnt appear in Event Browser neither in valid/invalid tab.

    Once I cast the value as integer in game and changed the parameter type to integer, those events appeared in the Event Browser
     
    Last edited: Feb 10, 2022
  9. MileyUnity

    MileyUnity

    Joined:
    Jan 3, 2020
    Posts:
    92
    Good news :), I was able to fix this issue this morning and it will be going out with the next release of Analytics. I don't yet have any ETA on when it will be released but shouldn't be too long I presume.
     
  10. YousafGrewal

    YousafGrewal

    Joined:
    Jul 5, 2018
    Posts:
    40
    I am still facing this issue what is the solution for this....:rolleyes:
     

    Attached Files:

    • robo.PNG
      robo.PNG
      File size:
      924.6 KB
      Views:
      141
  11. DavidBVal

    DavidBVal

    Joined:
    Mar 13, 2017
    Posts:
    208
    This bug is still present in Analytics 5.0 with Unity 2020.3.44. My localization is ES-es, and floats just don't work; I wasted a full day thinking it was my mistake and reconfiguring events and parameters...