Skip to content

Commit 6f3cfa9

Browse files
author
Paul van Brenk
committed
Telemetry for debugging
1 parent 3e60b14 commit 6f3cfa9

File tree

4 files changed

+56
-7
lines changed

4 files changed

+56
-7
lines changed

Nodejs/Product/Nodejs/Debugger/NodeDebugProvider.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.ComponentModel.Composition;
55
using System.IO;
66
using Microsoft.NodejsTools.Project;
7+
using Microsoft.NodejsTools.Telemetry;
78
using Microsoft.VisualStudio.Setup.Configuration;
89
using Microsoft.VisualStudio.Shell.Interop;
910
using Microsoft.VisualStudio.Workspace;
@@ -47,16 +48,18 @@ internal class NodeJsDebugLaunchProvider : IVsDebugLaunchTargetProvider
4748

4849
public void SetupDebugTargetInfo(ref VsDebugTargetInfo vsDebugTargetInfo, DebugLaunchActionContext debugLaunchContext)
4950
{
50-
var nodeExe = debugLaunchContext.LaunchConfiguration.GetValue<string>(NodeExeKey, defaultValue: Nodejs.GetPathToNodeExecutableFromEnvironment());
51+
var nodeExe = debugLaunchContext.LaunchConfiguration.GetValue(NodeExeKey, defaultValue: Nodejs.GetPathToNodeExecutableFromEnvironment());
5152

5253
var nodeVersion = Nodejs.GetNodeVersion(nodeExe);
5354
if (nodeVersion >= new Version(8, 0) || NodejsProjectLauncher.CheckDebugProtocolOption())
5455
{
5556
SetupDebugTargetInfoForWebkitV2Protocol(ref vsDebugTargetInfo, debugLaunchContext, nodeExe);
57+
TelemetryHelper.LogDebuggingStarted("ChromeV2", nodeVersion.ToString(), isProject: false);
5658
}
5759
else
5860
{
5961
this.SetupDebugTargetInfoForNodeProtocol(ref vsDebugTargetInfo, debugLaunchContext, nodeExe);
62+
TelemetryHelper.LogDebuggingStarted("Node6", nodeVersion.ToString(), isProject: false);
6063
}
6164
}
6265

@@ -117,7 +120,7 @@ private void SetupDebugTargetInfoForWebkitV2Protocol(ref VsDebugTargetInfo vsDeb
117120
new JProperty("runtimeExecutable", nodeExe),
118121
new JProperty("cwd", cwd),
119122
new JProperty("console", "externalTerminal"),
120-
new JProperty("diagnosticLogging", NodejsProjectLauncher.CheckEnableDiagnosticLoggingOption()),
123+
new JProperty("trace", NodejsProjectLauncher.CheckEnableDiagnosticLoggingOption()),
121124
new JProperty("sourceMaps", true),
122125
new JProperty("stopOnEntry", true),
123126
new JProperty("$adapter", pathToNodeExe),

Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Microsoft.NodejsTools.Debugger;
1818
using Microsoft.NodejsTools.Debugger.DebugEngine;
1919
using Microsoft.NodejsTools.Options;
20+
using Microsoft.NodejsTools.Telemetry;
2021
using Microsoft.NodejsTools.TypeScript;
2122
using Microsoft.VisualStudio;
2223
using Microsoft.VisualStudio.Setup.Configuration;
@@ -32,8 +33,8 @@ internal class NodejsProjectLauncher : IProjectLauncher
3233
private readonly NodejsProjectNode _project;
3334
private int? _testServerPort;
3435

35-
public static readonly Guid WebkitDebuggerGuid = Guid.Parse("4cc6df14-0ab5-4a91-8bb4-eb0bf233d0fe");
36-
public static readonly Guid WebkitPortSupplierGuid = Guid.Parse("4103f338-2255-40c0-acf5-7380e2bea13d");
36+
private static readonly Guid WebkitDebuggerGuid = Guid.Parse("4cc6df14-0ab5-4a91-8bb4-eb0bf233d0fe");
37+
private static readonly Guid WebkitPortSupplierGuid = Guid.Parse("4103f338-2255-40c0-acf5-7380e2bea13d");
3738
internal static readonly Guid WebKitDebuggerV2Guid = Guid.Parse("30d423cc-6d0b-4713-b92d-6b2a374c3d89");
3839

3940
public NodejsProjectLauncher(NodejsProjectNode project)
@@ -71,27 +72,32 @@ private int Start(string file, bool debug)
7172
return VSConstants.S_OK;
7273
}
7374

