Ejemplo n.º 1
0
        private void InitializeTelemetry()
        {
            var _logger = new SIM.Core.Logging.SitecoreLogger(Microsoft.Extensions.Logging.LogLevel.Debug);

            var kbProviderConfiguration = new KBProviderConfiguration()
            {
                BaseAddress = Constants.KBProviderBaseAddress
            };

            var kbTelemetryProvider = new KnowledgeBaseProvider(kbProviderConfiguration, true, _logger);

            Telemetry.Analytics.RegisterProvider(kbTelemetryProvider);

            try
            {
                string appVersion = string.IsNullOrEmpty(ApplicationManager.AppVersion) ? "0.0.0.0" : ApplicationManager.AppVersion;

                var telemetryEventContext = new TelemetryEventContext(
                    Constants.SitecoreInstanceManagerAppId,
                    AnalyticsHelper.GetDeviceId(ApplicationManager.TempFolder, _logger),
                    appVersion,
                    _logger
                    );

                Telemetry.Analytics.Initialize(telemetryEventContext, WindowsSettings.AppTelemetryEnabled.Value, _logger);
            }
            catch (Exception ex)
            {
                Log.Error($"'TelemetryEventContext' error occurred.{Environment.NewLine}" +
                          $"Message: {ex.Message}{Environment.NewLine}," +
                          $"{ex.StackTrace}");

                return;
            }
        }