File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -1972,8 +1972,13 @@ export interface IEventNamePropertyMapping {
19721972 [ EventName . REPL ] : {
19731973 /**
19741974 * Whether the user launched the Terminal REPL or Native REPL
1975+ *
1976+ * Terminal - Terminal REPL user ran `Python: Start Terminal REPL` command.
1977+ * Native - Native REPL user ran `Python: Start Native Python REPL` command.
1978+ * manualTerminal - User started REPL in terminal using `python`, `python3` or `py` etc without arguments in terminal.
1979+ * runningScript - User ran a script in terminal like `python myscript.py`.
19751980 */
1976- replType : 'Terminal' | 'Native' | 'manualTerminal' ;
1981+ replType : 'Terminal' | 'Native' | 'manualTerminal' | `runningScript` ;
19771982 } ;
19781983 /**
19791984 * Telemetry event sent if and when user configure tests command. This command can be trigerred from multiple places in the extension. (Command palette, prompt etc.)
Original file line number Diff line number Diff line change @@ -3,16 +3,24 @@ import { onDidStartTerminalShellExecution } from '../../common/vscodeApis/window
33import { sendTelemetryEvent } from '../../telemetry' ;
44import { EventName } from '../../telemetry/constants' ;
55
6- function checkREPLCommand ( command : string ) : boolean {
6+ function checkREPLCommand ( command : string ) : undefined | 'manualTerminal' | `runningScript` {
77 const lower = command . toLowerCase ( ) . trimStart ( ) ;
8- return lower . startsWith ( 'python' ) || lower . startsWith ( 'py ' ) ;
8+ if ( lower . startsWith ( 'python' ) || lower . startsWith ( 'py ' ) ) {
9+ const parts = lower . split ( ' ' ) ;
10+ if ( parts . length === 1 ) {
11+ return 'manualTerminal' ;
12+ }
13+ return 'runningScript' ;
14+ }
15+ return undefined ;
916}
1017
1118export function registerTriggerForTerminalREPL ( disposables : Disposable [ ] ) : void {
1219 disposables . push (
1320 onDidStartTerminalShellExecution ( async ( e : TerminalShellExecutionStartEvent ) => {
14- if ( e . execution . commandLine . isTrusted && checkREPLCommand ( e . execution . commandLine . value ) ) {
15- sendTelemetryEvent ( EventName . REPL , undefined , { replType : 'manualTerminal' } ) ;
21+ const replType = checkREPLCommand ( e . execution . commandLine . value ) ;
22+ if ( e . execution . commandLine . isTrusted && replType ) {
23+ sendTelemetryEvent ( EventName . REPL , undefined , { replType } ) ;
1624 }
1725 } ) ,
1826 ) ;
You can’t perform that action at this time.
0 commit comments