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