From 555475f754509f8ecf245ed9f52942a79d0fadf1 Mon Sep 17 00:00:00 2001 From: Bob Brown Date: Wed, 6 May 2026 16:53:37 -0700 Subject: [PATCH] Add telemetry for run without debugging --- .../Debugger/debugAdapterDescriptorFactory.ts | 59 +++++++++++-------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/Extension/src/Debugger/debugAdapterDescriptorFactory.ts b/Extension/src/Debugger/debugAdapterDescriptorFactory.ts index 90657bb90..c20c12719 100644 --- a/Extension/src/Debugger/debugAdapterDescriptorFactory.ts +++ b/Extension/src/Debugger/debugAdapterDescriptorFactory.ts @@ -8,6 +8,7 @@ import * as path from 'path'; import * as vscode from "vscode"; import * as nls from 'vscode-nls'; import { getOutputChannel } from '../logger'; +import { logDebuggerEvent } from '../telemetry'; import { RunWithoutDebuggingAdapter } from './runWithoutDebuggingAdapter'; nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })(); @@ -29,40 +30,52 @@ abstract class AbstractDebugAdapterDescriptorFactory implements vscode.DebugAdap export class CppdbgDebugAdapterDescriptorFactory extends AbstractDebugAdapterDescriptorFactory { async createDebugAdapterDescriptor(session: vscode.DebugSession, _executable?: vscode.DebugAdapterExecutable): Promise { - if (session.configuration.noDebug) { - if (noDebugSupported(session.configuration)) { - return new vscode.DebugAdapterInlineImplementation(new RunWithoutDebuggingAdapter()); + const properties: { [key: string]: string } = { type: 'cppdbg', noDebug: Boolean(session.configuration.noDebug).toString() }; + try { + if (session.configuration.noDebug) { + if (noDebugSupported(session.configuration)) { + return new vscode.DebugAdapterInlineImplementation(new RunWithoutDebuggingAdapter()); + } + // If the configuration is not supported, gracefully fall back to a regular debug session and log a message to the user. + logReasonForNoDebugNotSupported(session.configuration); + properties.noDebugSkipped = true.toString(); } - // If the configuration is not supported, gracefully fall back to a regular debug session and log a message to the user. - logReasonForNoDebugNotSupported(session.configuration); - } - const adapter: string = "./debugAdapters/bin/OpenDebugAD7" + (os.platform() === 'win32' ? ".exe" : ""); + const adapter: string = "./debugAdapters/bin/OpenDebugAD7" + (os.platform() === 'win32' ? ".exe" : ""); - const command: string = path.join(this.context.extensionPath, adapter); + const command: string = path.join(this.context.extensionPath, adapter); - return new vscode.DebugAdapterExecutable(command, []); + return new vscode.DebugAdapterExecutable(command, []); + } finally { + logDebuggerEvent('createDebugAdapter', properties); + } } } export class CppvsdbgDebugAdapterDescriptorFactory extends AbstractDebugAdapterDescriptorFactory { async createDebugAdapterDescriptor(session: vscode.DebugSession, _executable?: vscode.DebugAdapterExecutable): Promise { - if (session.configuration.noDebug) { - if (noDebugSupported(session.configuration)) { - return new vscode.DebugAdapterInlineImplementation(new RunWithoutDebuggingAdapter()); + const properties: { [key: string]: string } = { type: 'cppvsdbg', noDebug: Boolean(session.configuration.noDebug).toString() }; + try { + if (session.configuration.noDebug) { + if (noDebugSupported(session.configuration)) { + return new vscode.DebugAdapterInlineImplementation(new RunWithoutDebuggingAdapter()); + } + // If the configuration is not supported, gracefully fall back to a regular debug session and log a message to the user. + logReasonForNoDebugNotSupported(session.configuration); + properties.noDebugSkipped = true.toString(); } - // If the configuration is not supported, gracefully fall back to a regular debug session and log a message to the user. - logReasonForNoDebugNotSupported(session.configuration); - } - if (os.platform() !== 'win32') { - void vscode.window.showErrorMessage(localize("debugger.not.available", "Debugger type '{0}' is not available for non-Windows machines.", "cppvsdbg")); - return null; - } else { - return new vscode.DebugAdapterExecutable( - path.join(this.context.extensionPath, './debugAdapters/vsdbg/bin/vsdbg.exe'), - ['--interpreter=vscode', '--extConfigDir=%USERPROFILE%\\.cppvsdbg\\extensions'] - ); + if (os.platform() !== 'win32') { + void vscode.window.showErrorMessage(localize("debugger.not.available", "Debugger type '{0}' is not available for non-Windows machines.", "cppvsdbg")); + return null; + } else { + return new vscode.DebugAdapterExecutable( + path.join(this.context.extensionPath, './debugAdapters/vsdbg/bin/vsdbg.exe'), + ['--interpreter=vscode', '--extConfigDir=%USERPROFILE%\\.cppvsdbg\\extensions'] + ); + } + } finally { + logDebuggerEvent('createDebugAdapter', properties); } } }