Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Send custom event from OnApplicationQuit

Discussion in 'Unity Analytics' started by Indie Viking, Aug 11, 2015.

  1. Indie Viking

    Indie Viking

    Joined:
    Sep 12, 2013
    Posts:
    28
    Hi,
    I am testing analytics integration from the editor to the integration validator. From the OnApplicationQuit method, I am sending a custom event, but I get a NotInitialized result back (all other events is working correctly). Is this intended behavior? I thought messages the Analytics SDK cannot send would be cached and sent the next time the game is started.

    Update:
    Same thing happens when trying to send custom event from OnApplicationPause(true).
     
    Last edited: Aug 11, 2015
  2. mpinol

    mpinol

    Joined:
    Jul 29, 2015
    Posts:
    317
    Hi @Indie Viking,

    We do not allow events to occur in OnApplicationQuit/OnApplicationPause because they may not have enough time to cache the event before the application actually quits/pauses and could possibly lead to lost data.
     
  3. col000r

    col000r

    Joined:
    Mar 27, 2008
    Posts:
    698
    Did you ever find a way around this? How can I send analytics data when a user ends a session?
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Generally you would want to avoid any scripting in OnApplicationQuit as objects are in the process of being unloaded from memory. Also, keep in mind that the current Analytics dashboard would not provide insight into per-user data as you likely require, and only shows aggregated data. If you have a Pro license, then you can use Raw Data Export https://docs.unity3d.com/Manual/UnityAnalyticsRawDataExport.html