diff --git a/src/telemetry.ts b/src/telemetry.ts index 382b4c940..35f702603 100644 --- a/src/telemetry.ts +++ b/src/telemetry.ts @@ -25,9 +25,9 @@ export namespace Telemetry { if (!!telemetryManager) { throw new Error("The telemetry service for vscode-java has already been started"); } - workspaceHash = cyrb53(workspace.workspaceFolders.map(f => f.uri.toString()).join('|')); + workspaceHash = computeWorkspaceHash(); workspace.onDidChangeWorkspaceFolders(() => { - workspaceHash = cyrb53(workspace.workspaceFolders.map(f => f.uri.toString()).join('|')); + workspaceHash = computeWorkspaceHash(); }); const redhatService = await getRedHatService(context); const telemService = await redhatService.getTelemetryService(); @@ -35,6 +35,13 @@ export namespace Telemetry { return telemService; } + function computeWorkspaceHash(): number { + if (!workspace.workspaceFolders?.length) { + return 0; + } + return cyrb53(workspace.workspaceFolders.map(f => f.uri.toString()).join('|')); + } + /** * Send a telemetry event with the given name and data *