Skip to content

Commit d8a1f7d

Browse files
code-asherAkash Satheesan
authored andcommitted
Remove duplicate telemetry service registration
We no longer comment out the telemetry service in the workbench so ours is redundant. - logTelemetry call was slightly wrong (uses an object rather than an array) - No longer need the telemetry channel since the default uses the extension environment channel. - No longer need disableTelemetry since we don't create the setting. This does mean the setting is not toggled off when the disable flag is set (it does of course still prevent telemetry) but that appears to be the same with upstream.
1 parent 9e46573 commit d8a1f7d

File tree

9 files changed

+9
-108
lines changed

9 files changed

+9
-108
lines changed

ci/build/build-release.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ bundle_vscode() {
8282
rsync "$VSCODE_SRC_PATH/resources/linux/code.png" "$VSCODE_OUT_PATH/resources/linux/code.png"
8383
rsync "$VSCODE_SRC_PATH/resources/web/callback.html" "$VSCODE_OUT_PATH/resources/web/callback.html"
8484

85-
# Adds the commit and date to product.json
85+
# Add the commit and date and enable telemetry. This just makes telemetry
86+
# available; telemetry can still be disabled by flag or setting.
8687
jq --slurp '.[0] * .[1]' "$VSCODE_SRC_PATH/product.json" <(
8788
cat << EOF
8889
{
90+
"enableTelemetry": true,
8991
"commit": "$(git rev-parse HEAD)",
9092
"date": $(jq -n 'now | todate')
9193
}

lib/vscode/src/vs/platform/telemetry/common/telemetryChannel.ts

Lines changed: 0 additions & 65 deletions
This file was deleted.

lib/vscode/src/vs/server/channel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export class ExtensionEnvironmentChannel implements IServerChannel {
240240
);
241241
case 'getDiagnosticInfo': return this.getDiagnosticInfo();
242242
case 'disableTelemetry': return this.disableTelemetry();
243-
case 'logTelemetry': return this.logTelemetry(args[0], args[1]);
243+
case 'logTelemetry': return this.logTelemetry(args.eventName, args.data);
244244
case 'flushTelemetry': return this.flushTelemetry();
245245
}
246246
throw new Error(`Invalid call '${command}'`);

lib/vscode/src/vs/server/server.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import { TelemetryLogAppender } from 'vs/platform/telemetry/common/telemetryLogA
4646
import { TelemetryService } from 'vs/platform/telemetry/common/telemetryService';
4747
import { combinedAppender, NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
4848
import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppender';
49-
import { TelemetryChannel } from 'vs/platform/telemetry/common/telemetryChannel';
5049
import { ExtensionEnvironmentChannel, FileProviderChannel, TerminalProviderChannel } from 'vs/server/channel';
5150
import { Connection, ExtensionHostConnection, ManagementConnection } from 'vs/server/connection';
5251
import { TelemetryClient } from 'vs/server/insights';
@@ -269,7 +268,8 @@ export class Vscode {
269268
instantiationService.createInstance(LogsDataCleaner);
270269

271270
let telemetryService: ITelemetryService;
272-
if (!environmentService.disableTelemetry) {
271+
272+
if (!environmentService.isExtensionDevelopment && !environmentService.disableTelemetry && !!productService.enableTelemetry) {
273273
telemetryService = new TelemetryService({
274274
appender: combinedAppender(
275275
new AppInsightsAppender('code-server', null, () => new TelemetryClient() as any),
@@ -300,7 +300,6 @@ export class Vscode {
300300
environmentService, logService, telemetryService, '',
301301
));
302302
this.ipc.registerChannel('request', new RequestChannel(accessor.get(IRequestService)));
303-
this.ipc.registerChannel('telemetry', new TelemetryChannel(telemetryService));
304303
this.ipc.registerChannel('localizations', <IServerChannel<any>>ProxyChannel.fromService(accessor.get(ILocalizationsService)));
305304
this.ipc.registerChannel(REMOTE_FILE_SYSTEM_CHANNEL_NAME, new FileProviderChannel(environmentService, logService));
306305

lib/vscode/src/vs/workbench/browser/client.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@ import { Options } from 'vs/base/common/ipc';
33
import { localize } from 'vs/nls';
44
import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
55
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
6-
import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
76
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
8-
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
97
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
108
import { ILogService } from 'vs/platform/log/common/log';
119
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
12-
import { Registry } from 'vs/platform/registry/common/platform';
1310
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
14-
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
15-
import { TelemetryChannelClient } from 'vs/platform/telemetry/common/telemetryChannel';
1611
import { getOptions } from 'vs/base/common/util';
1712
import 'vs/workbench/contrib/localizations/browser/localizations.contribution'; // eslint-disable-line code-import-patterns
1813
import 'vs/workbench/services/localizations/browser/localizationsService';
19-
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
2014

2115
/**
2216
* All client-side customization to VS Code should live in this file when
@@ -25,32 +19,6 @@ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteA
2519

2620
const options = getOptions<Options>();
2721

28-
class TelemetryService extends TelemetryChannelClient {
29-
public constructor(
30-
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
31-
) {
32-
super(remoteAgentService.getConnection()!.getChannel('telemetry'));
33-
}
34-
}
35-
36-
const TELEMETRY_SECTION_ID = 'telemetry';
37-
Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration({
38-
'id': TELEMETRY_SECTION_ID,
39-
'order': 110,
40-
'type': 'object',
41-
'title': localize('telemetryConfigurationTitle', 'Telemetry'),
42-
'properties': {
43-
'telemetry.enableTelemetry': {
44-
'type': 'boolean',
45-
'description': localize('telemetry.enableTelemetry', 'Enable usage data and errors to be sent to a Microsoft online service.'),
46-
'default': !options.disableTelemetry,
47-
'tags': ['usesOnlineServices']
48-
}
49-
}
50-
});
51-
52-
registerSingleton(ITelemetryService, TelemetryService);
53-
5422
/**
5523
* This is called by vs/workbench/browser/web.main.ts after the workbench has
5624
* been initialized so we can initialize our own client-side code.

src/node/routes/vscode.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ router.get("/", async (req, res) => {
4949
!isDevMode ? content.replace(/<!-- PROD_ONLY/g, "").replace(/END_PROD_ONLY -->/g, "") : content,
5050
{
5151
authed: req.args.auth !== "none",
52-
disableTelemetry: !!req.args["disable-telemetry"],
5352
disableUpdateCheck: !!req.args["disable-update-check"],
5453
},
5554
)

test/unit/register.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe("register", () => {
145145
mockElement.id = "coder-options"
146146
mockElement.setAttribute(
147147
"data-settings",
148-
`{"csStaticBase":"${csStaticBasePath}","logLevel":2,"disableTelemetry":false,"disableUpdateCheck":false}`,
148+
`{"csStaticBase":"${csStaticBasePath}","logLevel":2,"disableUpdateCheck":false}`,
149149
)
150150
// Return mockElement from the spy
151151
// this way, when we call "getElementById"
@@ -166,7 +166,7 @@ describe("register", () => {
166166
mockElement.id = "coder-options"
167167
mockElement.setAttribute(
168168
"data-settings",
169-
`{"base":"proxy/","csStaticBase":"${csStaticBasePath}","logLevel":2,"disableTelemetry":false,"disableUpdateCheck":false}`,
169+
`{"base":"proxy/","csStaticBase":"${csStaticBasePath}","logLevel":2,"disableUpdateCheck":false}`,
170170
)
171171
// Return mockElement from the spy
172172
// this way, when we call "getElementById"

test/unit/util.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ describe("util", () => {
144144
const mockElement = document.createElement("div")
145145
mockElement.setAttribute(
146146
"data-settings",
147-
'{"base":".","csStaticBase":"./static/development/Users/jp/Dev/code-server","logLevel":2,"disableTelemetry":false,"disableUpdateCheck":false}',
147+
'{"base":".","csStaticBase":"./static/development/Users/jp/Dev/code-server","logLevel":2,"disableUpdateCheck":false}',
148148
)
149149
// Return mockElement from the spy
150150
// this way, when we call "getElementById"
@@ -154,7 +154,6 @@ describe("util", () => {
154154
expect(util.getOptions()).toStrictEqual({
155155
base: "",
156156
csStaticBase: "/static/development/Users/jp/Dev/code-server",
157-
disableTelemetry: false,
158157
disableUpdateCheck: false,
159158
logLevel: 2,
160159
})

typings/ipc.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export interface Options {
99
authed: boolean
1010
base: string
1111
csStaticBase: string
12-
disableTelemetry: boolean
1312
disableUpdateCheck: boolean
1413
logLevel: number
1514
}

0 commit comments

Comments
 (0)