@@ -20,14 +20,29 @@ 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,10 +147,25 @@ 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
43
+ const telemetryEndpoint = process.env.CS_TELEMETRY_URL || "https://v1.telemetry.coder.com/track";
29
44
+ if (telemetryEndpoint) {
30
- + oneDsAppender = new OneDataSystemAppender(requestService, false, eventPrefix, null, () => new TelemetryClient(telemetryEndpoint));
45
+ + oneDsAppender = new OneDataSystemAppender(requestService, false, eventPrefix, null, () => new TelemetryClient(telemetryEndpoint, isContainer ));
31
46
+ } else if (!isLoggingOnly(productService, environmentService) && productService.aiConfig?.ariaKey) {
32
47
oneDsAppender = new OneDataSystemAppender(requestService, isInternal, eventPrefix, null, productService.aiConfig.ariaKey);
33
48
disposables.add(toDisposable(() => oneDsAppender?.flush())); // Ensure the AI appender is disposed so that it flushes remaining data
@@ -36,14 +51,16 @@ Index: code-server/lib/vscode/src/vs/server/node/telemetryClient.ts
36
51
===================================================================
37
52
--- /dev/null
38
53
+++ code-server/lib/vscode/src/vs/server/node/telemetryClient.ts
39
- @@ -0,0 +1,49 @@
54
+ @@ -0,0 +1,53 @@
40
55
+ import { AppInsightsCore, IExtendedTelemetryItem, ITelemetryItem } from '@microsoft/1ds-core-js';
41
56
+ import * as https from 'https';
42
57
+ import * as http from 'http';
43
58
+ import * as os from 'os';
44
59
+
45
60
+ export class TelemetryClient extends AppInsightsCore {
46
- + public constructor(private readonly endpoint: string) {
61
+ + public constructor(
62
+ + private readonly endpoint: string,
63
+ + private readonly isContainer: Boolean | undefined) {
47
64
+ super();
48
65
+ }
49
66
+
@@ -73,6 +90,8 @@ 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.isContainer'] = this.isContainer;
94
+ +
76
95
+ try {
77
96
+ const request = (/^http:/.test(this.endpoint) ? http : https).request(this.endpoint, {
78
97
+ method: 'POST',
0 commit comments