From 2633bca30b5b9294ba12f426d547a3b22bba9671 Mon Sep 17 00:00:00 2001 From: Asher Date: Mon, 6 May 2024 16:58:07 -0800 Subject: [PATCH] Move telemetry endpoint to product service This will let us use it in the client. --- patches/display-language.diff | 6 +++--- patches/getting-started.diff | 2 +- patches/telemetry.diff | 31 +++++++++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/patches/display-language.diff b/patches/display-language.diff index 94e8f23e0..6c802696a 100644 --- a/patches/display-language.diff +++ b/patches/display-language.diff @@ -30,7 +30,7 @@ Index: code-server/lib/vscode/src/vs/server/node/serverServices.ts import { ProtocolConstants } from 'vs/base/parts/ipc/common/ipc.net'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ConfigurationService } from 'vs/platform/configuration/common/configurationService'; -@@ -239,6 +239,9 @@ export async function setupServerService +@@ -240,6 +240,9 @@ export async function setupServerService const channel = new ExtensionManagementChannel(extensionManagementService, (ctx: RemoteAgentConnectionContext) => getUriTransformer(ctx.remoteAuthority)); socketServer.registerChannel('extensions', channel); @@ -220,7 +220,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts import { CharCode } from 'vs/base/common/charCode'; import { IExtensionManifest } from 'vs/platform/extensions/common/extensions'; -@@ -347,6 +348,8 @@ export class WebClientServer { +@@ -348,6 +349,8 @@ export class WebClientServer { callbackRoute: this._callbackRoute }; @@ -229,7 +229,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts const nlsBaseUrl = this._productService.extensionsGallery?.nlsBaseUrl; const values: { [key: string]: string } = { WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration), -@@ -355,6 +358,7 @@ export class WebClientServer { +@@ -356,6 +359,7 @@ export class WebClientServer { WORKBENCH_NLS_BASE_URL: vscodeBase + (nlsBaseUrl ? `${nlsBaseUrl}${!nlsBaseUrl.endsWith('/') ? '/' : ''}${this._productService.commit}/${this._productService.version}/` : ''), BASE: base, VS_BASE: vscodeBase, diff --git a/patches/getting-started.diff b/patches/getting-started.diff index e278c62b2..c2eb9002d 100644 --- a/patches/getting-started.diff +++ b/patches/getting-started.diff @@ -201,7 +201,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts +++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts -@@ -338,6 +338,7 @@ export class WebClientServer { +@@ -339,6 +339,7 @@ export class WebClientServer { userDataPath: this._environmentService.userDataPath, isEnabledFileDownloads: !this._environmentService.args['disable-file-downloads'], isEnabledFileUploads: !this._environmentService.args['disable-file-uploads'], diff --git a/patches/telemetry.diff b/patches/telemetry.diff index 15234f6d4..eac843a04 100644 --- a/patches/telemetry.diff +++ b/patches/telemetry.diff @@ -40,7 +40,7 @@ Index: code-server/lib/vscode/src/vs/server/node/serverServices.ts const isInternal = isInternalTelemetry(productService, configurationService); if (supportsTelemetry(productService, environmentService)) { - if (!isLoggingOnly(productService, environmentService) && productService.aiConfig?.ariaKey) { -+ const telemetryEndpoint = process.env.CS_TELEMETRY_URL || "https://v1.telemetry.coder.com/track"; ++ const telemetryEndpoint = productService.telemetryEndpoint; + if (telemetryEndpoint) { + oneDsAppender = new OneDataSystemAppender(requestService, false, eventPrefix, null, () => new TelemetryClient(telemetryEndpoint, isContainer)); + } else if (!isLoggingOnly(productService, environmentService) && productService.aiConfig?.ariaKey) { @@ -109,11 +109,38 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts +++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts -@@ -318,6 +318,7 @@ export class WebClientServer { +@@ -318,6 +318,8 @@ export class WebClientServer { scope: vscodeBase + '/', path: base + '/_static/out/browser/serviceWorker.js', }, + enableTelemetry: this._productService.enableTelemetry, ++ telemetryEndpoint: this._productService.telemetryEndpoint, embedderIdentifier: 'server-distro', extensionsGallery: this._productService.extensionsGallery, }; +Index: code-server/lib/vscode/src/vs/base/common/product.ts +=================================================================== +--- code-server.orig/lib/vscode/src/vs/base/common/product.ts ++++ code-server/lib/vscode/src/vs/base/common/product.ts +@@ -64,6 +64,7 @@ export interface IProductConfiguration { + readonly path: string; + readonly scope: string; + } ++ readonly telemetryEndpoint?: string + + readonly version: string; + readonly date?: string; +Index: code-server/lib/vscode/src/vs/platform/product/common/product.ts +=================================================================== +--- code-server.orig/lib/vscode/src/vs/platform/product/common/product.ts ++++ code-server/lib/vscode/src/vs/platform/product/common/product.ts +@@ -55,7 +55,8 @@ else if (globalThis._VSCODE_PRODUCT_JSON + resourceUrlTemplate: "https://open-vsx.org/vscode/asset/{publisher}/{name}/{version}/Microsoft.VisualStudio.Code.WebResources/{path}", + controlUrl: "", + recommendationsUrl: "", +- }) ++ }), ++ telemetryEndpoint: env.CS_TELEMETRY_URL || product.telemetryEndpoint || "https://v1.telemetry.coder.com/track", + }); + } +