Skip to content

Add telemetry for when user triggers testing from CLI #25103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented May 23, 2025

This PR adds telemetry to capture when users run Python tests via the command line in the terminal. This helps us get a better understanding of testing usage in the extension outside of the testing UI.

Changes

  • Added a new telemetry event constant UNITTEST_RUN_CLI to track CLI test execution
  • Updated the telemetry interface to include the new event with proper GDPR comments
  • Enhanced the terminal command detection to identify test commands:
    • python -m pytest, pytest, py.test
    • python -m unittest
    • python -m nose
  • Added unit tests to validate the functionality

Implementation

The implementation uses the existing terminal command detection system that already tracks when users run Python scripts in the terminal. When a test command is detected, we send a specific telemetry event rather than the general REPL telemetry.

This implementation has minimal impact on performance as it just adds an additional condition to the existing command detection logic that already runs for every terminal command. The telemetry is sent asynchronously and doesn't block terminal execution.

Fixes #24562.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.fwupd.org
    • Triggering command: /usr/bin/fwupdmgr refresh (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Add telemetry for when user triggers testing from CLI Add telemetry for when user triggers testing from CLI May 23, 2025
@Copilot Copilot AI requested a review from karthiknadig May 23, 2025 01:01
Copilot finished work on behalf of karthiknadig May 23, 2025 01:01
Copy link
Member

@karthiknadig karthiknadig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove nose. We don’t support that anymore.

Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
Copy link
Author

Copilot AI commented May 23, 2025

Remove nose. We don’t support that anymore.

I've removed nose test support as requested. All related detection code and test cases have been removed in commit 097da2d.

Copilot finished work on behalf of karthiknadig May 23, 2025 06:11
Copilot finished work on behalf of karthiknadig May 23, 2025 16:57
@karthiknadig karthiknadig dismissed their stale review May 23, 2025 17:10

Comment addressed

@karthiknadig karthiknadig added debt Covers everything internal: CI, testing, refactoring of the codebase, etc. skip-issue-check labels May 23, 2025
eleanorjboyd
eleanorjboyd previously approved these changes May 27, 2025
@eleanorjboyd
Copy link
Member

eleanorjboyd commented May 27, 2025

looks good to me- fixed linting as well. @karthiknadig am I good to take this out of draft and get reviews? [edit nvm]

@karthiknadig karthiknadig marked this pull request as ready for review May 27, 2025 15:27
@vs-code-engineering vs-code-engineering bot added this to the May 2025 milestone May 27, 2025
@karthiknadig karthiknadig enabled auto-merge (squash) May 27, 2025 17:34
@karthiknadig karthiknadig requested a review from anthonykim1 May 27, 2025 17:34
// Check for test commands
if (
lower.includes('pytest') ||
(lower.startsWith('python') && lower.includes(' -m pytest')) ||

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can consolidate (lower.startsWith('python') && lower.includes(' -m pytest')) || (lower.startsWith('py ') && lower.includes(' -m pytest')) || (lower.startsWith('python') && lower.includes(' -m unittest')) || (lower.startsWith('py ') && lower.includes(' -m unittest')) ||
into two conditionals. One for starting with 'python' other for 'py'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've consolidated the conditionals as suggested into two statements - one for commands starting with 'python' and another for commands starting with 'py'. This makes the code more readable while maintaining the same functionality. All tests are passing. Changes in commit 6d2e428.

Co-authored-by: anthonykim1 <62267334+anthonykim1@users.noreply.github.com>
Copilot finished work on behalf of anthonykim1 May 27, 2025 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debt Covers everything internal: CI, testing, refactoring of the codebase, etc. skip-issue-check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add telemetry for when user triggers testing from CLI
4 participants