This guide explains how to add an issue reporter feature to your VS Code extension, allowing users to easily report issues with relevant log output attached. It covers command registration, menu contributions, and the command callback implementation, with code snippets for each step.
NOTE: This example uses logTester as the extension name, but this would be your extension id.
Add a new command to your extension's package.json to register the issue reporter command:
// package.json
"contributes": {
"commands": [
{
"command": "logTester.reportIssue",
"title": "Log Tester: Report Issue"
}
]
}When users invoke this command it will launch the Issue Reporter pre-filled with the extension ID selected.
To make the command accessible from the Command Palette and Issue Reporter, add it to the menus section:
// package.json
"contributes": {
"menus": {
"commandPalette": [
{
"command": "logTester.reportIssue",
"when": "true"
}
],
"issue/reporter": [
{
"command": "logTester.reportIssue"
}
]
}
}In your extension's main file (e.g., src/extension.ts), implement the command callback. This example collects log output and opens the issue reporter:
// src/extension.ts
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
// ...existing code...
const reportIssueCommand = vscode.commands.registerCommand('logTester.reportIssue', async () => {
// Get whatever data you may want to add like log outputs or anything
const logOutput = '...collect log output here...';
// This will wrap it nicely for a GitHub issue in a collapsable section
const wrappedLog = `<details><summary>Log Output</summary><pre>${logOutput}</pre></details>`;
// Open the issue reporter with log output attached
await vscode.commands.executeCommand('vscode.openIssueReporter', {
extensionId: 'your-publisher-name.your-extension-id',
data: wrappedLog
});
});
context.subscriptions.push(reportIssueCommand);
// ...existing code...
}With these steps, your extension will provide a convenient way for users to report issues with relevant log output included, improving diagnostics and support. This will provide Additional Extension Info automatically (with the ability for the user to unselect that before submitting):