74-
var chromeProtocolRequired = Nodejs.GetNodeVersion(nodePath) >= new Version(8, 0) || CheckDebugProtocolOption();
75+
var nodeVersion = Nodejs.GetNodeVersion(nodePath);
76+
var chromeProtocolRequired = nodeVersion >= new Version(8, 0) || CheckDebugProtocolOption();
7577
var startBrowser = ShouldStartBrowser();
7678

7779
if (debug && !chromeProtocolRequired)
7880
{
7981
StartWithDebugger(file);
82+
TelemetryHelper.LogDebuggingStarted("Node6", nodeVersion.ToString());
8083
}
8184
else if (debug && chromeProtocolRequired)
8285
{
8386
if (CheckUseNewChromeDebugProtocolOption())
8487
{
8588
StartWithChromeV2Debugger(file, nodePath, startBrowser);
89+
TelemetryHelper.LogDebuggingStarted("ChromeV2", nodeVersion.ToString());
8690
}
8791
else
8892
{
8993
StartAndAttachDebugger(file, nodePath, startBrowser);
94+
TelemetryHelper.LogDebuggingStarted("Chrome", nodeVersion.ToString());
9095
}
9196
}
9297
else
9398
{
9499
StartNodeProcess(file, nodePath, startBrowser);
100+
TelemetryHelper.LogDebuggingStarted("None", nodeVersion.ToString());
95101
}
96102

97103
return VSConstants.S_OK;

Nodejs/Product/Nodejs/Telemetry/TelemetryEvents.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,33 @@ internal static class TelemetryEvents
1414
/// </summary>
1515
public const string ProjectImported = Prefix + "ProjectImported";
1616

17+
/// <summary>
18+
/// User started debugging.
19+
/// </summary>
20+
public const string DebbugerStarted = Prefix + "DebuggerStarted";
21+
}
22+
23+
internal static class TelemetryProperties
24+
{
25+
private const string Prefix = "VS.NodejsTools.";
26+
27+
/// <summary>
28+
/// The engine the user is using to debug node. Expected entries are:
29+
/// * Node6
30+
/// * Chrome
31+
/// * ChromeV2
32+
/// * None
33+
/// </summary>
34+
public const string DebuggerEngine = Prefix + "DebuggerEngine";
35+
36+
/// <summary>
37+
/// Wether the user started debugging inside a project or in AnyCode.
38+
/// </summary>
39+
public const string IsProject = Prefix + "IsProject";
40+
41+
/// <summary>
42+
/// The version of Node the user is using.
43+
/// </summary>
44+
public const string NodeVersion = Prefix + "NodeVersion";
1745
}
1846
}

Nodejs/Product/Nodejs/Telemetry/TelemetryHelper.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
namespace Microsoft.NodejsTools.Telemetry
77
{
8+
using static TelemetryEvents;
9+
using static TelemetryProperties;
10+
811
/// <summary>
912
/// Extensions for logging telemetry events.
1013
/// </summary>
@@ -20,8 +23,17 @@ public static void Initialize()
2023

2124
public static void LogProjectImported()
2225
{
23-
defaultSession.PostUserTask(TelemetryEvents.ProjectImported, TelemetryResult.Success);
26+
defaultSession.PostUserTask(ProjectImported, TelemetryResult.Success);
27+
}
28+
29+
public static void LogDebuggingStarted(string debuggerName, string nodeVersion, bool isProject = true)
30+
{
31+
var userTask = new UserTaskEvent(DebbugerStarted, TelemetryResult.Success);
32+
userTask.Properties[DebuggerEngine] = debuggerName;
33+
userTask.Properties[NodeVersion] = nodeVersion;
34+
userTask.Properties[IsProject] = isProject;
35+
36+
defaultSession.PostEvent(userTask);
2437
}
2538
}
2639
}
27-

0 commit comments

Comments
 (0)