Analytics using production environment instead of custom environment

I've created 2 extra environments, Dev and Release. When the game starts it calls this code:

private async void Initialize()
        {
            try
            {
                var options = new InitializationOptions();

                // ReSharper disable once ConvertToConstant.Local
                var environment = Dev;

#if ENVIRONMENT_RELEASE_PRODUCTION
                environment = Release;
#endif

                options.SetEnvironmentName(environment);
                await UnityServices.InitializeAsync(options);

                _isInitialized = true;

                SetupSubscriptions();
            }
            catch (Exception exception)
            {
                // An error occured during services initialization.
                Debug.LogError($"Failed to initialized Services {exception}");
            }
        }

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?

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.

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.

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?

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.

7782981--982119--chrome_yrIIOYhSxi.png 7782981--982116--chrome_KWnVNZEfVx.png 7782981--982122--chrome_wels4WOPP9.png

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.

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.

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.

@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?

Nothing from users. The lack of any custom events coming through on production is concerning. I double checked that the custom events are enabled.

Find out for sure using Charles Proxy, it’s a free download for testing https://support.unity.com/hc/en-us/articles/115002917683-Using-Charles-Proxy-with-Unity

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.

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
// Unity - Scripting API: CrashReporting.CrashReportingSettings.captureEditorExceptions
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);
}
}

1 Like

@JeffDUnity3D @unity_Ctri I think we’re experiencing the same problem, please check my thread too: