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

Add telemetry to serial monitor commands #137

Merged
merged 3 commits into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ export enum TelemetryEventName {
COMMAND_RUN_SIMULATOR_BUTTON = "COMMAND.RUN.SIMULATOR_BUTTON",
COMMAND_RUN_PALETTE = "COMMAND.RUN.PALETTE",
COMMAND_RUN_EDITOR_ICON = "COMMAND.RUN.EDITOR_ICON",
COMMAND_SERIAL_MONITOR_CHOOSE_PORT = "COMMAND.SERIAL_MONITOR.CHOOSE_PORT",
COMMAND_SERIAL_MONITOR_OPEN = "COMMAND.SERIAL_MONITOR.OPEN",
COMMAND_SERIAL_MONITOR_BAUD_RATE = "COMMAND.SERIAL_MONITOR.BAUD_RATE",
COMMAND_SERIAL_MONITOR_CLOSE = "COMMAND.SERIAL_MONITOR.CLOSE",

// Simulator interaction
SIMULATOR_BUTTON_A = "SIMULATOR.BUTTON.A",
Expand Down
22 changes: 17 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ export async function activate(context: vscode.ExtensionContext) {
case "print":
console.log(
`Process print statement output = ${
messageToWebview.data
messageToWebview.data
}`
);
utils.logToOutputChannel(
Expand Down Expand Up @@ -644,7 +644,10 @@ export async function activate(context: vscode.ExtensionContext) {
"pacifica.selectSerialPort",
() => {
if (serialMonitor) {
serialMonitor.selectSerialPort(null, null);
telemetryAI.runWithLatencyMeasure(
() => { serialMonitor.selectSerialPort(null, null); },
TelemetryEventName.COMMAND_SERIAL_MONITOR_CHOOSE_PORT
);
} else {
vscode.window.showErrorMessage(CONSTANTS.ERROR.NO_FOLDER_OPENED);
console.info("Serial monitor is not defined.");
Expand All @@ -656,7 +659,10 @@ export async function activate(context: vscode.ExtensionContext) {
"pacifica.openSerialMonitor",
() => {
if (serialMonitor) {
serialMonitor.openSerialMonitor();
telemetryAI.runWithLatencyMeasure(
serialMonitor.openSerialMonitor.bind(serialMonitor),
TelemetryEventName.COMMAND_SERIAL_MONITOR_OPEN
);
} else {
vscode.window.showErrorMessage(CONSTANTS.ERROR.NO_FOLDER_OPENED);
console.info("Serial monitor is not defined.");
Expand All @@ -668,7 +674,10 @@ export async function activate(context: vscode.ExtensionContext) {
"pacifica.changeBaudRate",
() => {
if (serialMonitor) {
serialMonitor.changeBaudRate();
telemetryAI.runWithLatencyMeasure(
serialMonitor.changeBaudRate.bind(serialMonitor),
TelemetryEventName.COMMAND_SERIAL_MONITOR_BAUD_RATE
);
} else {
vscode.window.showErrorMessage(CONSTANTS.ERROR.NO_FOLDER_OPENED);
console.info("Serial monitor is not defined.");
Expand All @@ -680,7 +689,10 @@ export async function activate(context: vscode.ExtensionContext) {
"pacifica.closeSerialMonitor",
(port, showWarning = true) => {
if (serialMonitor) {
serialMonitor.closeSerialMonitor(port, showWarning);
telemetryAI.runWithLatencyMeasure(
() => { serialMonitor.closeSerialMonitor(port, showWarning); },
TelemetryEventName.COMMAND_SERIAL_MONITOR_CLOSE
)
} else {
vscode.window.showErrorMessage(CONSTANTS.ERROR.NO_FOLDER_OPENED);
console.info("Serial monitor is not defined.");
Expand Down