Add telemetry data points for .NET Core 2.0

This commit is contained in:
William Li 2017-06-05 20:51:58 -07:00 committed by William Lee
parent 676fe41aca
commit 081f208942
29 changed files with 1324 additions and 77 deletions

View file

@ -2,9 +2,11 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Telemetry;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Configurer;
using Microsoft.DotNet.PlatformAbstractions;
@ -43,8 +45,8 @@ namespace Microsoft.DotNet.Cli
}
catch (Exception e) when (e.ShouldBeDisplayedAsError())
{
Reporter.Error.WriteLine(CommandContext.IsVerbose()
? e.ToString().Red().Bold()
Reporter.Error.WriteLine(CommandContext.IsVerbose()
? e.ToString().Red().Bold()
: e.Message.Red().Bold());
var commandParsingException = e as CommandParsingException;
@ -101,9 +103,9 @@ namespace Microsoft.DotNet.Cli
PrintInfo();
return 0;
}
else if (IsArg(args[lastArg], "h", "help") ||
args[lastArg] == "-?" ||
args[lastArg] == "/?")
else if (IsArg(args[lastArg], "h", "help") ||
args[lastArg] == "-?" ||
args[lastArg] == "/?")
{
HelpCommand.PrintHelp();
return 0;
@ -139,11 +141,16 @@ namespace Microsoft.DotNet.Cli
if (telemetryClient == null)
{
telemetryClient = new Telemetry(firstTimeUseNoticeSentinel);
telemetryClient = new Telemetry.Telemetry(firstTimeUseNoticeSentinel);
}
TelemetryEventEntry.Subscribe(telemetryClient.TrackEvent);
TelemetryEventEntry.TelemetryFilter = new TelemetryFilter();
}
var appArgs = (lastArg + 1) >= args.Length ? Enumerable.Empty<string>() : args.Skip(lastArg + 1).ToArray();
IEnumerable<string> appArgs =
(lastArg + 1) >= args.Length
? Enumerable.Empty<string>()
: args.Skip(lastArg + 1).ToArray();
if (verbose.HasValue)
{
@ -156,12 +163,12 @@ namespace Microsoft.DotNet.Cli
command = "help";
}
telemetryClient.TrackEvent(command, null, null);
TelemetryEventEntry.TrackEvent(command, null, null);
int exitCode;
BuiltInCommandMetadata builtIn;
if (BuiltInCommandsCatalog.Commands.TryGetValue(command, out builtIn))
if (BuiltInCommandsCatalog.Commands.TryGetValue(command, out var builtIn))
{
TelemetryEventEntry.SendFiltered(Parser.Instance.ParseFrom($"dotnet {command}", appArgs.ToArray()));
exitCode = builtIn.Command(appArgs.ToArray());
}
else
@ -173,7 +180,6 @@ namespace Microsoft.DotNet.Cli
.Execute();
exitCode = result.ExitCode;
}
return exitCode;
}