Search Unity

Bug Event's don't show up

Discussion in 'Unity Analytics' started by EgorexW, Jan 17, 2023.

  1. EgorexW

    EgorexW

    Joined:
    May 9, 2021
    Posts:
    5
    I don't know why. It has been 36h already. I can't find it in valid events either in invalid ones.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Unity.Services.Analytics;
    5. using UnityServices = Unity.Services.Core.UnityServices;
    6. using System;
    7.  
    8.  
    9. // doesn't really work, just try to use unity's analytics
    10. public class Stats : MonoBehaviour
    11. {
    12.     int enemyDamageCounter;
    13.     int playerDamageCounter;
    14.     public static Stats i;
    15.     [SerializeField] Boss enemy;
    16.     [SerializeField] Player player;
    17.     [SerializeField] Shield shield;
    18.     time = 0;
    19.  
    20.     private async void Start() {
    21.         try {
    22.             await UnityServices.InitializeAsync();
    23.             List<string> consentIdentifiers = await AnalyticsService.Instance.CheckForRequiredConsents();
    24.             Debug.Log("init");
    25.         } catch (ConsentCheckException e) {
    26.             Debug.Log("error");
    27.             // Something went wrong when checking the GeoIP, check the e.Reason and handle appropriately.
    28.         }
    29.         AnalyticsService.Instance.CustomData("Start", new Dictionary<string, object>
    30.         {
    31.             {"Enemy", enemy.ToString()},
    32.         });
    33.     }
    34.     void Awake(){
    35.         i = this;
    36.     }
    37.     void Update(){
    38.         time += Time.deltaTime;
    39.     }
    40.     // added
    41.     public void OnPlayerDamage(String cause){
    42.         Debug.Log("Player Damaged " + cause);
    43.         playerDamageCounter++;
    44.         AnalyticsService.Instance.CustomData("PlayerDamaged", new Dictionary<string, object>
    45.         {
    46.             {"Enemy", enemy.ToString()},
    47.             {"EnemyBehaviour", enemy.GetBehaviour().ToString()},
    48.             {"PlayerHealth", player.GetHealth()},
    49.             {"ShieldState", shield.GetState()},
    50.             {"Cause", cause}
    51.         });
    52.     }
    53.     // added
    54.     public void OnBehaviour(){
    55.         AnalyticsService.Instance.CustomData("Behaviour", new Dictionary<string, object>
    56.         {
    57.             {"Enemy", enemy.ToString()},
    58.             {"EnemyBehaviour", enemy.GetBehaviour().ToString()},
    59.             {"DamageDone", playerDamageCounter},
    60.             {"DamageReceived", enemyDamageCounter},
    61.         });
    62.         playerDamageCounter = 0;
    63.         enemyDamageCounter = 0;
    64.     }
    65.     // added
    66.     public void OnPlayerHeal(){
    67.         AnalyticsService.Instance.CustomData("PlayerHealed", new Dictionary<string, object>
    68.         {
    69.             {"Enemy", enemy.ToString()},
    70.             {"EnemyBehaviour", enemy.GetBehaviour().ToString()},
    71.             {"PlayerHealth", player.GetHealth()},
    72.             {"ShieldState", shield.GetState()}
    73.         });
    74.     }
    75.     // added
    76.     public void OnEnemyDamage(){
    77.         enemyDamageCounter++;
    78.         AnalyticsService.Instance.CustomData("EnemyDamaged", new Dictionary<string, object>
    79.         {
    80.             {"Enemy", enemy.ToString()},
    81.             {"EnemyBehaviour", enemy.GetBehaviour().ToString()},
    82.         });
    83.     }
    84.     // added
    85.     public void OnEnemyEnraged(){
    86.         AnalyticsService.Instance.CustomData("EnemyEnraged", new Dictionary<string, object>
    87.         {
    88.             {"Enemy", enemy.ToString()},
    89.             {"Time", time},
    90.             {"PlayerHealth", player.GetHealth()}
    91.         });
    92.     }
    93.     //added
    94.     public void OnEnd(){
    95.         AnalyticsService.Instance.CustomData("End", new Dictionary<string, object>
    96.         {
    97.             {"Enemy", enemy.ToString()},
    98.             {"WinState", enemy.GetHealth() <= 0},
    99.             {"Time", time},
    100.             {"EnemyHealth", enemy.GetHealth()},
    101.             {"PlayerHealth", player.GetHealth()}
    102.         });
    103.     }
    104. }
     
  2. EgorexW

    EgorexW

    Joined:
    May 9, 2021
    Posts:
    5
    Also, I filed a report ticket, and this part was fixed before trying to send them
    time = 0;
     
  3. EgorexW

    EgorexW

    Joined:
    May 9, 2021
    Posts:
    5
    Started working, dont know what the issue was
     
  4. RandolfKlemola

    RandolfKlemola

    Unity Technologies

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

    Thanks for reaching out to the support team. I see that you had issues receiving your events. Normally there might be a slight delay in the 1st group of events sent, but 36h is very excessive. In the data, the events have an EVENT_TIMESTAMP and also a EVENT_JSON:collectInsertedTimestamp::VARCHAR, I'm assuming there is a big gap between these 2 timestamps. EVENT_TIMESTAMP is when the event was originally recorded while the collectInsertedTimestamp is when it was actually processed.

    Let us know if you continue to run into issues like this.

    Best,
    Randy