Hello,
We tried to create a custom event at the end of a user’s session to record how much player use their energy in one session.
- This event is not fired when player end their session, instead they are fired when player begin a new session after that but it’s not recorded, instead it says “Analytic not initialized” ?
- Also, this custom event somehow is fired every time the game went to background even just for one second, instead of “went idle for 30 minutes” as Unity Analytic would normally count one session?
Appreciate any advice.
Code
void OnApplicationPause (bool isPause) {
if (isPause)
RecordSessionEnd ();
}
void RecordSessionEnd () {
var staminaUsed = PlayerPrefs.GetInt (KeyConstants.SESSION_STAMINA_USE, 0);
CharacterManager.onStaminaUse -= RecordStaminaUse;
var totalStamina = 0;
foreach (var pc in CharacterManager.GetAllCharacters ()) {
if (pc.boughtStatus)
totalStamina += pc.GetStamina ();
}
Analytics.RecordSessionEnd (staminaUsed, totalStamina);
}
Thank you