Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Analytics using production environment instead of custom environment

Discussion in 'Unity Analytics' started by StefanEdurino, Jan 5, 2022.

  1. StefanEdurino

    StefanEdurino

    Joined:
    Jun 29, 2021
    Posts:
    18
    I've created 2 extra environments, Dev and Release. When the game starts it calls this code:


    Code (CSharp):
    1. private async void Initialize()
    2.         {
    3.             try
    4.             {
    5.                 var options = new InitializationOptions();
    6.  
    7.                 // ReSharper disable once ConvertToConstant.Local
    8.                 var environment = Dev;
    9.  
    10. #if ENVIRONMENT_RELEASE_PRODUCTION
    11.                 environment = Release;
    12. #endif
    13.  
    14.                 options.SetEnvironmentName(environment);
    15.                 await UnityServices.InitializeAsync(options);
    16.  
    17.                 _isInitialized = true;
    18.                
    19.                 SetupSubscriptions();
    20.             }
    21.             catch (Exception exception)
    22.             {
    23.                 // An error occured during services initialization.
    24.                 Debug.LogError($"Failed to initialized Services {exception}");
    25.             }
    26.         }
    Now that our game is live I see that some data is going to the Release environment while the majority is still going to Production (the default environment).
    ENVIRONMENT_RELEASE_PRODUCTION is getting defined in the Unity Cloud Build process and that seems to be working for other places in the code that check for it.

    Is there something else I need to do to use a custom Environment?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    How do you know some users are using the previous environment? Keep in mind, when you upgrade, many users will continue to use the previous version of the app until they upgrade.
     
  3. StefanEdurino

    StefanEdurino

    Joined:
    Jun 29, 2021
    Posts:
    18
    I can see users with the latest version of the game showing up in Production and in my custom Environment.

    I think the issue is this my initialization code. It's not being called sometimes and that is why those users are defaulting to the Production environment instead of my custom one. The reason I think that is so is due to there being no custom events being sent on the Production environment, only on my custom environment.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You mention "I can see users with the latest version of the game showing up in Production and in my custom Environment." please share a screenshot of the data that you are referring to. Are you able to reproduce? Where is ENVIRONMENT_RELEASE_PRODUCTION defined?
     
  5. StefanEdurino

    StefanEdurino

    Joined:
    Jun 29, 2021
    Posts:
    18
    I've posted screenshots of production and release. Release is the environment that all actual users should be on. Version 1.0.2 is the latest version and they can be seen in both environments. There are a lot of UNKNOWN versions which I'm not sure of. There are many more users on Production than Release. I'm not able to reproduce the issue.

    chrome_yrIIOYhSxi.png chrome_KWnVNZEfVx.png chrome_wels4WOPP9.png
     
  6. StefanEdurino

    StefanEdurino

    Joined:
    Jun 29, 2021
    Posts:
    18
    Here's some screenshots from Event Browser. There are no custom events for production ever. SceneLoaded is a custom event which you can see under release.

    chrome_w44ZrvS60N.png chrome_CKGlOeRJNr.png
     
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Where is ENVIRONMENT_RELEASE_PRODUCTION defined? Are you saying that Cloud Build is ignoring this setting? I don't support Cloud Build if it's a build issue. At this point unfortunately there is no action we can take if you can't reproduce.
     
  8. StefanEdurino

    StefanEdurino

    Joined:
    Jun 29, 2021
    Posts:
    18
    Where is ENVIRONMENT_RELEASE_PRODUCTION defined?
    - Under Advanced Options in Cloud Build.

    I don't think Cloud Build is ignoring it as it's valid in other parts of the code.

    Thanks for the support. I will try reproduce the issue and write back here.
     
  9. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @StefanEdurino From the description of the issue, my guess is that it's a display issue on the Dashboard only (an issue at our end). Are your users complaining, or is there any other indication of the behavior, other than the dashboard reports?
     
  10. StefanEdurino

    StefanEdurino

    Joined:
    Jun 29, 2021
    Posts:
    18
    Nothing from users. The lack of any custom events coming through on production is concerning. I double checked that the custom events are enabled.
     
  11. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  12. unity_Ctri

    unity_Ctri

    Unity Technologies

    Joined:
    Oct 20, 2020
    Posts:
    81
    To build on the above, if your investigation confirms that you're sending events successfully but aren't seeing them after a few minutes on your dashboards "Event Browser" (either valid or invalid) sections, DM me a link to your event browser page and I'll dig a little deeper on the back end to see what we've received and if there's anything unexpected occuring.
     
  13. mayankgigafun

    mayankgigafun

    Joined:
    Jun 12, 2023
    Posts:
    1
    I am facing the same issue with remote config. I am using custom environment for remote config, but I am not able to fetch properties for "developement" (custom) env. It showing results for production only
    The async function I m using to set the env.

    async Task InitialiseUnityServices()
    {
    #if UNITY_EDITOR
    // https://docs.unity3d.com/ScriptRefe...eportingSettings-captureEditorExceptions.html
    CrashReportingSettings.captureEditorExceptions = false;
    #endif
    try
    {
    var options = new InitializationOptions();
    options.SetEnvironmentName(EnvironmentType.Development);
    await UnityServices.InitializeAsync(options);
    }
    catch (Exception exception)
    {
    Debug.LogError("Fatal error: Couldn't set environment with unity services");
    Debug.LogException(exception);
    }
    }
     
    hotlabs likes this.
  14. hotlabs

    hotlabs

    Joined:
    Apr 11, 2021
    Posts:
    10