Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TelemetryClient"/> class.
        /// </summary>
        public TelemetryClient()
        {
            // Only enable telemetry if the user has opted into it in Visual Studio
            TelemetryService.DefaultSession.UseVsIsOptedIn();

            if (TelemetryService.DefaultSession.IsOptedIn)
            {
                _telemetrySession = TelemetryService.DefaultSession;

                GitRepositoryInfo repositoryInfo = GitRepositoryInfo.GetRepoInfoForCurrentDirectory();

                if (repositoryInfo?.Origin != null)
                {
                    TelemetryContext context = _telemetrySession.CreateContext("GitRepository");

                    context.SharedProperties["VS.TeamFoundation.Git.OriginRemoteUrlHashV2"] = new TelemetryPiiProperty(repositoryInfo.Origin);
                }
            }
        }