Hi,
I am using 2022.3.30f1 and analytics 6.0.2(also tried to rollback to 5.1.1 which was installed on my older project and is working)
Using ENG US locale
i have attached a logcat screenshot of the error i am facing.
All the custom and default events are being recorded when played through the editor but nothing when building apk
Events in the screenshot are logged from bottom to top, with most recent being at top.
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Services.Analytics;
using Unity.Services.Core;
using Unity.Services.Core.Environments;
using UnityEngine;
public class UGS_Analytics : MonoBehaviour
{
[HideInInspector] public bool isInitialized = false;
[HideInInspector] public double sceneTimer = 0;
async void Start()
{
int retryCount = 6; // Number of retries
int currentAttempt = 0;
while (currentAttempt < retryCount)
{
try
{
Debug.LogError("Initializing Unity Services...");
var options = new InitializationOptions();
options.SetEnvironmentName("production");
await UnityServices.InitializeAsync(options);
Debug.LogError("Unity Services initialized successfully.");
GiveConsent(); // Get user consent according to various legislations
SetAquisitionSource();
isInitialized = true;
break; // Exit the loop if successful
}
catch (Exception e)
{
currentAttempt++;
Debug.LogError($"Error during initialization (Attempt {currentAttempt}): {e.ToString()}");
if (currentAttempt >= retryCount)
{
Debug.LogError("Max retry attempts reached. Initialization failed.");
}
else
{
Debug.LogError("Retrying initialization...");
}
}
}
}
void Update()
{
if (isInitialized)
{
sceneTimer++;
Debug.LogError($"Scene Timer updated: {sceneTimer}");
CustomEvent phaseTimeEvent = new CustomEvent("timeSpentInPhase") {
{ "Scene_ID", 0 },
{ "demoPhaseID", 0 },
{ "phaseTime", sceneTimer} };
Debug.LogError("Recording phase time event.");
AnalyticsService.Instance.RecordEvent(phaseTimeEvent);
AnalyticsService.Instance.Flush();
}
}
private void SetAquisitionSource()
{
Debug.LogError("Setting acquisition source...");
var acquisitionSource = new AcquisitionSourceEvent()
{
AcquisitionChannel = "SideQuest",
};
AnalyticsService.Instance.RecordEvent(acquisitionSource);
AnalyticsService.Instance.Flush();
Debug.LogError("Acquisition source recorded.");
}
public void GiveConsent()
{
Debug.LogError("Giving consent for data collection...");
AnalyticsService.Instance.StartDataCollection();
Debug.LogError("Consent has been provided. The SDK is now collecting data!");
}
}
this is my code after trying a lot but still failing to log any analytics event through the .apk when installed on quest2,3 devices, Am i missing something?

