|
1 | 1 | import { getDefaultEnvManagerSetting, getDefaultPkgManagerSetting } from '../../features/settings/settingHelpers'; |
2 | 2 | import { EnvironmentManagers, PythonProjectManager } from '../../internal.api'; |
| 3 | +import { getUvEnvironments } from '../../managers/builtin/uvEnvironments'; |
3 | 4 | import { getWorkspaceFolders } from '../workspace.apis'; |
4 | 5 | import { EventNames } from './constants'; |
5 | 6 | import { sendTelemetryEvent } from './sender'; |
@@ -115,19 +116,23 @@ export async function sendEnvironmentToolUsageTelemetry( |
115 | 116 | try { |
116 | 117 | const env = await envManagers.getEnvironment(project.uri); |
117 | 118 | if (env?.envId?.managerId) { |
118 | | - const toolName = extractToolName(env.envId.managerId); |
119 | | - |
120 | | - // Check if this is a UV environment (UV uses venv manager but has 'uv' in description) |
121 | | - const isUv = env.description?.toLowerCase().includes('uv') ?? false; |
122 | | - |
123 | | - // Determine the tool name |
124 | | - if (isUv) { |
125 | | - toolsUsed.add('uv'); |
126 | | - } else { |
127 | | - // Normalize 'global' to 'system' for consistency |
128 | | - const normalizedTool = toolName === 'global' ? 'system' : toolName; |
129 | | - toolsUsed.add(normalizedTool); |
| 119 | + let toolName = extractToolName(env.envId.managerId); |
| 120 | + |
| 121 | + // UV environments share the venv manager. Check the persistent UV env list instead |
| 122 | + if (toolName === 'venv' && env.environmentPath) { |
| 123 | + // Lazily load UV environment paths only when a venv environment is encountered |
| 124 | + const uvEnvPaths = await getUvEnvironments(); |
| 125 | + if (uvEnvPaths.includes(env.environmentPath.fsPath)) { |
| 126 | + toolName = 'uv'; |
| 127 | + } |
130 | 128 | } |
| 129 | + |
| 130 | + // Normalize 'global' to 'system' for consistency |
| 131 | + if (toolName === 'global') { |
| 132 | + toolName = 'system'; |
| 133 | + } |
| 134 | + |
| 135 | + toolsUsed.add(toolName); |
131 | 136 | } |
132 | 137 | } catch { |
133 | 138 | // Ignore errors when getting environment for a project |
|
0 commit comments