Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit 0534322

Browse files
authored
Add telemetry to serial monitor commands (#137)
* Add telemetry to serial monitor commands * fix missing this issue
1 parent 2d45a3e commit 0534322

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ export enum TelemetryEventName {
255255
COMMAND_RUN_SIMULATOR_BUTTON = "COMMAND.RUN.SIMULATOR_BUTTON",
256256
COMMAND_RUN_PALETTE = "COMMAND.RUN.PALETTE",
257257
COMMAND_RUN_EDITOR_ICON = "COMMAND.RUN.EDITOR_ICON",
258+
COMMAND_SERIAL_MONITOR_CHOOSE_PORT = "COMMAND.SERIAL_MONITOR.CHOOSE_PORT",
259+
COMMAND_SERIAL_MONITOR_OPEN = "COMMAND.SERIAL_MONITOR.OPEN",
260+
COMMAND_SERIAL_MONITOR_BAUD_RATE = "COMMAND.SERIAL_MONITOR.BAUD_RATE",
261+
COMMAND_SERIAL_MONITOR_CLOSE = "COMMAND.SERIAL_MONITOR.CLOSE",
258262

259263
// Simulator interaction
260264
SIMULATOR_BUTTON_A = "SIMULATOR.BUTTON.A",

src/extension.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ export async function activate(context: vscode.ExtensionContext) {
442442
case "print":
443443
console.log(
444444
`Process print statement output = ${
445-
messageToWebview.data
445+
messageToWebview.data
446446
}`
447447
);
448448
utils.logToOutputChannel(
@@ -644,7 +644,10 @@ export async function activate(context: vscode.ExtensionContext) {
644644
"pacifica.selectSerialPort",
645645
() => {
646646
if (serialMonitor) {
647-
serialMonitor.selectSerialPort(null, null);
647+
telemetryAI.runWithLatencyMeasure(
648+
() => { serialMonitor.selectSerialPort(null, null); },
649+
TelemetryEventName.COMMAND_SERIAL_MONITOR_CHOOSE_PORT
650+
);
648651
} else {
649652
vscode.window.showErrorMessage(CONSTANTS.ERROR.NO_FOLDER_OPENED);
650653
console.info("Serial monitor is not defined.");
@@ -656,7 +659,10 @@ export async function activate(context: vscode.ExtensionContext) {
656659
"pacifica.openSerialMonitor",
657660
() => {
658661
if (serialMonitor) {
659-
serialMonitor.openSerialMonitor();
662+
telemetryAI.runWithLatencyMeasure(
663+
serialMonitor.openSerialMonitor.bind(serialMonitor),
664+
TelemetryEventName.COMMAND_SERIAL_MONITOR_OPEN
665+
);
660666
} else {
661667
vscode.window.showErrorMessage(CONSTANTS.ERROR.NO_FOLDER_OPENED);
662668
console.info("Serial monitor is not defined.");
@@ -668,7 +674,10 @@ export async function activate(context: vscode.ExtensionContext) {
668674
"pacifica.changeBaudRate",
669675
() => {
670676
if (serialMonitor) {
671-
serialMonitor.changeBaudRate();
677+
telemetryAI.runWithLatencyMeasure(
678+
serialMonitor.changeBaudRate.bind(serialMonitor),
679+
TelemetryEventName.COMMAND_SERIAL_MONITOR_BAUD_RATE
680+
);
672681
} else {
673682
vscode.window.showErrorMessage(CONSTANTS.ERROR.NO_FOLDER_OPENED);
674683
console.info("Serial monitor is not defined.");
@@ -680,7 +689,10 @@ export async function activate(context: vscode.ExtensionContext) {
680689
"pacifica.closeSerialMonitor",
681690
(port, showWarning = true) => {
682691
if (serialMonitor) {
683-
serialMonitor.closeSerialMonitor(port, showWarning);
692+
telemetryAI.runWithLatencyMeasure(
693+
() => { serialMonitor.closeSerialMonitor(port, showWarning); },
694+
TelemetryEventName.COMMAND_SERIAL_MONITOR_CLOSE
695+
)
684696
} else {
685697
vscode.window.showErrorMessage(CONSTANTS.ERROR.NO_FOLDER_OPENED);
686698
console.info("Serial monitor is not defined.");

0 commit comments

Comments
 (0)