When to call `Privacy.SetUserId`

Include the following details (edit as applicable):

  • Issue category: Lightship Maps / Semantic Segmentation / Multiplayer / Real-time Mapping-Depth / ARDK Documentation / Unity Example Package / Sample App aka ‘AR Voyage’ / ARDK Virtual Studio Tools / Developer Tools / Networking / VPS / Scanning Framework
  • Device type & OS version: Android / iOS / Other Ex. iPhone 8+ on iOS 13
  • Host machine & OS version: Mac / Windows / Linux / Other Ex. Mac on Big Sur x.x
  • Issue Environment : Unity Remote / Unity Mock / On Device / Dev Portal
  • Xcode version: 15.2
  • ARDK version: 3
  • Unity version: 2022.3.5

Description of the issue:

I can never call Privacy.SetUserId at the right time. It is either missing or too early. I am callin g it after InitalizeLoaders but it is still to early. Here is my code

using System.Collections;
using UnityEngine;
using UnityEngine.XR.Management;
using Niantic.Lightship.AR.Settings;
using UnityEngine.SceneManagement;

public class NewXRController : MonoBehaviour
{
    private void Start()
    {
        // Start the combined initialization/startup coroutine.
        StartCoroutine(StartXRCoroutine());
    }

    public IEnumerator StartXRCoroutine()
    {
        Debug.Log("Initializing XR...");
        yield return XRGeneralSettings.Instance.Manager.InitializeLoader();

        if (XRGeneralSettings.Instance.Manager.activeLoader == null)
        {
            Debug.LogError("Initializing XR Failed. Check Editor or Player log for details.");
        }
        else
        {
            Debug.Log("Starting XR...");
            try
            {
                string deviceName = SystemInfo.deviceName;
                if (string.IsNullOrEmpty(deviceName))
                    deviceName = "test-user";

                // See https://lightship.dev/docs/ardk/data_privacy/ for more details.
                PrivacyData.SetUserId(deviceName);
            }
            catch
            {
                Debug.Log("Error with lightship");
            }

            XRGeneralSettings.Instance.Manager.StartSubsystems();
            SceneManager.LoadScene("ARScene");

        }
    }


    /// <summary>
    /// Disables XR
    /// </summary>
    public static void DisableXR()
    {
        Debug.Log("Disabling XR");
        if (XRGeneralSettings.Instance.Manager.isInitializationComplete)
        {
            XRGeneralSettings.Instance.Manager.StopSubsystems();
            XRGeneralSettings.Instance.Manager.DeinitializeLoader();
        }
    }
}

It correctly initalizes XR but not lightship. If you could help that would be great