コード例 #1
0
        private bool VsTelemetryIsOptedIn(GenShell genShell)
        {
            var info = genShell.GetVSTelemetryInfo();

            _client.Context.Properties.Add(TelemetryProperties.VisualStudioEdition, info.VisualStudioEdition);
            _client.Context.Properties.Add(TelemetryProperties.VisualStudioExeVersion, info.VisualStudioExeVersion);
            _client.Context.Properties.Add(TelemetryProperties.VisualStudioCulture, info.VisualStudioCulture);
            _client.Context.Properties.Add(TelemetryProperties.VisualStudioManifestId, info.VisualStudioManifestId);

            return(info.OptedIn);
        }
コード例 #2
0
        public void IntializeTelemetryClient(GenShell genShell)
        {
            if (_client != null)
            {
                return;
            }

            var config = TelemetryConfiguration.CreateDefault();

            try
            {
                config.InstrumentationKey = _currentConfig.RemoteTelemetryKey;

                var vstelemetryInfo = genShell.GetVSTelemetryInfo();
                if (vstelemetryInfo.OptedIn && RemoteKeyAvailable())
                {
                    if (!string.IsNullOrEmpty(_currentConfig.CustomTelemetryEndpoint))
                    {
                        config.TelemetryChannel.EndpointAddress = _currentConfig.CustomTelemetryEndpoint;
                    }

                    IsEnabled = true;
#if DEBUG
                    config.TelemetryChannel.DeveloperMode = true;
#endif
                }
                else
                {
                    IsEnabled = false;
                    config.DisableTelemetry = true;
                }

                _client = new TelemetryClient(config);
                SetSessionData();
                SetVSTelemetryInfo(vstelemetryInfo);

                _client.TrackEvent(TelemetryEvents.SessionStart);
            }
            catch (Exception ex)
            {
                IsEnabled = false;
                config.DisableTelemetry = true;

                Trace.TraceError($"Exception instantiating TelemetryClient:\n\r{ex}");
            }
        }