Skip to content

Commit c3a38e3

Browse files
authored
Add telemetry and option to disable (coder#519)
* Add telemetry and option to disable * Update readme and getting-started guide * Update lockfile * Update getting started guide
1 parent cc8c7e2 commit c3a38e3

File tree

9 files changed

+221
-26
lines changed

9 files changed

+221
-26
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ How to [secure your setup](/doc/security/ssl.md).
6363
6464
At the moment we can't use the official VSCode Marketplace. We've created a custom extension marketplace focused around open-sourced extensions. However, if you have access to the `.vsix` file, you can manually install the extension.
6565
66+
## Telemetry
67+
68+
Use the `--disable-telemetry` flag or set `DISABLE_TELEMETRY=true` to disable tracking ENTIRELY.
69+
70+
We use data collected to improve code-server.
71+
6672
## Contributing
6773
6874
Development guides are coming soon.

doc/self-hosted/index.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,29 @@ It takes just a few minutes to get your own self-hosted server running. If you'v
3434
code-server can be ran with a number of arguments to customize your working directory, host, port, and SSL certificate.
3535

3636
```
37-
USAGE
38-
$ code-server [WORKDIR]
39-
40-
ARGUMENTS
41-
WORKDIR [default: (directory to binary)] Specify working dir
42-
43-
OPTIONS
44-
-d, --data-dir=data-dir
45-
-h, --host=host [default: 0.0.0.0]
46-
-o, --open Open in browser on startup
47-
-p, --port=port [default: 8443] Port to bind on
48-
-v, --version show CLI version
49-
--allow-http
50-
--cert=cert
51-
--cert-key=cert-key
52-
--help show CLI help
53-
--no-auth
54-
--password=password
37+
Usage: code-server [options]
38+
39+
Run VS Code on a remote server.
40+
41+
Options:
42+
-V, --version output the version number
43+
--cert <value>
44+
--cert-key <value>
45+
-e, --extensions-dir <dir> Set the root path for extensions.
46+
-d --user-data-dir <dir> Specifies the directory that user data is kept in, useful when running as root.
47+
--data-dir <value> DEPRECATED: Use '--user-data-dir' instead. Customize where user-data is stored.
48+
-h, --host <value> Customize the hostname. (default: "0.0.0.0")
49+
-o, --open Open in the browser on startup.
50+
-p, --port <number> Port to bind on. (default: 8443)
51+
-N, --no-auth Start without requiring authentication.
52+
-H, --allow-http Allow http connections.
53+
-P, --password <value> Specify a password for authentication.
54+
--disable-telemetry Disables ALL telemetry.
55+
-h, --help output usage information
5556
```
5657

5758
### Data Directory
58-
Use `code-server -d (path/to/directory)` or `code-server --data-dir=(path/to/directory)`, excluding the parentheses to specify the root folder that VS Code will start in
59+
Use `code-server -d (path/to/directory)` or `code-server --data-dir=(path/to/directory)`, excluding the parentheses to specify the root folder that VS Code will start in.
5960

6061
### Host
6162
By default, code-server will use `0.0.0.0` as its address. This can be changed by using `code-server -h` or `code-server --host=` followed by the address you want to use.
@@ -68,6 +69,9 @@ OPTIONS
6869
By default, code-server will use `8443` as its port. This can be changed by using `code-server -p` or `code-server --port=` followed by the port you want to use.
6970
> Example: `code-server -p 9000`
7071
72+
### Telemetry
73+
Disable all telemetry with `code-server --disable-telemetry`.
74+
7175
### Cert and Cert Key
7276
To encrypt the traffic between the browser and server use `code-server --cert=` followed by the path to your `.cer` file. Additionally, you can use certificate keys with `code-server --cert-key` followed by the path to your `.key` file.
7377
> Example (certificate and key): `code-server --cert /etc/letsencrypt/live/example.com/fullchain.cer --cert-key /etc/letsencrypt/live/example.com/fullchain.key`
@@ -116,4 +120,4 @@ OPTIONS
116120
*Important:* For more details about Apache reverse proxy configuration checkout the [documentation](https://httpd.apache.org/docs/current/mod/mod_proxy.html) - especially the [Securing your Server](https://httpd.apache.org/docs/current/mod/mod_proxy.html#access) section
117121

118122
### Help
119-
Use `code-server -h` or `code-server --help` to view the usage for the cli. This is also shown at the beginning of this section.
123+
Use `code-server --help` to view the usage for the CLI. This is also shown at the beginning of this section.

packages/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"build:binary": "ts-node scripts/nbin.ts"
1010
},
1111
"dependencies": {
12-
"@coder/nbin": "^1.1.1",
12+
"@coder/nbin": "^1.1.2",
1313
"commander": "^2.19.0",
1414
"express": "^4.16.4",
1515
"express-static-gzip": "^1.1.3",

packages/server/src/cli.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ commander.version(process.env.VERSION || "development")
2929
.option("-N, --no-auth", "Start without requiring authentication.", undefined)
3030
.option("-H, --allow-http", "Allow http connections.", false)
3131
.option("-P, --password <value>", "Specify a password for authentication.")
32+
.option("--disable-telemetry", "Disables ALL telemetry.", false)
3233
.option("--install-extension <value>", "Install an extension by its ID.")
3334
.option("--bootstrap-fork <name>", "Used for development. Never set.")
3435
.option("--extra-args <args>", "Used for development. Never set.")
@@ -52,6 +53,7 @@ const bold = (text: string | number): string | number => {
5253
readonly allowHttp: boolean;
5354
readonly host: string;
5455
readonly port: number;
56+
readonly disableTelemetry: boolean;
5557

5658
readonly userDataDir?: string;
5759
readonly extensionsDir?: string;
@@ -68,6 +70,10 @@ const bold = (text: string | number): string | number => {
6870
readonly extraArgs?: string;
6971
};
7072

73+
if (options.disableTelemetry) {
74+
process.env.DISABLE_TELEMETRY = "true";
75+
}
76+
7177
// Commander has an exception for `--no` prefixes. Here we'll adjust that.
7278
// tslint:disable-next-line:no-any
7379
const noAuthValue = (commander as any).auth;

packages/server/src/vscode/sharedProcess.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export class SharedProcess {
9292
env: {
9393
VSCODE_ALLOW_IO: "true",
9494
VSCODE_LOGS: process.env.VSCODE_LOGS,
95+
DISABLE_TELEMETRY: process.env.DISABLE_TELEMETRY,
9596
},
9697
}, this.userDataDir);
9798
this.activeProcess = activeProcess;

packages/server/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
resolved "https://registry.yarnpkg.com/@coder/logger/-/logger-1.0.3.tgz#e0e1ae5496fde5a3c6ef3d748fdfb26a55add8b8"
88
integrity sha512-1o5qDZX2VZUNnzgz5KfAdMnaqaX6FNeTs0dUdg73MRHfQW94tFTIryFC1xTTCuzxGDjVHOHkaUAI4uHA2bheOA==
99

10-
"@coder/nbin@^1.1.1":
11-
version "1.1.1"
12-
resolved "https://registry.yarnpkg.com/@coder/nbin/-/nbin-1.1.1.tgz#0690928fb1306ee2a84120c8ae8ba221c338b190"
13-
integrity sha512-SDlW0dNw6N5Ge3XlI6nbQV7G7dvTYqxzhN0douJlD56upaU4C130g0FCrhLPU/H4gT3SdZVfWoWc4AGv2fhZZw==
10+
"@coder/nbin@^1.1.2":
11+
version "1.1.2"
12+
resolved "https://registry.yarnpkg.com/@coder/nbin/-/nbin-1.1.2.tgz#3af9e4368f37532da446c7c291d476bb52de995d"
13+
integrity sha512-MkwKpmu1SU9wkBwQ+bZVU2nPzENWUa3Isut9osVq3LG+udovsk+k5c5rjfJ1q8cf4km5snjOSYiulug3n9sdgw==
1414
dependencies:
1515
"@coder/logger" "^1.0.3"
1616
fs-extra "^7.0.1"
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
/**
2+
* Used by node
3+
*/
4+
import * as https from "https";
5+
import * as os from "os";
6+
7+
export const defaultClient = "filler";
8+
9+
export class TelemetryClient {
10+
public channel = {
11+
setUseDiskRetryCaching: (): void => undefined,
12+
};
13+
14+
public constructor() {
15+
//
16+
}
17+
18+
public trackEvent(options: {
19+
name: string;
20+
properties: object;
21+
measurements: object;
22+
}): void {
23+
if (!options.properties) {
24+
options.properties = {};
25+
}
26+
if (!options.measurements) {
27+
options.measurements = {};
28+
}
29+
30+
try {
31+
const cpus = os.cpus();
32+
// tslint:disable-next-line:no-any
33+
(options.measurements as any).cpu = {
34+
model: cpus[0].model,
35+
cores: cpus.length,
36+
};
37+
} catch (ex) {
38+
// Nothin
39+
}
40+
41+
try {
42+
// tslint:disable-next-line:no-any
43+
(options.measurements as any).memory = {
44+
virtual_free: os.freemem(),
45+
virtual_used: os.totalmem(),
46+
};
47+
} catch (ex) {
48+
//
49+
}
50+
51+
try {
52+
// tslint:disable:no-any
53+
(options.properties as any)["common.shell"] = os.userInfo().shell;
54+
(options.properties as any)["common.release"] = os.release();
55+
(options.properties as any)["common.arch"] = os.arch();
56+
// tslint:enable:no-any
57+
} catch (ex) {
58+
//
59+
}
60+
61+
try {
62+
// tslint:disable-next-line:no-any
63+
(options.properties as any)["common.machineId"] = machineIdSync();
64+
} catch (ex) {
65+
//
66+
}
67+
68+
try {
69+
const request = https.request({
70+
host: "v1.telemetry.coder.com",
71+
port: 443,
72+
path: "/track",
73+
method: "POST",
74+
headers: {
75+
"Content-Type": "application/json",
76+
},
77+
});
78+
request.on("error", () => {
79+
// Do nothing, we don"t really care
80+
});
81+
request.write(JSON.stringify(options));
82+
request.end();
83+
} catch (ex) {
84+
// Suppress all errs
85+
}
86+
}
87+
88+
public flush(options: {
89+
readonly callback: () => void;
90+
}): void {
91+
options.callback();
92+
}
93+
}
94+
95+
// Taken from https://github.com/automation-stack/node-machine-id
96+
import { exec, execSync } from "child_process";
97+
import { createHash } from "crypto";
98+
99+
const isWindowsProcessMixedOrNativeArchitecture = (): "" | "mixed" | "native" => {
100+
// detect if the node binary is the same arch as the Windows OS.
101+
// or if this is 32 bit node on 64 bit windows.
102+
if (process.platform !== "win32") {
103+
return "";
104+
}
105+
if (process.arch === "ia32" && process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")) {
106+
return "mixed";
107+
}
108+
109+
return "native";
110+
};
111+
112+
let { platform } = process,
113+
win32RegBinPath = {
114+
native: "%windir%\\System32",
115+
mixed: "%windir%\\sysnative\\cmd.exe /c %windir%\\System32",
116+
"": "",
117+
},
118+
guid = {
119+
darwin: "ioreg -rd1 -c IOPlatformExpertDevice",
120+
win32: `${win32RegBinPath[isWindowsProcessMixedOrNativeArchitecture()]}\\REG ` +
121+
"QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography " +
122+
"/v MachineGuid",
123+
linux: "( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :",
124+
freebsd: "kenv -q smbios.system.uuid || sysctl -n kern.hostuuid",
125+
// tslint:disable-next-line:no-any
126+
} as any;
127+
128+
const hash = (guid: string): string => {
129+
return createHash("sha256").update(guid).digest("hex");
130+
};
131+
132+
const expose = (result: string): string => {
133+
switch (platform) {
134+
case "darwin":
135+
return result
136+
.split("IOPlatformUUID")[1]
137+
.split("\n")[0].replace(/\=|\s+|\"/ig, "")
138+
.toLowerCase();
139+
case "win32":
140+
return result
141+
.toString()
142+
.split("REG_SZ")[1]
143+
.replace(/\r+|\n+|\s+/ig, "")
144+
.toLowerCase();
145+
case "linux":
146+
return result
147+
.toString()
148+
.replace(/\r+|\n+|\s+/ig, "")
149+
.toLowerCase();
150+
case "freebsd":
151+
return result
152+
.toString()
153+
.replace(/\r+|\n+|\s+/ig, "")
154+
.toLowerCase();
155+
default:
156+
throw new Error(`Unsupported platform: ${process.platform}`);
157+
}
158+
};
159+
160+
let cachedMachineId: string | undefined;
161+
162+
const machineIdSync = (): string => {
163+
if (cachedMachineId) {
164+
return cachedMachineId;
165+
}
166+
let id: string = expose(execSync(guid[platform]).toString());
167+
cachedMachineId = hash(id);
168+
169+
return cachedMachineId;
170+
};

packages/vscode/src/fill/product.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ class Product implements IProductConfiguration {
1212
public tipsAndTricksUrl = "https://code.visualstudio.com/docs/getstarted/tips-and-tricks";
1313
public twitterUrl = "https://twitter.com/code";
1414
public licenseUrl = "https://github.com/codercom/code-server/blob/master/LICENSE";
15+
public aiConfig = process.env.DISABLE_TELEMETRY ? undefined! : {
16+
// Only needed so vscode can see that content exists for this value.
17+
// We override the application insights module.
18+
asimovKey: "content",
19+
};
20+
public enableTelemetry = process.env.DISABLE_TELEMETRY ? false : true;
1521

1622
private _dataFolderName: string | undefined;
1723
public get dataFolderName(): string {
@@ -26,7 +32,8 @@ class Product implements IProductConfiguration {
2632
serviceUrl: global && global.process && global.process.env.SERVICE_URL
2733
|| process.env.SERVICE_URL
2834
|| "https://v1.extapi.coder.com",
29-
};
35+
// tslint:disable-next-line:no-any
36+
} as any;
3037

3138
public extensionExecutionEnvironments = {
3239
"wayou.vscode-todo-highlight": "worker",

packages/vscode/webpack.bootstrap.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ module.exports = merge(
5555
"vscode-sqlite3": path.resolve(fills, "empty.ts"),
5656
"vs/base/browser/browser": path.resolve(fills, "empty.ts"),
5757

58+
"applicationinsights": path.join(vsFills, "applicationInsights.ts"),
5859
"electron": path.join(vsFills, "stdioElectron.ts"),
5960
"vscode-ripgrep": path.join(vsFills, "ripgrep.ts"),
6061
"native-keymap": path.join(vsFills, "native-keymap.ts"),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy