Search Unity

Question Analytics Not Working from Command Line Build

Discussion in 'Unity Analytics' started by unity_k78UnPubQd9P-Q, Mar 30, 2023.

  1. unity_k78UnPubQd9P-Q

    unity_k78UnPubQd9P-Q

    Joined:
    Oct 4, 2021
    Posts:
    12
    Hello,

    We recently added UGS analytics to our project, and everything is working as we expect from local editor builds. The issue arises when building from command line, which we use for autobuilds, as analytics is not working at all in these builds. We are getting a line in the command line output that says:
    [ServicesCore]: To use Unity's dashboard services, you need to link your Unity project to a project ID.
    To do this, go to Project Settings to select your organization, select your project and then link a project ID.
    You also need to make sure your organization has access to the required products.
    Visit [URL='https://dashboard.unity3d.com/']https://dashboard.unity3d.com[/URL] to sign up.
    I have been looking at the UGS CLI, but I am having trouble figuring out how / if this would help set up analytics for command line builds.
     
  2. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    Can you confirm if your editor is indeed linked to your project in dashboard?
     
  3. unity_k78UnPubQd9P-Q

    unity_k78UnPubQd9P-Q

    Joined:
    Oct 4, 2021
    Posts:
    12
    Sorry for late reply. Yes, our editor is indeed linked to the project in dashboard. Builds from editor are correctly connecting to UGS and we are getting analytic events. Not sure what steps are needed for a command line headless build.
     
  4. unity_k78UnPubQd9P-Q

    unity_k78UnPubQd9P-Q

    Joined:
    Oct 4, 2021
    Posts:
    12
    I have checked the ProjectSettings.asset file before and after a command line batchmode build, and it has the correct settings. Is it importing it wrong during a build? I have tried to debug the CloudProjectSettings.projectId during a build, but it appears to run before the buildscript imports the settings and returns an empty string.
     
    Last edited: Apr 13, 2023
  5. unity_k78UnPubQd9P-Q

    unity_k78UnPubQd9P-Q

    Joined:
    Oct 4, 2021
    Posts:
    12
    Full graphics unity editor is logged in and project settings are correct in the asset file. We are even passing valid credentials to the unity command line batchmode nographics build so that it has a valid account. We use Jenkins; is there any reason that CloudProjectSettings.projectId would get unset via command line?
     
  6. unity_Ctri

    unity_Ctri

    Unity Technologies

    Joined:
    Oct 20, 2020
    Posts:
    81
    Hey there!

    I checked with some of the engineers on this, and yes it's expected in certain circumstances.
    We do a quick security check to ensure that the logged in user has permission to access the project in question, if not then the projectId is stripped out.

    If you find yourself logged out of the Unity Hub and try to build, you'll find the behaviour is the same on your local machine.

    Double check that your Jenkins pipeline is factoring the Unity Hub & your login credentials during the build - it's not an area of my own focus so I don't have any direct pointers for where or what to look for, I'll ask around internally and see if I can connect with the correct team and update here if I find anything.
     
  7. ooxcit

    ooxcit

    Joined:
    Jul 7, 2021
    Posts:
    26
    Started getting same message using unity cloud build, our analytics don't work now.
     
  8. unity_k78UnPubQd9P-Q

    unity_k78UnPubQd9P-Q

    Joined:
    Oct 4, 2021
    Posts:
    12
    One of my coworkers found a UGS.exe buried somewhere in the docs that we can call in the jenkins build pipeline prior to the headless build call that allows us to have ugs up. Its hacky but it works. I'll see if he remembers where he found that exe.
     
  9. alytvynenko

    alytvynenko

    Joined:
    Apr 11, 2022
    Posts:
    5
    Could you tell me where I can find UGS.exe?
     
  10. unity_k78UnPubQd9P-Q

    unity_k78UnPubQd9P-Q

    Joined:
    Oct 4, 2021
    Posts:
    12
    We went to the UGS CLI github releases and downloaded the ugs-windows-x64.exe. In our buildscript we call

    "PATH_TO_EXE\ugs-windows-x64.exe" login --service-key-id <SERVICE_KEY> --secret-key-stdin <SECRET_KEY>


    After this call we make our normal unity nographics batchmode build call.
     
    Last edited: Jun 12, 2023
    alytvynenko likes this.