|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +'use strict'; |
| 5 | + |
| 6 | +import * as fs from 'fs-extra'; |
| 7 | +import * as path from 'path'; |
| 8 | +import { executeCommand } from '../../vscodeapi'; |
| 9 | +import { getActiveEnvironmentPath, resolveEnvironment } from '../../python'; |
| 10 | +import { EXTENSION_ROOT_DIR } from '../../constants'; |
| 11 | +import { getRawVersion } from '../../settings'; |
| 12 | +import { sendTelemetryEvent } from '../../../telemetry'; |
| 13 | +import { EventName } from '../../../telemetry/constants'; |
| 14 | + |
| 15 | +/** |
| 16 | + * Allows the user to report an issue related to the Python Debugger extension using our template. |
| 17 | + */ |
| 18 | +export async function openReportIssue(): Promise<void> { |
| 19 | + const templatePath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_template.md'); |
| 20 | + const userDataTemplatePath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_user_data_template.md'); |
| 21 | + const template = await fs.readFile(templatePath, 'utf8'); |
| 22 | + const userTemplate = await fs.readFile(userDataTemplatePath, 'utf8'); |
| 23 | + const interpreterPath = await getActiveEnvironmentPath(); |
| 24 | + const interpreter = await resolveEnvironment(interpreterPath); |
| 25 | + const virtualEnvKind = interpreter?.environment?.type || 'Unknown'; |
| 26 | + |
| 27 | + const pythonVersion = getRawVersion(interpreter?.version); |
| 28 | + await executeCommand('workbench.action.openIssueReporter', { |
| 29 | + extensionId: 'ms-python.debugpy', |
| 30 | + issueBody: template, |
| 31 | + data: userTemplate.replace('{0}', pythonVersion).replace('{1}', virtualEnvKind), |
| 32 | + }); |
| 33 | + sendTelemetryEvent(EventName.USE_REPORT_ISSUE_COMMAND, undefined, {}); |
| 34 | +} |
0 commit comments