From 7151ddf2b0c0d4320a1c0b46be9e8a70355a3cbf Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Tue, 4 May 2021 10:05:50 -0700 Subject: [PATCH] Add jump to source telemetry --- src/client/telemetry/constants.ts | 2 ++ src/client/telemetry/index.ts | 13 +++++++++++++ src/client/tensorBoard/tensorBoardSession.ts | 2 ++ 3 files changed, 17 insertions(+) diff --git a/src/client/telemetry/constants.ts b/src/client/telemetry/constants.ts index 854266995e09..c30cb777c5de 100644 --- a/src/client/telemetry/constants.ts +++ b/src/client/telemetry/constants.ts @@ -136,6 +136,8 @@ export enum EventName { TENSORBOARD_DETECTED_IN_INTEGRATED_TERMINAL = 'TENSORBOARD_DETECTED_IN_INTEGRATED_TERMINAL', TENSORBOARD_PACKAGE_INSTALL_RESULT = 'TENSORBOARD.PACKAGE_INSTALL_RESULT', TENSORBOARD_TORCH_PROFILER_IMPORT = 'TENSORBOARD.TORCH_PROFILER_IMPORT', + TENSORBOARD_JUMP_TO_SOURCE_REQUEST = 'TENSORBOARD_JUMP_TO_SOURCE_REQUEST', + TENSORBOARD_JUMP_TO_SOURCE_FILE_NOT_FOUND = 'TENSORBOARD_JUMP_TO_SOURCE_FILE_NOT_FOUND', } export enum PlatformErrors { diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index d92464de9997..46989cf6868a 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -1832,4 +1832,17 @@ export interface IEventNamePropertyMapping { * `from torch import profiler`. */ [EventName.TENSORBOARD_TORCH_PROFILER_IMPORT]: never | undefined; + /** + * Telemetry event sent when the extension host receives a message from the + * TensorBoard webview containing a valid jump to source payload from the + * PyTorch profiler TensorBoard plugin. + */ + [EventName.TENSORBOARD_JUMP_TO_SOURCE_REQUEST]: never | undefined; + /** + * Telemetry event sent when the extension host receives a message from the + * TensorBoard webview containing a valid jump to source payload from the + * PyTorch profiler TensorBoard plugin, but the source file does not exist + * on the machine currently running TensorBoard. + */ + [EventName.TENSORBOARD_JUMP_TO_SOURCE_FILE_NOT_FOUND]: never | undefined; } diff --git a/src/client/tensorBoard/tensorBoardSession.ts b/src/client/tensorBoard/tensorBoardSession.ts index 36e45fdc40d6..fef4ae8ac3ca 100644 --- a/src/client/tensorBoard/tensorBoardSession.ts +++ b/src/client/tensorBoard/tensorBoardSession.ts @@ -499,10 +499,12 @@ export class TensorBoardSession { } private async jumpToSource(fsPath: string, line: number) { + sendTelemetryEvent(EventName.TENSORBOARD_JUMP_TO_SOURCE_REQUEST); let uri: Uri | undefined; if (fs.existsSync(fsPath)) { uri = Uri.file(fsPath); } else { + sendTelemetryEvent(EventName.TENSORBOARD_JUMP_TO_SOURCE_FILE_NOT_FOUND); traceError( `Requested jump to source filepath ${fsPath} does not exist. Prompting user to select source file...`, );