@@ -20,30 +20,47 @@ Index: code-server/lib/vscode/src/vs/server/node/serverServices.ts
20
20
import { NullPolicyService } from 'vs/platform/policy/common/policy';
21
21
import { OneDataSystemAppender } from 'vs/platform/telemetry/node/1dsAppender';
22
22
import { LoggerService } from 'vs/platform/log/node/loggerService';
23
- @@ -149,7 +150,10 @@ export async function setupServerService
23
+ @@ -146,11 +147,23 @@ export async function setupServerService
24
+ const requestService = new RequestService(configurationService, environmentService, logService, loggerService);
25
+ services.set(IRequestService, requestService);
26
+
27
+ + let isContainer = undefined;
28
+ + try {
29
+ + await Promises.stat('/run/.containerenv');
30
+ + isContainer = true;
31
+ + } catch (error) { /* Does not exist, probably. */ }
32
+ + if (!isContainer) {
33
+ + try {
34
+ + const content = await Promises.readFile('/proc/self/cgroup', 'utf8')
35
+ + isContainer = content.includes('docker');
36
+ + } catch (error) { /* Permission denied, probably. */ }
37
+ + }
38
+ +
24
39
let oneDsAppender: ITelemetryAppender = NullAppender;
25
40
const isInternal = isInternalTelemetry(productService, configurationService);
26
41
if (supportsTelemetry(productService, environmentService)) {
27
42
- if (!isLoggingOnly(productService, environmentService) && productService.aiConfig?.ariaKey) {
28
- + const telemetryEndpoint = process.env.CS_TELEMETRY_URL || "https://v1.telemetry.coder.com/track";
29
- + if (telemetryEndpoint) {
30
- + oneDsAppender = new OneDataSystemAppender(requestService, false, eventPrefix, null, () => new TelemetryClient(telemetryEndpoint));
31
- + } else if (!isLoggingOnly(productService, environmentService) && productService.aiConfig?.ariaKey) {
32
- oneDsAppender = new OneDataSystemAppender(requestService, isInternal, eventPrefix, null, productService.aiConfig.ariaKey);
43
+ - oneDsAppender = new OneDataSystemAppender(requestService, isInternal, eventPrefix, null, productService.aiConfig.ariaKey);
44
+ + if (!isLoggingOnly(productService, environmentService) && productService.telemetryEndpoint) {
45
+ + oneDsAppender = new OneDataSystemAppender(requestService, isInternal, eventPrefix, null, () => new TelemetryClient(productService.telemetryEndpoint!, machineId, isContainer));
33
46
disposables.add(toDisposable(() => oneDsAppender?.flush())); // Ensure the AI appender is disposed so that it flushes remaining data
34
47
}
48
+
35
49
Index: code-server/lib/vscode/src/vs/server/node/telemetryClient.ts
36
50
===================================================================
37
51
--- /dev/null
38
52
+++ code-server/lib/vscode/src/vs/server/node/telemetryClient.ts
39
- @@ -0,0 +1,49 @@
53
+ @@ -0,0 +1,55 @@
40
54
+ import { AppInsightsCore, IExtendedTelemetryItem, ITelemetryItem } from '@microsoft/1ds-core-js';
41
55
+ import * as https from 'https';
42
56
+ import * as http from 'http';
43
57
+ import * as os from 'os';
44
58
+
45
59
+ export class TelemetryClient extends AppInsightsCore {
46
- + public constructor(private readonly endpoint: string) {
60
+ + public constructor(
61
+ + private readonly endpoint: string,
62
+ + private readonly machineId: string,
63
+ + private readonly isContainer: Boolean | undefined) {
47
64
+ super();
48
65
+ }
49
66
+
@@ -73,6 +90,9 @@ Index: code-server/lib/vscode/src/vs/server/node/telemetryClient.ts
73
90
+ options.properties['common.arch'] = os.arch();
74
91
+ } catch (error) {}
75
92
+
93
+ + options.properties['common.remoteMachineId'] = this.machineId;
94
+ + options.properties['common.isContainer'] = this.isContainer;
95
+ +
76
96
+ try {
77
97
+ const request = (/^http:/.test(this.endpoint) ? http : https).request(this.endpoint, {
78
98
+ method: 'POST',
@@ -90,11 +110,38 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
90
110
===================================================================
91
111
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
92
112
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
93
- @@ -318,6 +318,7 @@ export class WebClientServer {
113
+ @@ -318,6 +318,8 @@ export class WebClientServer {
94
114
scope: vscodeBase + '/',
95
115
path: base + '/_static/out/browser/serviceWorker.js',
96
116
},
97
117
+ enableTelemetry: this._productService.enableTelemetry,
118
+ + telemetryEndpoint: this._productService.telemetryEndpoint,
98
119
embedderIdentifier: 'server-distro',
99
120
extensionsGallery: this._productService.extensionsGallery,
100
121
};
122
+ Index: code-server/lib/vscode/src/vs/base/common/product.ts
123
+ ===================================================================
124
+ --- code-server.orig/lib/vscode/src/vs/base/common/product.ts
125
+ +++ code-server/lib/vscode/src/vs/base/common/product.ts
126
+ @@ -64,6 +64,7 @@ export interface IProductConfiguration {
127
+ readonly path: string;
128
+ readonly scope: string;
129
+ }
130
+ + readonly telemetryEndpoint?: string
131
+
132
+ readonly version: string;
133
+ readonly date?: string;
134
+ Index: code-server/lib/vscode/src/vs/platform/product/common/product.ts
135
+ ===================================================================
136
+ --- code-server.orig/lib/vscode/src/vs/platform/product/common/product.ts
137
+ +++ code-server/lib/vscode/src/vs/platform/product/common/product.ts
138
+ @@ -55,7 +55,8 @@ else if (globalThis._VSCODE_PRODUCT_JSON
139
+ resourceUrlTemplate: "https://open-vsx.org/vscode/asset/{publisher}/{name}/{version}/Microsoft.VisualStudio.Code.WebResources/{path}",
140
+ controlUrl: "",
141
+ recommendationsUrl: "",
142
+ - })
143
+ + }),
144
+ + telemetryEndpoint: env.CS_TELEMETRY_URL || product.telemetryEndpoint || "https://v1.telemetry.coder.com/track",
145
+ });
146
+ }
147
+
0 commit comments