Skip to content

Record if certain extensions are installed #114

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

Merged
merged 2 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions TELEMETRY.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ If you have already opted out of sending telemetry in Visual Studio Code then no
- Docker version
- function names and parameters for diagnosing errors and crashes
- error messages when the language server is unable to start or is crashing
- if certain extensions are also installed
- [Microsoft's Container Tools extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-containers)
- [Microsoft's Docker extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker)
- [Red Hat's YAML extension](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml)

The list above does _not_ include any telemetry collected by the [Docker Language Server](https://github.com/docker/docker-language-server). For telemetry collected by the Docker Language Server, please refer to the telemetry documentation of that project.

Expand Down
12 changes: 12 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ function listenForConfigurationChanges(ctx: vscode.ExtensionContext) {
}

function recordVersionTelemetry() {
const installedExtensions = vscode.extensions.all
.filter((extension) => {
return (
extension.id === 'ms-azuretools.vscode-docker' ||
extension.id === 'ms-azuretools.vscode-containers' ||
extension.id === 'redhat.vscode-yaml'
);
})
.map((extension) => extension.id);
let versionString: string | null = null;
const process = spawn('docker', ['-v']);
process.stdout.on('data', (data) => {
Expand All @@ -223,17 +232,20 @@ function recordVersionTelemetry() {
// this happens if docker cannot be found on the PATH
queueTelemetryEvent(EVENT_CLIENT_HEARTBEAT, false, {
docker_version: 'spawn docker -v failed',
installedExtensions,
});
publishTelemetry();
});
process.on('exit', (code) => {
if (code === 0) {
queueTelemetryEvent(EVENT_CLIENT_HEARTBEAT, false, {
docker_version: String(versionString),
installedExtensions,
});
} else {
queueTelemetryEvent(EVENT_CLIENT_HEARTBEAT, false, {
docker_version: String(code),
installedExtensions,
});
}
publishTelemetry();
Expand Down
4 changes: 2 additions & 2 deletions src/telemetry/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ interface TelemetryRecord {
event: string;
source: string;
event_timestamp: number;
properties: { [key: string]: boolean | number | string | undefined };
properties: { [key: string]: boolean | number | string | object | undefined };
}

const events: TelemetryRecord[] = [];

export function queueTelemetryEvent(
event: string,
error: boolean,
properties: { [key: string]: boolean | number | string | undefined },
properties: { [key: string]: boolean | number | string | object | undefined },
) {
if (!vscode.env.isTelemetryEnabled) {
return;
Expand Down
Loading