1
1
Add support for telemetry endpoint
2
2
3
+ Contains some fixes included in https://github.com/microsoft/vscode/commit/b108bc8294ce920fcf2ee8d53f97c3bcf3316e1c
4
+
3
5
Index: code-server/lib/vscode/src/vs/server/node/serverServices.ts
4
6
===================================================================
5
7
--- code-server.orig/lib/vscode/src/vs/server/node/serverServices.ts
@@ -86,12 +88,45 @@ Index: code-server/lib/vscode/src/vs/workbench/services/telemetry/browser/teleme
86
88
===================================================================
87
89
--- code-server.orig/lib/vscode/src/vs/workbench/services/telemetry/browser/telemetryService.ts
88
90
+++ code-server/lib/vscode/src/vs/workbench/services/telemetry/browser/telemetryService.ts
89
- @@ -38,26 +38,30 @@ export class TelemetryService extends Di
91
+ @@ -15,7 +15,7 @@ import { ClassifiedEvent, IGDPRProperty,
92
+ import { ITelemetryData, ITelemetryInfo, ITelemetryService, TelemetryLevel, TELEMETRY_SETTING_ID } from 'vs/platform/telemetry/common/telemetry';
93
+ import { TelemetryLogAppender } from 'vs/platform/telemetry/common/telemetryLogAppender';
94
+ import { ITelemetryServiceConfig, TelemetryService as BaseTelemetryService } from 'vs/platform/telemetry/common/telemetryService';
95
+ - import { isInternalTelemetry, ITelemetryAppender, NullTelemetryService, supportsTelemetry } from 'vs/platform/telemetry/common/telemetryUtils';
96
+ + import { getTelemetryLevel, isInternalTelemetry, ITelemetryAppender, NullTelemetryService, supportsTelemetry } from 'vs/platform/telemetry/common/telemetryUtils';
97
+ import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
98
+ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
99
+ import { resolveWorkbenchCommonProperties } from 'vs/workbench/services/telemetry/browser/workbenchCommonProperties';
100
+ @@ -24,7 +24,7 @@ export class TelemetryService extends Di
101
+
102
+ declare readonly _serviceBrand: undefined;
103
+
104
+ - private impl: ITelemetryService;
105
+ + private impl: ITelemetryService = NullTelemetryService;
106
+ public readonly sendErrorTelemetry = true;
107
+
108
+ constructor(
109
+ @@ -37,11 +37,7 @@ export class TelemetryService extends Di
90
110
) {
91
111
super();
92
112
93
113
- if (supportsTelemetry(productService, environmentService) && productService.aiConfig?.ariaKey) {
94
- + if (supportsTelemetry(productService, environmentService)) {
114
+ - this.impl = this.initializeService(environmentService, loggerService, configurationService, storageService, productService, remoteAgentService);
115
+ - } else {
116
+ - this.impl = NullTelemetryService;
117
+ - }
118
+ + this.impl = this.initializeService(environmentService, loggerService, configurationService, storageService, productService, remoteAgentService);
119
+
120
+ // When the level changes it could change from off to on and we want to make sure telemetry is properly intialized
121
+ this._register(configurationService.onDidChangeConfiguration(e => {
122
+ @@ -64,23 +60,28 @@ export class TelemetryService extends Di
123
+ productService: IProductService,
124
+ remoteAgentService: IRemoteAgentService
125
+ ) {
126
+ - const telemetrySupported = supportsTelemetry(productService, environmentService) && productService.aiConfig?.ariaKey;
127
+ - if (telemetrySupported && this.impl === NullTelemetryService && this.telemetryLevel.value !== TelemetryLevel.NONE) {
128
+ + const telemetrySupported = supportsTelemetry(productService, environmentService);
129
+ + if (telemetrySupported && getTelemetryLevel(configurationService) !== TelemetryLevel.NONE && this.impl === NullTelemetryService) {
95
130
// If remote server is present send telemetry through that, else use the client side appender
96
131
const appenders = [];
97
132
const isInternal = isInternalTelemetry(productService, configurationService);
@@ -103,14 +138,6 @@ Index: code-server/lib/vscode/src/vs/workbench/services/telemetry/browser/teleme
103
138
- commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, isInternal, environmentService.remoteAuthority, productService.embedderIdentifier, productService.removeTelemetryMachineId, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
104
139
- sendErrorTelemetry: this.sendErrorTelemetry,
105
140
- };
106
- - this.impl = this._register(new BaseTelemetryService(config, configurationService, productService));
107
- -
108
- - if (getTelemetryLevel(configurationService) !== TelemetryLevel.NONE) {
109
- - // If we cannot fetch the endpoint it means it is down and we should not send any telemetry.
110
- - // This is most likely due to ad blockers
111
- - fetch(telemetryEndpointUrl, { method: 'POST' }).catch(err => {
112
- - this.impl = NullTelemetryService;
113
- - });
114
141
+ const telemetryProvider: ITelemetryAppender | undefined = remoteAgentService.getConnection() !== null ? { log: remoteAgentService.logTelemetry.bind(remoteAgentService), flush: remoteAgentService.flushTelemetry.bind(remoteAgentService) } : productService.aiConfig?.ariaKey ? new OneDataSystemWebAppender(isInternal, 'monacoworkbench', null, productService.aiConfig?.ariaKey) : undefined;
115
142
+ if (telemetryProvider) {
116
143
+ appenders.push(telemetryProvider);
@@ -120,20 +147,19 @@ Index: code-server/lib/vscode/src/vs/workbench/services/telemetry/browser/teleme
120
147
+ commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, isInternal, environmentService.remoteAuthority, productService.embedderIdentifier, productService.removeTelemetryMachineId, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
121
148
+ sendErrorTelemetry: this.sendErrorTelemetry,
122
149
+ };
123
- + this.impl = this._register(new BaseTelemetryService(config, configurationService, productService));
124
150
+
125
- + if (remoteAgentService.getConnection() === null && getTelemetryLevel(configurationService) !== TelemetryLevel.NONE) {
126
- + // If we cannot fetch the endpoint it means it is down and we should not send any telemetry.
127
- + // This is most likely due to ad blockers
128
- + fetch(telemetryEndpointUrl, { method: 'POST' }).catch(err => {
129
- + this.impl = NullTelemetryService;
130
- + });
131
- + }
151
+ + return this._register(new BaseTelemetryService(config, configurationService, productService));
132
152
+ } else {
133
- + this.impl = NullTelemetryService;
134
- }
135
- } else {
136
- this.impl = NullTelemetryService;
153
+ + return this.impl;
154
+ + }
155
+
156
+ - return this._register(new BaseTelemetryService(config, configurationService, productService));
157
+ }
158
+ - return NullTelemetryService;
159
+ + return this.impl;
160
+ }
161
+
162
+ setExperimentProperty(name: string, value: string): void {
137
163
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
138
164
===================================================================
139
165
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
0 commit comments