CR feedback part 1

This commit is contained in:
Dan Quirk 2016-04-04 16:18:47 -07:00
parent e077b60382
commit 3e4edf1688
2 changed files with 15 additions and 10 deletions

View file

@ -8,11 +8,11 @@ namespace Microsoft.DotNet.Cli.Utils
{ {
public class Telemetry : ITelemetry public class Telemetry : ITelemetry
{ {
private static bool _isInitialized = false; private bool _isInitialized = false;
private static TelemetryClient _client = null; private TelemetryClient _client = null;
private static Dictionary<string, string> _commonProperties = null; private Dictionary<string, string> _commonProperties = null;
private static Dictionary<string, double> _commonMeasurements = null; private Dictionary<string, double> _commonMeasurements = null;
private const string InstrumentationKey = "74cc1c9e-3e6e-4d05-b3fc-dde9101d0254"; private const string InstrumentationKey = "74cc1c9e-3e6e-4d05-b3fc-dde9101d0254";
private const string TelemetryOptout = "DOTNET_CLI_TELEMETRY_OPTOUT"; private const string TelemetryOptout = "DOTNET_CLI_TELEMETRY_OPTOUT";
@ -52,6 +52,7 @@ namespace Microsoft.DotNet.Cli.Utils
{ {
// we dont want to fail the tool if telemetry fais. We should be able to detect abnormalities from data // we dont want to fail the tool if telemetry fais. We should be able to detect abnormalities from data
// at the server end // at the server end
Debug.Fail("Exception during telemetry initialization");
} }
} }
@ -70,7 +71,10 @@ namespace Microsoft.DotNet.Cli.Utils
_client.TrackEvent(eventName, eventProperties, eventMeasurements); _client.TrackEvent(eventName, eventProperties, eventMeasurements);
_client.Flush(); _client.Flush();
} }
catch (Exception) { } catch (Exception)
{
Debug.Fail("Exception during TrackEvent");
}
} }
@ -96,9 +100,9 @@ namespace Microsoft.DotNet.Cli.Utils
private Dictionary<string, string> GetEventProperties(IDictionary<string, string> properties) private Dictionary<string, string> GetEventProperties(IDictionary<string, string> properties)
{ {
Dictionary<string, string> eventProperties = new Dictionary<string, string>(_commonProperties);
if (properties != null) if (properties != null)
{ {
var eventProperties = new Dictionary<string, string>(_commonProperties);
foreach (var property in properties) foreach (var property in properties)
{ {
if (eventProperties.ContainsKey(property.Key)) if (eventProperties.ContainsKey(property.Key))
@ -110,8 +114,12 @@ namespace Microsoft.DotNet.Cli.Utils
eventProperties.Add(property.Key, property.Value); eventProperties.Add(property.Key, property.Value);
} }
} }
return eventProperties;
}
else
{
return _commonProperties;
} }
return eventProperties;
} }
} }
} }

View file

@ -117,12 +117,10 @@ namespace Microsoft.DotNet.Cli
}; };
int exitCode; int exitCode;
var arguments = string.Empty;
Func<string[], int> builtIn; Func<string[], int> builtIn;
if (builtIns.TryGetValue(command, out builtIn)) if (builtIns.TryGetValue(command, out builtIn))
{ {
exitCode = builtIn(appArgs.ToArray()); exitCode = builtIn(appArgs.ToArray());
arguments = string.Join(" ", appArgs);
} }
else else
{ {
@ -130,7 +128,6 @@ namespace Microsoft.DotNet.Cli
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.Execute(); .Execute();
arguments = result.StartInfo.Arguments;
exitCode = result.ExitCode; exitCode = result.ExitCode;
} }