Skip to content

Commit 3544b1d

Browse files
author
Paul van Brenk
committed
PR feedback
1 parent 7e95180 commit 3544b1d

File tree

7 files changed

+23
-41
lines changed

7 files changed

+23
-41
lines changed

Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ internal void Install(PackageCatalogEntryViewModel package)
304304
{
305305
var selectedVersion = this.SelectedVersion is SemverVersion ? ((SemverVersion)this.SelectedVersion).ToString() : string.Empty;
306306

307-
TelemetryHelper.LogInstallNpmPackage(package.Name, selectedVersion);
307+
TelemetryHelper.LogInstallNpmPackage();
308308

309309
this.npmWorker.QueueCommand(
310310
NpmArgumentBuilder.GetNpmInstallArguments(

Nodejs/Product/Nodejs/NpmUI/NpmWorker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public async Task<IEnumerable<IPackage>> GetCatalogPackagesAsync(string filterTe
104104
return Enumerable.Empty<IPackage>();
105105
}
106106

107-
TelemetryHelper.LogSearchNpm(filterText);
107+
TelemetryHelper.LogSearchNpm();
108108

109109
var relativeUri = string.Format("/-/v1/search?text={0}", WebUtility.UrlEncode(filterText));
110110
var searchUri = new Uri(defaultRegistryUri, relativeUri);

Nodejs/Product/Nodejs/Project/NodeModulesNode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ public System.Threading.Tasks.Task UninstallModules()
621621
{
622622
foreach (var node in selected.OfType<DependencyNode>().Where(this.CheckValidCommandTarget))
623623
{
624-
TelemetryHelper.LogUnInstallNpmPackage(node.Package.Name);
624+
TelemetryHelper.LogUnInstallNpmPackage();
625625
await commander.UninstallPackageAsync(node.Package.Name);
626626
}
627627
});
@@ -634,7 +634,7 @@ public async System.Threading.Tasks.Task UninstallModule(DependencyNode node)
634634
return;
635635
}
636636

637-
TelemetryHelper.LogUnInstallNpmPackage(node.Package.Name);
637+
TelemetryHelper.LogUnInstallNpmPackage();
638638

639639
await RunNpmCommand(async commander =>
640640
{

Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ private int Start(string file, bool debug)
7676
var chromeProtocolRequired = nodeVersion >= new Version(8, 0) || CheckDebugProtocolOption();
7777
var startBrowser = ShouldStartBrowser();
7878

79+
// The call to Version.ToString() is safe, since changes to the ToString method are very unlikely, as the current output is widely documented.
7980
if (debug && !chromeProtocolRequired)
8081
{
8182
StartWithDebugger(file);

Nodejs/Product/Nodejs/Telemetry/TelemetryEvents.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,5 @@ internal static class TelemetryProperties
6262
/// The version of Node the user is using.
6363
/// </summary>
6464
public const string NodeVersion = Prefix + "NodeVersion";
65-
66-
/// <summary>
67-
/// The query the user send to NPM.
68-
/// </summary>
69-
public const string NpmSearchQuery = Prefix + "NpmSearchQuery";
70-
71-
/// <summary>
72-
/// The NPM package being installed/uninstalled/updated.
73-
/// </summary>
74-
public const string NpmPackageName = Prefix + "NpmPackageName";
75-
76-
/// <summary>
77-
/// The version of the NPM package being installed/uninstalled/updated.
78-
/// </summary>
79-
public const string NpmPackageVersion = Prefix + "NpmPackageVersion";
8065
}
8166
}

Nodejs/Product/Nodejs/Telemetry/TelemetryHelper.cs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,22 @@ public static void LogDebuggingStarted(string debuggerName, string nodeVersion,
3737
defaultSession.PostEvent(userTask);
3838
}
3939

40-
public static void LogSearchNpm(string query)
40+
public static void LogSearchNpm()
4141
{
42-
var userTask = new UserTaskEvent(SearchNpm, TelemetryResult.Success);
43-
userTask.Properties[NpmSearchQuery] = query;
44-
45-
defaultSession.PostEvent(userTask);
42+
defaultSession.PostUserTask(SearchNpm, TelemetryResult.Success);
4643
}
4744

48-
public static void LogInstallNpmPackage(string packageName, string version)
45+
public static void LogInstallNpmPackage()
4946
{
50-
var userTask = new UserTaskEvent(InstallNpm, TelemetryResult.Success);
51-
userTask.Properties[NpmPackageName] = packageName;
52-
userTask.Properties[NpmPackageVersion] = packageName;
53-
54-
defaultSession.PostEvent(userTask);
47+
defaultSession.PostUserTask(InstallNpm, TelemetryResult.Success);
5548
}
5649

57-
public static void LogUnInstallNpmPackage(string packageName)
50+
public static void LogUnInstallNpmPackage()
5851
{
59-
var userTask = new UserTaskEvent(UnInstallNpm, TelemetryResult.Success);
60-
userTask.Properties[NpmPackageName] = packageName;
61-
62-
defaultSession.PostEvent(userTask);
52+
defaultSession.PostUserTask(UnInstallNpm, TelemetryResult.Success);
6353
}
6454

65-
internal static void LogReplUse()
55+
public static void LogReplUse()
6656
{
6757
defaultSession.PostUserTask(UsedRepl, TelemetryResult.Success);
6858
}

Nodejs/Product/TestAdapter/TestExecutor.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,16 @@ public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrame
183183
}
184184
}
185185

186-
private void LogTelemetry(int testCount, bool isDebugging)
186+
private void LogTelemetry(int testCount, Version nodeVersion, bool isDebugging)
187187
{
188188
var userTask = new UserTaskEvent("VS/NodejsTools/UnitTestsExecuted", TelemetryResult.Success);
189189
userTask.Properties["VS.NodejsTools.TestCount"] = testCount;
190+
// This is safe, since changes to the ToString method are very unlikely, as the current output is widely documented.
191+
userTask.Properties["VS.NodejsTools.NodeVersion"] = nodeVersion.ToString();
190192
userTask.Properties["VS.NodejsTools.IsDebugging"] = isDebugging;
191193

194+
//todo: when we have support for the Node 8 debugger log which version of the debugger people are actually using
195+
192196
var defaultSession = TelemetryService.DefaultSession;
193197
defaultSession.PostEvent(userTask);
194198
}
@@ -221,12 +225,14 @@ private void RunTestCases(IEnumerable<TestCase> tests, IRunContext runContext, I
221225
var testInfo = new NodejsTestInfo(tests.First().FullyQualifiedName);
222226
var workingDir = Path.GetDirectoryName(CommonUtils.GetAbsoluteFilePath(settings.WorkingDir, testInfo.ModulePath));
223227

224-
// we can only log telemetry when we're running in VS,
225-
// the required assemblies are not on disk, so we have to keep the call in a separate method
226-
// this way the .NET framework only loads the assemblies when we actually need them.
228+
var nodeVersion = Nodejs.GetNodeVersion(settings.NodeExePath);
229+
230+
// We can only log telemetry when we're running in VS.
231+
// Since the required assemblies are not on disk if we're not running in VS, we have to reference them in a separate method
232+
// this way the .NET framework only tries to load the assemblies when we actually need them.
227233
if (app != null)
228234
{
229-
LogTelemetry(tests.Count(), runContext.IsBeingDebugged);
235+
LogTelemetry(tests.Count(), nodeVersion, runContext.IsBeingDebugged);
230236
}
231237

232238
foreach (var test in tests)

0 commit comments

Comments
 (0)