Skip to content

Commit 54d8881

Browse files
Add missing telemetry and extra logging
1 parent 161cd6b commit 54d8881

File tree

8 files changed

+43
-4
lines changed

8 files changed

+43
-4
lines changed

src/extension/common/application/debugSessionTelemetry.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,18 @@ class TelemetryTracker implements DebugAdapterTracker {
4141
this.sendTelemetry(EventName.DEBUG_SESSION_STOP);
4242
}
4343

44-
public onError?(_error: Error): void {
45-
this.sendTelemetry(EventName.DEBUG_SESSION_ERROR);
44+
public onError?(error: Error): void {
45+
this.sendTelemetry(EventName.DEBUG_SESSION_ERROR, error);
4646
}
4747

48-
private sendTelemetry(eventName: EventName): void {
48+
private sendTelemetry<P extends IEventNamePropertyMapping, E extends keyof P>(eventName: EventName, properties?: P[E]): void {
4949
if (eventName === EventName.DEBUG_SESSION_START) {
5050
this.timer.reset();
5151
}
5252
const telemetryProps = {
5353
trigger: this.trigger,
5454
console: this.console,
55+
...properties
5556
};
5657
sendTelemetryEvent(eventName as keyof IEventNamePropertyMapping, this.timer.elapsedTime, telemetryProps);
5758
}

src/extension/debugger/adapter/factory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
149149
}
150150

151151
private async showDeprecatedPythonMessage() {
152+
sendTelemetryEvent(EventName.DEBUGGER_PYTHON_37_DEPRECATED);
152153
const notificationPromptEnabled = this.persistentState.createGlobalPersistentState(
153154
debugStateKeys.doNotShowAgain,
154155
false,

src/extension/debugger/configuration/dynamicdebugConfigurationService.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { IDynamicDebugConfigurationService } from '../types';
1010
import { DebuggerTypeName } from '../../constants';
1111
import { replaceAll } from '../../common/stringUtils';
1212
import { getDjangoPaths, getFastApiPaths, getFlaskPaths } from './utils/configuration';
13+
import { sendTelemetryEvent } from '../../telemetry';
14+
import { EventName } from '../../telemetry/constants';
1315

1416
const workspaceFolderToken = '${workspaceFolder}';
1517

@@ -20,7 +22,7 @@ export class DynamicPythonDebugConfigurationService implements IDynamicDebugConf
2022
_token?: CancellationToken,
2123
): Promise<DebugConfiguration[] | undefined> {
2224
const providers = [];
23-
25+
2426
providers.push({
2527
name: 'Python Debugger: Python File',
2628
type: DebuggerTypeName,
@@ -74,6 +76,8 @@ export class DynamicPythonDebugConfigurationService implements IDynamicDebugConf
7476
});
7577
}
7678

79+
sendTelemetryEvent(EventName.DEBUGGER_DYNAMIC_CONFIGURATION, undefined, { providers: providers });
80+
7781
return providers;
7882
}
7983
}

src/extension/debugger/hooks/childProcessAttachService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { AttachRequestArguments } from '../../types';
1010
import { IChildProcessAttachService } from './types';
1111
import { getWorkspaceFolders, showErrorMessage } from '../../common/vscodeapi';
1212
import { noop } from '../../common/utils/misc';
13+
import { traceLog } from '../../common/log/logging';
1314

