File tree 2 files changed +18
-5
lines changed
2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -1972,8 +1972,13 @@ export interface IEventNamePropertyMapping {
1972
1972
[ EventName . REPL ] : {
1973
1973
/**
1974
1974
* 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`.
1975
1980
*/
1976
- replType : 'Terminal' | 'Native' | 'manualTerminal' ;
1981
+ replType : 'Terminal' | 'Native' | 'manualTerminal' | `runningScript` ;
1977
1982
} ;
1978
1983
/**
1979
1984
* 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
3
3
import { sendTelemetryEvent } from '../../telemetry' ;
4
4
import { EventName } from '../../telemetry/constants' ;
5
5
6
- function checkREPLCommand ( command : string ) : boolean {
6
+ function checkREPLCommand ( command : string ) : undefined | 'manualTerminal' | `runningScript` {
7
7
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 ;
9
16
}
10
17
11
18
export function registerTriggerForTerminalREPL ( disposables : Disposable [ ] ) : void {
12
19
disposables . push (
13
20
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 } ) ;
16
24
}
17
25
} ) ,
18
26
) ;
You can’t perform that action at this time.
0 commit comments