forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REPL Telemetry for Terminal REPL and Native REPL (#23941)
Resolves: #23740 Also organize Telemetry for Terminal REPL vs. Native REPL. Now we can sort them out with new attribute 'replType' on the REPL Event. With this PR: - (EventName.REPL, { replType: 'Terminal' }) for when people launch Terminal REPL via Command Palette, Manually type Python in terminal (tried to account for all Python cases that will trigger REPL). - (EventName.REPL, { replType: 'Native' }) for when people launch Native REPL via Command Palette. --------- Co-authored-by: Karthik Nadig <[email protected]>
- Loading branch information
1 parent
f417024
commit c13bb07
Showing
5 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Disposable, TerminalShellExecutionStartEvent } from 'vscode'; | ||
import { onDidStartTerminalShellExecution } from '../../common/vscodeApis/windowApis'; | ||
import { sendTelemetryEvent } from '../../telemetry'; | ||
import { EventName } from '../../telemetry/constants'; | ||
|
||
function checkREPLCommand(command: string): boolean { | ||
const lower = command.toLowerCase().trimStart(); | ||
return lower.startsWith('python ') || lower.startsWith('py '); | ||
} | ||
|
||
export function registerTriggerForTerminalREPL(disposables: Disposable[]): void { | ||
disposables.push( | ||
onDidStartTerminalShellExecution(async (e: TerminalShellExecutionStartEvent) => { | ||
if (e.execution.commandLine.isTrusted && checkREPLCommand(e.execution.commandLine.value)) { | ||
sendTelemetryEvent(EventName.REPL, undefined, { replType: 'Terminal' }); | ||
} | ||
}), | ||
); | ||
} |