From cdbbe361ce33f514225e06ef8b9881954d30c15f Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Wed, 20 Sep 2023 15:28:13 +0800 Subject: [PATCH 1/3] Flatten the log entities Signed-off-by: Sheng Chen --- extension/src/bs/BuildServerController.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/extension/src/bs/BuildServerController.ts b/extension/src/bs/BuildServerController.ts index c19d3718a..f1a193e6f 100644 --- a/extension/src/bs/BuildServerController.ts +++ b/extension/src/bs/BuildServerController.ts @@ -61,7 +61,7 @@ export class BuildServerController implements Disposable { }), commands.registerCommand(SEND_TELEMETRY_CMD, (jsonString: string) => { const log = JSON.parse(jsonString); - sendInfo("", log); + sendInfo("", this.flattenAdditionalProperties(log)); }), workspace.onDidChangeConfiguration((e: ConfigurationChangeEvent) => { if (e.affectsConfiguration("java.gradle.buildServer.enabled")) { @@ -92,4 +92,19 @@ export class BuildServerController implements Disposable { public dispose() { this.disposable.dispose(); } + + private flattenAdditionalProperties(obj: any) { + const flattened: { [key: string]: any } = {}; + + Object.keys(obj).forEach((key) => { + const value = obj[key]; + if (typeof value === "object" && value !== null && !Array.isArray(value)) { + Object.assign(flattened, this.flattenAdditionalProperties(value)); + } else { + flattened[key] = value; + } + }); + + return flattened; + } } From bcfd80f2eb8be2864acd0d576061359f6f5b19ad Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Thu, 21 Sep 2023 15:57:33 +0800 Subject: [PATCH 2/3] Use new schema Signed-off-by: Sheng Chen --- extension/src/bs/BuildServerController.ts | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/extension/src/bs/BuildServerController.ts b/extension/src/bs/BuildServerController.ts index f1a193e6f..4626cbbe8 100644 --- a/extension/src/bs/BuildServerController.ts +++ b/extension/src/bs/BuildServerController.ts @@ -61,7 +61,12 @@ export class BuildServerController implements Disposable { }), commands.registerCommand(SEND_TELEMETRY_CMD, (jsonString: string) => { const log = JSON.parse(jsonString); - sendInfo("", this.flattenAdditionalProperties(log)); + const obj = { + kind: log.kind, + data: jsonString, + ...log.schemaVersion && {schemaVersion: log.schemaVersion}, + }; + sendInfo("", obj); }), workspace.onDidChangeConfiguration((e: ConfigurationChangeEvent) => { if (e.affectsConfiguration("java.gradle.buildServer.enabled")) { @@ -92,19 +97,4 @@ export class BuildServerController implements Disposable { public dispose() { this.disposable.dispose(); } - - private flattenAdditionalProperties(obj: any) { - const flattened: { [key: string]: any } = {}; - - Object.keys(obj).forEach((key) => { - const value = obj[key]; - if (typeof value === "object" && value !== null && !Array.isArray(value)) { - Object.assign(flattened, this.flattenAdditionalProperties(value)); - } else { - flattened[key] = value; - } - }); - - return flattened; - } } From 021aab25b8b53e48ae1d59700f33e95ede77f359 Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Thu, 21 Sep 2023 16:03:00 +0800 Subject: [PATCH 3/3] Fix lint --- extension/src/bs/BuildServerController.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/extension/src/bs/BuildServerController.ts b/extension/src/bs/BuildServerController.ts index 4626cbbe8..47b00f229 100644 --- a/extension/src/bs/BuildServerController.ts +++ b/extension/src/bs/BuildServerController.ts @@ -61,12 +61,11 @@ export class BuildServerController implements Disposable { }), commands.registerCommand(SEND_TELEMETRY_CMD, (jsonString: string) => { const log = JSON.parse(jsonString); - const obj = { + sendInfo("", { kind: log.kind, data: jsonString, - ...log.schemaVersion && {schemaVersion: log.schemaVersion}, - }; - sendInfo("", obj); + ...(log.schemaVersion && { schemaVersion: log.schemaVersion }), + }); }), workspace.onDidChangeConfiguration((e: ConfigurationChangeEvent) => { if (e.affectsConfiguration("java.gradle.buildServer.enabled")) {