From ebbc6591de225f5c8d9e921cdbb07fcd7d7c11a1 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sun, 5 Apr 2020 09:12:10 -0700 Subject: [PATCH] Report linux desktop-related env vars in issue reporter Fixes #94388 --- .../issue/issueReporterModel.ts | 9 +++- .../issue/test/testReporterModel.test.ts | 49 +++++++++++++++++++ .../diagnostics/common/diagnostics.ts | 8 +++ .../diagnostics/node/diagnosticsService.ts | 12 ++++- 4 files changed, 75 insertions(+), 3 deletions(-) diff --git a/src/vs/code/electron-browser/issue/issueReporterModel.ts b/src/vs/code/electron-browser/issue/issueReporterModel.ts index 6c7fa528e3770..96bae9110ee2f 100644 --- a/src/vs/code/electron-browser/issue/issueReporterModel.ts +++ b/src/vs/code/electron-browser/issue/issueReporterModel.ts @@ -168,6 +168,13 @@ ${this.getInfos()} |Screen Reader|${this._data.systemInfo.screenReader}| |VM|${this._data.systemInfo.vmHint}|`; + if (this._data.systemInfo.linuxEnv) { + md += `\n|DESKTOP_SESSION|${this._data.systemInfo.linuxEnv.desktopSession}| +|XDG_CURRENT_DESKTOP|${this._data.systemInfo.linuxEnv.xdgCurrentDesktop}| +|XDG_SESSION_DESKTOP|${this._data.systemInfo.linuxEnv.xdgSessionDesktop}| +|XDG_SESSION_TYPE|${this._data.systemInfo.linuxEnv.xdgSessionType}|`; + } + this._data.systemInfo.remoteData.forEach(remote => { if (isRemoteDiagnosticError(remote)) { md += `\n\n${remote.errorMessage}`; @@ -268,4 +275,4 @@ ${table} `; } -} \ No newline at end of file +} diff --git a/src/vs/code/electron-browser/issue/test/testReporterModel.test.ts b/src/vs/code/electron-browser/issue/test/testReporterModel.test.ts index b34917961c05b..6be44cf35ca97 100644 --- a/src/vs/code/electron-browser/issue/test/testReporterModel.test.ts +++ b/src/vs/code/electron-browser/issue/test/testReporterModel.test.ts @@ -81,6 +81,55 @@ OS version: undefined `); }); + test('serializes Linux environment information when data is provided', () => { + const issueReporterModel = new IssueReporterModel({ + issueType: 0, + systemInfo: { + os: 'Darwin', + cpus: 'Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800)', + memory: '16.00GB', + vmHint: '0%', + processArgs: '', + screenReader: 'no', + remoteData: [], + gpuStatus: {}, + linuxEnv: { + desktopSession: 'ubuntu', + xdgCurrentDesktop: 'ubuntu', + xdgSessionDesktop: 'ubuntu:GNOME', + xdgSessionType: 'x11' + } + } + }); + assert.equal(issueReporterModel.serialize(), + ` +Issue Type: Bug + +undefined + +VS Code version: undefined +OS version: undefined + +
+System Info + +|Item|Value| +|---|---| +|CPUs|Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800)| +|GPU Status|| +|Load (avg)|undefined| +|Memory (System)|16.00GB| +|Process Argv|| +|Screen Reader|no| +|VM|0%| +|DESKTOP_SESSION|ubuntu| +|XDG_CURRENT_DESKTOP|ubuntu| +|XDG_SESSION_DESKTOP|ubuntu:GNOME| +|XDG_SESSION_TYPE|x11| +
Extensions: none +`); + }); + test('serializes remote information when data is provided', () => { const issueReporterModel = new IssueReporterModel({ issueType: 0, diff --git a/src/vs/platform/diagnostics/common/diagnostics.ts b/src/vs/platform/diagnostics/common/diagnostics.ts index 31a4ee17474fa..c283b80e6ef7e 100644 --- a/src/vs/platform/diagnostics/common/diagnostics.ts +++ b/src/vs/platform/diagnostics/common/diagnostics.ts @@ -13,6 +13,14 @@ export interface IMachineInfo { cpus?: string; memory: string; vmHint: string; + linuxEnv?: ILinuxEnv; +} + +export interface ILinuxEnv { + desktopSession?: string; + xdgSessionDesktop?: string; + xdgCurrentDesktop?: string; + xdgSessionType?: string; } export interface IDiagnosticInfo { diff --git a/src/vs/platform/diagnostics/node/diagnosticsService.ts b/src/vs/platform/diagnostics/node/diagnosticsService.ts index b423cbae2eb67..6fddf2b2822e8 100644 --- a/src/vs/platform/diagnostics/node/diagnosticsService.ts +++ b/src/vs/platform/diagnostics/node/diagnosticsService.ts @@ -11,7 +11,7 @@ import { parse, ParseError, getNodeType } from 'vs/base/common/json'; import { listProcesses } from 'vs/base/node/ps'; import product from 'vs/platform/product/common/product'; import { repeat, pad } from 'vs/base/common/strings'; -import { isWindows } from 'vs/base/common/platform'; +import { isWindows, isLinux } from 'vs/base/common/platform'; import { URI } from 'vs/base/common/uri'; import { ProcessItem } from 'vs/base/common/processes'; import { IMainProcessInfo } from 'vs/platform/launch/common/launch'; @@ -336,11 +336,19 @@ export class DiagnosticsService implements IDiagnosticsService { remoteData }; - if (!isWindows) { systemInfo.load = `${osLib.loadavg().map(l => Math.round(l)).join(', ')}`; } + if (isLinux) { + systemInfo.linuxEnv = { + desktopSession: process.env.DESKTOP_SESSION, + xdgSessionDesktop: process.env.XDG_SESSION_DESKTOP, + xdgCurrentDesktop: process.env.XDG_CURRENT_DESKTOP, + xdgSessionType: process.env.XDG_SESSION_TYPE + }; + } + return Promise.resolve(systemInfo); }