public async Task <TelemetryConfigModel> Get()
        {
            if (!_telemetryOptions.IsTelemetryEnabled())
            {
                return(TelemetryConfigModel.Disabled);
            }

            var telemetryConfigModel = new TelemetryConfigModel
            {
                Client              = GetClientHash(),
                User                = GetUserHash(),
                Versions            = GetVersions(),
                User_creationDate   = GetDate(),
                User_hasAdminAccess = PrincipalInfo.HasAdminAccess
            };

            var configuration = await GetTelemetryConfiguration(telemetryConfigModel).ConfigureAwait(false);

            if (configuration == null)
            {
                return(TelemetryConfigModel.Disabled);
            }

            telemetryConfigModel.Configuration = configuration;

            return(telemetryConfigModel);
        }
        /// <summary>
        /// Gets the telemetry configuration from azure function endpoint.
        /// </summary>
        /// <returns>
        /// A dictionary containing the configuration; otherwise null if the request to
        /// the azure function failed.
        /// </returns>
        private async Task <IDictionary <string, object> > GetTelemetryConfiguration(TelemetryConfigModel telemetryConfigModel)
        {
            var endpointUrl = new Uri("https://cmsui.episerver.net/api/telemetryconfig");
            var uriBuilder  = new UriBuilder(endpointUrl);
            var query       = HttpUtility.ParseQueryString(uriBuilder.Query);

            query.Add("client", telemetryConfigModel.Client);
            query.Add("user", telemetryConfigModel.User);
            query.Add("version", telemetryConfigModel.Versions["CMS"]);

            uriBuilder.Query = query.ToString();
            var url = uriBuilder.Uri.ToString();

            try
            {
                using (var response = await GetRequestAsync(url).ConfigureAwait(false))
                    using (var content = response.Content)
                    {
                        if (!response.IsSuccessStatusCode)
                        {
                            return(null);
                        }
                        var raw = await content.ReadAsStringAsync().ConfigureAwait(false);

                        return(_objectSerializer.Deserialize <IDictionary <string, object> >(raw));
                    }
            }
            catch (HttpRequestException)
            {
                // Occurs when the request fails due to server issues or timeout.
                return(null);
            }
        }