Search Unity

Question Custom User Id no longer available?

Discussion in 'Unity Analytics' started by Claytonious, Jun 30, 2022.

  1. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    We have an existing auth system with user id's. We wanted to set our custom user id as described at https://docs.unity.com/analytics/CustomUserIDSupport.html, but that page is apparently out of date because SetAnalyticsUserId no longer exists on the InitializationOptions class.

    Code (CSharp):
    1.  
    2. // This is the incorrect code shown on your documentation page
    3. var options = new InitializationOptions();
    4. options.SetAnalyticsUserId("some-user-id");
    5.  
    So how should we set a custom user id now?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    It's working for me here. I'm using Analytics 4.0.1 in this project:

    using Unity.Services.Core.Analytics;

    try
    {
    InitializationOptions options;
    options = new InitializationOptions();
    options.SetAnalyticsUserId("my_test40");
    await UnityServices.InitializeAsync(options);
    ...
     
  3. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    Same here:
    upload_2022-6-30_13-15-59.png

    Which is giving me Services Core version 1.4.0, which has no such method on InitializationOptions. Is your version of Services Core higher?
     
  4. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    Is it an extension method offered by something else one must reference?
     
  5. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    It is. I had to add a reference to Unity.Services.Core.Analytics to my asmdef and then add a using to get access to it.

    Boooo.

    Thanks for your help, though, @JeffDUnity3D .
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You're welcome! That step is not needed by default, just to confirm. It works as shown in a new project, for example.
     
  7. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    Sure, if you're not using asmdefs. Fine for smaller, starter projects.
     
    JeffDUnity3D likes this.