Search Unity

Question Can I still not display the average elapsed time of an event?

Discussion in 'Unity Analytics' started by mrCharli3, Dec 17, 2022.

  1. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    I have several things in my game where I want to be able to time how long they take. So I created a custom event with a float parameter "elapsed". But there seems to be no good way to display the data in a readable manner.

    I want to be able to populate a graph with the average elapsed time of event "X" per day for example.

    If I cant do it using the GUI tool, is there somewhere I can read up on how I can look up custom events using the SQL explorer? It's not very intuitive and all samples you post you the pre-filled code.

    In SQL Id like to make the query: select all events named "generationTime" sort by desc. I then want to be able to view the average "elapsed" (float parameter of generationTime) per day in the table.
     
    Last edited: Dec 17, 2022
  2. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    397
    Should be something like:
    SELECT avg(elapsed), EVENT_DATE FROM EVENTS WHERE EVENT_NAME = 'generationTime' GROUP BY EVENT_DATE

    But the SQL seems only a subset of sql, for example "SELECT * " is not allowed.
     
    Last edited: Dec 19, 2022
  3. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    397
    avg(elapsed) does not seem to work. How do you select the value of a custom parameter?

    Got it, its EVENT_JSON:elapsed::FLOAT

    So the SQL is:

    SELECT avg(EVENT_JSON:elapsed::FLOAT), EVENT_DATE FROM EVENTS WHERE EVENT_NAME = 'generationTime' GROUP BY EVENT_DATE
     
    Last edited: Dec 19, 2022
    mrCharli3 likes this.
  4. RandolfKlemola

    RandolfKlemola

    Unity Technologies

    Joined:
    May 1, 2020
    Posts:
    130
    Hello manuelgoellnitz,

    Thanks for reaching out! Sorry, we were late to the port, but it appears you've figured it out. Custom parameters are added to an event's Event JSON, when viewing the data. There is a standard parameter, msSinceLastEvent, that can be used to track time between 2 events, and there's a pre-built query in our SQL Cookbook that helps track session times if you're interested.

    AvgSessionLengthBySessionNumber

    Best,
    Randy