mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 02:58:31 -05:00
VS Code merge to df8fe74bd55313de0dd2303bc47a4aab0ca56b0e (#17979)
* Merge from vscode 504f934659740e9d41501cad9f162b54d7745ad9 * delete unused folders * distro * Bump build node version * update chokidar * FIx hygiene errors * distro * Fix extension lint issues * Remove strict-vscode * Add copyright header exemptions * Bump vscode-extension-telemetry to fix webpacking issue with zone.js * distro * Fix failing tests (revert marked.js back to current one until we decide to update) * Skip searchmodel test * Fix mac build * temp debug script loading * Try disabling coverage * log error too * Revert "log error too" This reverts commit af0183e5d4ab458fdf44b88fbfab9908d090526f. * Revert "temp debug script loading" This reverts commit 3d687d541c76db2c5b55626c78ae448d3c25089c. * Add comments explaining coverage disabling * Fix ansi_up loading issue * Merge latest from ads * Use newer option * Fix compile * add debug logging warn * Always log stack * log more * undo debug * Update to use correct base path (+cleanup) * distro * fix compile errors * Remove strict-vscode * Fix sql editors not showing * Show db dropdown input & fix styling * Fix more info in gallery * Fix gallery asset requests * Delete unused workflow * Fix tapable resolutions for smoke test compile error * Fix smoke compile * Disable crash reporting * Disable interactive Co-authored-by: ADS Merger <karlb@microsoft.com>
This commit is contained in:
@@ -3,31 +3,96 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ITelemetryService, ITelemetryInfo, ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { NullTelemetryService, combinedAppender, ITelemetryAppender } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import type { ApplicationInsights } from '@microsoft/applicationinsights-web';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { ILoggerService } from 'vs/platform/log/common/log';
|
||||
import { TelemetryService as BaseTelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { resolveWorkbenchCommonProperties } from 'vs/workbench/services/telemetry/browser/workbenchCommonProperties';
|
||||
import { ILoggerService } from 'vs/platform/log/common/log';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ClassifiedEvent, GDPRClassification, StrictPropertyCheck } from 'vs/platform/telemetry/common/gdprTypings';
|
||||
import { ITelemetryData, ITelemetryInfo, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { TelemetryLogAppender } from 'vs/platform/telemetry/common/telemetryLogAppender';
|
||||
import { ITelemetryServiceConfig, TelemetryService as BaseTelemetryService } from 'vs/platform/telemetry/common/telemetryService';
|
||||
import { combinedAppender, ITelemetryAppender, NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
||||
import { resolveWorkbenchCommonProperties } from 'vs/workbench/services/telemetry/browser/workbenchCommonProperties';
|
||||
|
||||
class WebAppInsightsAppender implements ITelemetryAppender {
|
||||
private _aiClient: ApplicationInsights | undefined;
|
||||
private _aiClientLoaded = false;
|
||||
private _telemetryCache: { eventName: string, data: any }[] = [];
|
||||
|
||||
constructor(private _eventPrefix: string, aiKey: string) {
|
||||
const endpointUrl = 'https://vortex.data.microsoft.com/collect/v1';
|
||||
import('@microsoft/applicationinsights-web').then(aiLibrary => {
|
||||
this._aiClient = new aiLibrary.ApplicationInsights({
|
||||
config: {
|
||||
instrumentationKey: aiKey,
|
||||
endpointUrl,
|
||||
disableAjaxTracking: true,
|
||||
disableExceptionTracking: true,
|
||||
disableFetchTracking: true,
|
||||
disableCorrelationHeaders: true,
|
||||
disableCookiesUsage: true,
|
||||
autoTrackPageVisitTime: false,
|
||||
emitLineDelimitedJson: true,
|
||||
},
|
||||
});
|
||||
this._aiClient.loadAppInsights();
|
||||
// Client is loaded we can now flush the cached events
|
||||
this._aiClientLoaded = true;
|
||||
this._telemetryCache.forEach(cacheEntry => this.log(cacheEntry.eventName, cacheEntry.data));
|
||||
this._telemetryCache = [];
|
||||
|
||||
// If we cannot access the endpoint this most likely means it's being blocked
|
||||
// and we should not attempt to send any telemetry.
|
||||
fetch(endpointUrl).catch(() => (this._aiClient = undefined));
|
||||
}).catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a telemetry event with eventName and data
|
||||
* @param eventName The event name
|
||||
* @param data The data associated with the events
|
||||
*/
|
||||
public log(eventName: string, data: any): void {
|
||||
if (!this._aiClient && this._aiClientLoaded) {
|
||||
return;
|
||||
} else if (!this._aiClient && !this._aiClientLoaded) {
|
||||
this._telemetryCache.push({ eventName, data });
|
||||
return;
|
||||
}
|
||||
|
||||
// undefined assertion is ok since above two if statements cover both cases
|
||||
this._aiClient!.trackEvent({ name: this._eventPrefix + '/' + eventName }, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes all the telemetry data still in the buffer
|
||||
*/
|
||||
public flush(): Promise<any> {
|
||||
if (this._aiClient) {
|
||||
this._aiClient.flush();
|
||||
this._aiClient = undefined;
|
||||
}
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
class WebTelemetryAppender implements ITelemetryAppender {
|
||||
|
||||
constructor(private _appender: IRemoteAgentService) { }
|
||||
constructor(private _appender: ITelemetryAppender) { }
|
||||
|
||||
log(eventName: string, data: any): void {
|
||||
this._appender.logTelemetry(eventName, data);
|
||||
this._appender.log(eventName, data);
|
||||
}
|
||||
|
||||
flush(): Promise<void> {
|
||||
return this._appender.flushTelemetry();
|
||||
return this._appender.flush();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,10 +113,12 @@ export class TelemetryService extends Disposable implements ITelemetryService {
|
||||
) {
|
||||
super();
|
||||
|
||||
if (!!productService.enableTelemetry) {
|
||||
if (!!productService.enableTelemetry && productService.aiConfig?.asimovKey && environmentService.isBuilt) {
|
||||
// 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 config: ITelemetryServiceConfig = {
|
||||
appender: combinedAppender(new WebTelemetryAppender(remoteAgentService), new TelemetryLogAppender(loggerService, environmentService)),
|
||||
commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, environmentService.remoteAuthority, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
|
||||
appender: combinedAppender(new WebTelemetryAppender(telemetryProvider), new TelemetryLogAppender(loggerService, environmentService)),
|
||||
commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, environmentService.remoteAuthority, productService.embedderIdentifier, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
|
||||
sendErrorTelemetry: false,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user