From 645bb43291f715ecfed9b4548b3d3ac815c95db3 Mon Sep 17 00:00:00 2001 From: Mike Lorbetske Date: Tue, 11 Apr 2017 15:51:20 -0700 Subject: [PATCH] Hook 'new' into the CLI telemetry pipeline --- src/dotnet/commands/dotnet-new/NewCommandShim.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/dotnet/commands/dotnet-new/NewCommandShim.cs b/src/dotnet/commands/dotnet-new/NewCommandShim.cs index 9aa51e860..bc06185cc 100644 --- a/src/dotnet/commands/dotnet-new/NewCommandShim.cs +++ b/src/dotnet/commands/dotnet-new/NewCommandShim.cs @@ -6,7 +6,10 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; +using Microsoft.DotNet.Cli; using Microsoft.DotNet.Cli.Utils; +using Microsoft.DotNet.Configurer; +using Microsoft.DotNet.Tools.MSBuild; using Microsoft.TemplateEngine.Abstractions; using Microsoft.TemplateEngine.Cli; using Microsoft.TemplateEngine.Edge; @@ -24,7 +27,16 @@ namespace Microsoft.DotNet.Tools.New public static int Run(string[] args) { - return New3Command.Run(CommandName, CreateHost(), new TelemetryLogger(null), FirstRun, args); + var sessionId = Environment.GetEnvironmentVariable(MSBuildForwardingApp.TelemetrySessionIdEnvironmentVariableName); + var telemetry = new Telemetry(new NuGetCacheSentinel(new CliFallbackFolderPathCalculator()), sessionId); + var logger = new TelemetryLogger((name, props, measures) => + { + if (telemetry.Enabled) + { + telemetry.TrackEvent(name, props, measures); + } + }); + return New3Command.Run(CommandName, CreateHost(), logger, FirstRun, args); } private static ITemplateEngineHost CreateHost()