chore: update Code to 1.70 (#5422)
* Update upstream Code to 1.70 * Update CSP hashes * Update comment on remote authority Also remove it from script-src since it is invalid anyway. * Use absolute path for disable download patch Just to keep it consistent with the other imports. We initially added the patch like this so it was not part of the upgrade but might as well fix it now. * Fix inability to change language while code-server is running Co-authored-by: Asher <ash@coder.com>
This commit is contained in:
committed by
Asher
parent
bef78e6a41
commit
2bfe15b3e9
@ -4,124 +4,47 @@ Index: code-server/lib/vscode/src/vs/server/node/serverServices.ts
|
||||
===================================================================
|
||||
--- code-server.orig/lib/vscode/src/vs/server/node/serverServices.ts
|
||||
+++ code-server/lib/vscode/src/vs/server/node/serverServices.ts
|
||||
@@ -70,6 +70,7 @@ import { REMOTE_FILE_SYSTEM_CHANNEL_NAME
|
||||
import { ExtensionHostStatusService, IExtensionHostStatusService } from 'vs/server/node/extensionHostStatusService';
|
||||
import { IExtensionsScannerService } from 'vs/platform/extensionManagement/common/extensionsScannerService';
|
||||
@@ -71,6 +71,7 @@ import { IExtensionsScannerService } fro
|
||||
import { ExtensionsScannerService } from 'vs/server/node/extensionsScannerService';
|
||||
import { ExtensionsProfileScannerService, IExtensionsProfileScannerService } from 'vs/platform/extensionManagement/common/extensionsProfileScannerService';
|
||||
import { IUserDataProfilesService, UserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
|
||||
+import { TelemetryClient } from "vs/server/node/telemetryClient";
|
||||
import { NullPolicyService } from 'vs/platform/policy/common/policy';
|
||||
import { OneDataSystemAppender } from 'vs/platform/telemetry/node/1dsAppender';
|
||||
|
||||
const eventPrefix = 'monacoworkbench';
|
||||
@@ -123,7 +124,11 @@ export async function setupServerService
|
||||
let appInsightsAppender: ITelemetryAppender = NullAppender;
|
||||
@@ -133,10 +134,13 @@ export async function setupServerService
|
||||
const machineId = await getMachineId();
|
||||
const isInternal = isInternalTelemetry(productService, configurationService);
|
||||
if (supportsTelemetry(productService, environmentService)) {
|
||||
- if (productService.aiConfig && productService.aiConfig.asimovKey) {
|
||||
- if (productService.aiConfig && productService.aiConfig.ariaKey) {
|
||||
+ const telemetryEndpoint = process.env.CS_TELEMETRY_URL || "https://v1.telemetry.coder.com/track";
|
||||
+ if (telemetryEndpoint) {
|
||||
+ appInsightsAppender = new AppInsightsAppender(eventPrefix, null, () => new TelemetryClient(telemetryEndpoint) as any);
|
||||
+ disposables.add(toDisposable(() => appInsightsAppender!.flush())); // Ensure the AI appender is disposed so that it flushes remaining data
|
||||
+ } else if (productService.aiConfig && productService.aiConfig.asimovKey) {
|
||||
appInsightsAppender = new AppInsightsAppender(eventPrefix, null, productService.aiConfig.asimovKey);
|
||||
disposables.add(toDisposable(() => appInsightsAppender!.flush())); // Ensure the AI appender is disposed so that it flushes remaining data
|
||||
+ oneDsAppender = new OneDataSystemAppender(false, eventPrefix, null, () => new TelemetryClient(telemetryEndpoint));
|
||||
+ } else if (productService.aiConfig && productService.aiConfig.ariaKey) {
|
||||
oneDsAppender = new OneDataSystemAppender(isInternal, eventPrefix, null, productService.aiConfig.ariaKey);
|
||||
- disposables.add(toDisposable(() => oneDsAppender?.flush())); // Ensure the AI appender is disposed so that it flushes remaining data
|
||||
}
|
||||
+ disposables.add(toDisposable(() => oneDsAppender?.flush())); // Ensure the AI appender is disposed so that it flushes remaining data
|
||||
|
||||
const config: ITelemetryServiceConfig = {
|
||||
appenders: [oneDsAppender],
|
||||
Index: code-server/lib/vscode/src/vs/server/node/telemetryClient.ts
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ code-server/lib/vscode/src/vs/server/node/telemetryClient.ts
|
||||
@@ -0,0 +1,135 @@
|
||||
+import * as appInsights from 'applicationinsights';
|
||||
@@ -0,0 +1,49 @@
|
||||
+import { AppInsightsCore, IExtendedTelemetryItem, ITelemetryItem } from '@microsoft/1ds-core-js';
|
||||
+import * as https from 'https';
|
||||
+import * as http from 'http';
|
||||
+import * as os from 'os';
|
||||
+
|
||||
+class Channel {
|
||||
+ public get _sender() {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+ public get _buffer() {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+
|
||||
+ public setUseDiskRetryCaching(): void {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+ public send(): void {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+ public triggerSend(): void {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+// Unable to use implements because TypeScript tells you a private property is
|
||||
+// missing but if you add it then it complains they have different private
|
||||
+// properties. Uncommenting it during development can be helpful though to see
|
||||
+// if anything is missing.
|
||||
+export class TelemetryClient /* implements appInsights.TelemetryClient */ {
|
||||
+ private _telemetryProcessors: any = undefined;
|
||||
+ public context: any = undefined;
|
||||
+ public commonProperties: any = undefined;
|
||||
+ public config: any = {};
|
||||
+ public quickPulseClient: any = undefined;
|
||||
+
|
||||
+ public channel: any = new Channel();
|
||||
+
|
||||
+export class TelemetryClient extends AppInsightsCore {
|
||||
+ public constructor(private readonly endpoint: string) {
|
||||
+ // Nothing to do.
|
||||
+ super();
|
||||
+ }
|
||||
+
|
||||
+ public addTelemetryProcessor(): void {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+
|
||||
+ public clearTelemetryProcessors(): void {
|
||||
+ if (this._telemetryProcessors) {
|
||||
+ this._telemetryProcessors = undefined;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public runTelemetryProcessors(): void {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+
|
||||
+ public trackTrace(): void {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+
|
||||
+ public trackMetric(): void {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+
|
||||
+ public trackException(): void {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+
|
||||
+ public trackRequest(): void {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+
|
||||
+ public trackDependency(): void {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+
|
||||
+ public track(): void {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+
|
||||
+ public trackNodeHttpRequestSync(): void {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+
|
||||
+ public trackNodeHttpRequest(): void {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+
|
||||
+ public trackNodeHttpDependency(): void {
|
||||
+ throw new Error('unimplemented');
|
||||
+ }
|
||||
+
|
||||
+ public trackEvent(options: appInsights.Contracts.EventTelemetry): void {
|
||||
+ public override track(item: IExtendedTelemetryItem | ITelemetryItem): void {
|
||||
+ const options = item.baseData || {}
|
||||
+ if (!options.properties) {
|
||||
+ options.properties = {};
|
||||
+ }
|
||||
@ -158,51 +81,63 @@ Index: code-server/lib/vscode/src/vs/server/node/telemetryClient.ts
|
||||
+ request.end();
|
||||
+ } catch (error) {}
|
||||
+ }
|
||||
+
|
||||
+ public flush(options: { callback: (v: string) => void }): void {
|
||||
+ if (options.callback) {
|
||||
+ options.callback('');
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
Index: code-server/lib/vscode/src/vs/workbench/services/telemetry/browser/telemetryService.ts
|
||||
===================================================================
|
||||
--- code-server.orig/lib/vscode/src/vs/workbench/services/telemetry/browser/telemetryService.ts
|
||||
+++ code-server/lib/vscode/src/vs/workbench/services/telemetry/browser/telemetryService.ts
|
||||
@@ -120,16 +120,19 @@ export class TelemetryService extends Di
|
||||
@@ -38,26 +38,30 @@ export class TelemetryService extends Di
|
||||
) {
|
||||
super();
|
||||
|
||||
- if (supportsTelemetry(productService, environmentService) && productService.aiConfig?.asimovKey) {
|
||||
- if (supportsTelemetry(productService, environmentService) && productService.aiConfig?.ariaKey) {
|
||||
+ if (supportsTelemetry(productService, environmentService)) {
|
||||
// If remote server is present send telemetry through that, else use the client side appender
|
||||
- const telemetryProvider: ITelemetryAppender = remoteAgentService.getConnection() !== null ? { log: remoteAgentService.logTelemetry.bind(remoteAgentService), flush: remoteAgentService.flushTelemetry.bind(remoteAgentService) } : new WebAppInsightsAppender('monacoworkbench', productService.aiConfig?.asimovKey);
|
||||
const appenders = [];
|
||||
const isInternal = isInternalTelemetry(productService, configurationService);
|
||||
- const telemetryProvider: ITelemetryAppender = remoteAgentService.getConnection() !== null ? { log: remoteAgentService.logTelemetry.bind(remoteAgentService), flush: remoteAgentService.flushTelemetry.bind(remoteAgentService) } : new OneDataSystemWebAppender(isInternal, 'monacoworkbench', null, productService.aiConfig?.ariaKey);
|
||||
- appenders.push(telemetryProvider);
|
||||
- appenders.push(new TelemetryLogAppender(loggerService, environmentService));
|
||||
- const config: ITelemetryServiceConfig = {
|
||||
- appenders: [new WebTelemetryAppender(telemetryProvider), new TelemetryLogAppender(loggerService, environmentService)],
|
||||
- commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, environmentService.remoteAuthority, productService.embedderIdentifier, productService.removeTelemetryMachineId, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
|
||||
- appenders,
|
||||
- commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, isInternal, environmentService.remoteAuthority, productService.embedderIdentifier, productService.removeTelemetryMachineId, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
|
||||
- sendErrorTelemetry: this.sendErrorTelemetry,
|
||||
- };
|
||||
-
|
||||
- this.impl = this._register(new BaseTelemetryService(config, configurationService, productService));
|
||||
+ const telemetryProvider: ITelemetryAppender | undefined = remoteAgentService.getConnection() !== null ? { log: remoteAgentService.logTelemetry.bind(remoteAgentService), flush: remoteAgentService.flushTelemetry.bind(remoteAgentService) } : productService.aiConfig?.asimovKey ? new WebAppInsightsAppender('monacoworkbench', productService.aiConfig?.asimovKey) : undefined;
|
||||
+ 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;
|
||||
+ if (telemetryProvider) {
|
||||
+ appenders.push(telemetryProvider);
|
||||
+ appenders.push(new TelemetryLogAppender(loggerService, environmentService));
|
||||
+ const config: ITelemetryServiceConfig = {
|
||||
+ appenders: [new WebTelemetryAppender(telemetryProvider), new TelemetryLogAppender(loggerService, environmentService)],
|
||||
+ commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, environmentService.remoteAuthority, productService.embedderIdentifier, productService.removeTelemetryMachineId, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
|
||||
+ appenders,
|
||||
+ commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, isInternal, environmentService.remoteAuthority, productService.embedderIdentifier, productService.removeTelemetryMachineId, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
|
||||
+ sendErrorTelemetry: this.sendErrorTelemetry,
|
||||
+ };
|
||||
+ this.impl = this._register(new BaseTelemetryService(config, configurationService, productService));
|
||||
|
||||
- if (getTelemetryLevel(configurationService) !== TelemetryLevel.NONE) {
|
||||
- // If we cannot fetch the endpoint it means it is down and we should not send any telemetry.
|
||||
- // This is most likely due to ad blockers
|
||||
- fetch(telemetryEndpointUrl, { method: 'POST' }).catch(err => {
|
||||
- this.impl = NullTelemetryService;
|
||||
- });
|
||||
+ if (remoteAgentService.getConnection() === null && getTelemetryLevel(configurationService) !== TelemetryLevel.NONE) {
|
||||
+ // If we cannot fetch the endpoint it means it is down and we should not send any telemetry.
|
||||
+ // This is most likely due to ad blockers
|
||||
+ fetch(telemetryEndpointUrl, { method: 'POST' }).catch(err => {
|
||||
+ this.impl = NullTelemetryService;
|
||||
+ });
|
||||
+ }
|
||||
+ } else {
|
||||
+ this.impl = NullTelemetryService;
|
||||
+ }
|
||||
}
|
||||
} else {
|
||||
this.impl = NullTelemetryService;
|
||||
}
|
||||
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
|
||||
===================================================================
|
||||
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
|
||||
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
|
||||
@@ -320,6 +320,7 @@ export class WebClientServer {
|
||||
@@ -324,6 +324,7 @@ export class WebClientServer {
|
||||
scope: vscodeBase + '/',
|
||||
path: base + '/_static/out/browser/serviceWorker.js',
|
||||
},
|
||||
|
Reference in New Issue
Block a user