1415
/**
1516
* This class is responsible for attaching the debugger to any
@@ -27,6 +28,7 @@ export class ChildProcessAttachService implements IChildProcessAttachService {
2728
lifecycleManagedByParent: true,
2829
};
2930
const folder = this.getRelatedWorkspaceFolder(debugConfig);
31+
traceLog("Start debugger in the child proccess");
3032
const launched = await debug.startDebugging(folder, debugConfig, debugSessionOption);
3133
if (!launched) {
3234
showErrorMessage(l10n.t('Failed to launch debugger for child process {0}', debugConfig.subProcessId!)).then(

src/extension/debugger/hooks/debugpySocketsHandler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { DebuggerEvents } from './constants';
1010
import { DebuggerTypeName } from '../../constants';
1111
import { DebugPortAttributesProvider } from '../debugPort/portAttributesProvider';
1212
import { IDebugSessionEventHandlers } from './types';
13+
import { traceLog } from '../../common/log/logging';
1314

1415
/**
1516
* This class is responsible for register ports using by debugpy in the portProvider.
@@ -30,6 +31,7 @@ export class DebugpySocketsHandler implements IDebugSessionEventHandlers {
3031
}
3132

3233
if (event.event === DebuggerEvents.DebugpySockets) {
34+
traceLog();
3335
let portSocket = event.body.sockets.find((socket: { [x: string]: any }) => {
3436
return socket['internal'] === false;
3537
});

src/extension/extensionInit.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import { openReportIssue } from './common/application/commands/reportIssueComman
4949
import { buildApi } from './api';
5050
import { IExtensionApi } from './apiTypes';
5151
import { registerHexDebugVisualizationTreeProvider } from './debugger/visualizers/inlineHexDecoder';
52+
import { traceLog } from './common/log/logging';
5253

5354
export async function registerDebugger(context: IExtensionContext): Promise<IExtensionApi> {
5455
const childProcessAttachService = new ChildProcessAttachService();
@@ -89,12 +90,14 @@ export async function registerDebugger(context: IExtensionContext): Promise<IExt
8990
return;
9091
}
9192
const config = await getDebugConfiguration(file);
93+
traceLog("Debugging using the editor button 'Debug in terminal'");
9294
startDebugging(undefined, config);
9395
}),
9496
);
9597

9698
context.subscriptions.push(
9799
registerCommand(Commands.Debug_Using_Launch_Config, async (file?: Uri) => {
100+
traceLog("Debugging using the editor button 'Debug using the launch.json'");
98101
sendTelemetryEvent(EventName.DEBUG_USING_LAUNCH_CONFIG_BUTTON);
99102
const interpreter = await getInterpreterDetails(file);
100103

src/extension/telemetry/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ export enum EventName {
1313
DEBUG_SESSION_START = 'DEBUG_SESSION.START',
1414
DEBUG_SESSION_STOP = 'DEBUG_SESSION.STOP',
1515
DEBUG_SESSION_USER_CODE_RUNNING = 'DEBUG_SESSION.USER_CODE_RUNNING',
16+
DEBUG_SHOW_INLINE_HEX_VALUE = 'DEBUG.SHOW_INLINE_HEX_VALUE',
1617
DEBUGGER = 'DEBUGGER',
1718
DEBUGGER_ATTACH_TO_CHILD_PROCESS = 'DEBUGGER.ATTACH_TO_CHILD_PROCESS',
1819
DEBUGGER_ATTACH_TO_LOCAL_PROCESS = 'DEBUGGER.ATTACH_TO_LOCAL_PROCESS',
1920
DEBUGGER_CONFIGURATION_PROMPTS = 'DEBUGGER.CONFIGURATION.PROMPTS',
2021
DEBUGGER_CONFIGURATION_PROMPTS_IN_LAUNCH_JSON = 'DEBUGGER.CONFIGURATION.PROMPTS.IN.LAUNCH.JSON',
22+
DEBUGGER_DYNAMIC_CONFIGURATION = 'DEBUGGER.DYNAMIC_CONFIGURATION',
2123
ENVFILE_VARIABLE_SUBSTITUTION = 'ENVFILE_VARIABLE_SUBSTITUTION',
2224
USE_REPORT_ISSUE_COMMAND = 'USE_REPORT_ISSUE_COMMAND',
25+
DEBUGGER_PYTHON_37_DEPRECATED = "DEBUGGER_PYTHON_37_DEPRECATED",
2326
}

src/extension/telemetry/index.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { DebugConfigurationType } from '../debugger/types';
1111
import { EventName } from './constants';
1212
import { isPromise } from '../common/utils/async';
1313
import { getTelemetryReporter } from './reporter';
14+
import { DebugConfiguration } from 'vscode';
1415

1516
/**
1617
* Checks whether telemetry is supported.
@@ -346,6 +347,7 @@ export interface IEventNamePropertyMapping {
346347
* @type {ConsoleType}
347348
*/
348349
console?: ConsoleType;
350+
error?: Error
349351
};
350352
/**
351353
* Telemetry captured after stopping debug session.
@@ -660,4 +662,25 @@ export interface IEventNamePropertyMapping {
660662
"use_report_issue_command" : { "owner": "paulacamargo25" }
661663
*/
662664
[EventName.USE_REPORT_ISSUE_COMMAND]: unknown;
665+
/**
666+
* Telemetry event sent when providing dynamic configuration for debugger
667+
*/
668+
/* __GDPR__
669+
"debugger_dynamic_config" : { "owner": "paulacamargo25" }
670+
*/
671+
[EventName.DEBUGGER_DYNAMIC_CONFIGURATION]: {
672+
/**
673+
* Providers of dynamic configurations
674+
*
675+
* @type {DebugConfiguration[]}
676+
*/
677+
providers: DebugConfiguration[]
678+
},
679+
/**
680+
* Telemetry event sent when the debugger is running with a non supports python versions minor than 3.7.
681+
*/
682+
/* __GDPR__
683+
"DEBUGGER_PYTHON_37_DEPRECATED" : { "owner": "paulacamargo25" }
684+
*/
685+
[EventName.DEBUGGER_PYTHON_37_DEPRECATED]: never | undefined;
663686
}

0 commit comments

Comments
 (0)