mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from master
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { binarySearch } from 'vs/base/common/arrays';
|
||||
import { globals } from 'vs/base/common/platform';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
@@ -55,7 +53,7 @@ export default class ErrorTelemetry {
|
||||
|
||||
private _telemetryService: ITelemetryService;
|
||||
private _flushDelay: number;
|
||||
private _flushHandle = -1;
|
||||
private _flushHandle: any = -1;
|
||||
private _buffer: ErrorEvent[] = [];
|
||||
private _disposables: IDisposable[] = [];
|
||||
|
||||
@@ -148,7 +146,10 @@ export default class ErrorTelemetry {
|
||||
e.count = 1;
|
||||
this._buffer.splice(~idx, 0, e);
|
||||
} else {
|
||||
this._buffer[idx].count += 1;
|
||||
if (!this._buffer[idx].count) {
|
||||
this._buffer[idx].count = 0;
|
||||
}
|
||||
this._buffer[idx].count! += 1;
|
||||
}
|
||||
|
||||
if (this._flushHandle === -1) {
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export const ITelemetryService = createDecorator<ITelemetryService>('telemetryService');
|
||||
@@ -29,9 +27,9 @@ export interface ITelemetryService {
|
||||
* Sends a telemetry event that has been privacy approved.
|
||||
* Do not call this unless you have been given approval.
|
||||
*/
|
||||
publicLog(eventName: string, data?: ITelemetryData, anonymizeFilePaths?: boolean): TPromise<void>;
|
||||
publicLog(eventName: string, data?: ITelemetryData, anonymizeFilePaths?: boolean): Thenable<void>;
|
||||
|
||||
getTelemetryInfo(): TPromise<ITelemetryInfo>;
|
||||
getTelemetryInfo(): Thenable<ITelemetryInfo>;
|
||||
|
||||
isOptedIn: boolean;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { escapeRegExpCharacters } from 'vs/base/common/strings';
|
||||
import { ITelemetryService, ITelemetryInfo, ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
|
||||
@@ -12,14 +10,13 @@ import { ITelemetryAppender } from 'vs/platform/telemetry/common/telemetryUtils'
|
||||
import { optional } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IConfigurationRegistry, Extensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { cloneAndChange, mixin } from 'vs/base/common/objects';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
|
||||
export interface ITelemetryServiceConfig {
|
||||
appender: ITelemetryAppender;
|
||||
commonProperties?: TPromise<{ [name: string]: any }>;
|
||||
commonProperties?: Thenable<{ [name: string]: any }>;
|
||||
piiPaths?: string[];
|
||||
}
|
||||
|
||||
@@ -31,7 +28,7 @@ export class TelemetryService implements ITelemetryService {
|
||||
_serviceBrand: any;
|
||||
|
||||
private _appender: ITelemetryAppender;
|
||||
private _commonProperties: TPromise<{ [name: string]: any; }>;
|
||||
private _commonProperties: Thenable<{ [name: string]: any; }>;
|
||||
private _piiPaths: string[];
|
||||
private _userOptIn: boolean;
|
||||
|
||||
@@ -43,7 +40,7 @@ export class TelemetryService implements ITelemetryService {
|
||||
@optional(IConfigurationService) private _configurationService: IConfigurationService
|
||||
) {
|
||||
this._appender = config.appender;
|
||||
this._commonProperties = config.commonProperties || TPromise.as({});
|
||||
this._commonProperties = config.commonProperties || Promise.resolve({});
|
||||
this._piiPaths = config.piiPaths || [];
|
||||
this._userOptIn = true;
|
||||
|
||||
@@ -75,7 +72,7 @@ export class TelemetryService implements ITelemetryService {
|
||||
return this._userOptIn;
|
||||
}
|
||||
|
||||
getTelemetryInfo(): TPromise<ITelemetryInfo> {
|
||||
getTelemetryInfo(): Thenable<ITelemetryInfo> {
|
||||
return this._commonProperties.then(values => {
|
||||
// well known properties
|
||||
let sessionId = values['sessionID'];
|
||||
@@ -90,10 +87,10 @@ export class TelemetryService implements ITelemetryService {
|
||||
this._disposables = dispose(this._disposables);
|
||||
}
|
||||
|
||||
publicLog(eventName: string, data?: ITelemetryData, anonymizeFilePaths?: boolean): TPromise<any> {
|
||||
publicLog(eventName: string, data?: ITelemetryData, anonymizeFilePaths?: boolean): Thenable<any> {
|
||||
// don't send events when the user is optout
|
||||
if (!this._userOptIn) {
|
||||
return TPromise.as(undefined);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
return this._commonProperties.then(values => {
|
||||
@@ -134,6 +131,8 @@ export class TelemetryService implements ITelemetryService {
|
||||
|
||||
const nodeModulesRegex = /^[\\\/]?(node_modules|node_modules\.asar)[\\\/]/;
|
||||
const fileRegex = /(file:\/\/)?([a-zA-Z]:(\\\\|\\|\/)|(\\\\|\\|\/))?([\w-\._]+(\\\\|\\|\/))+[\w-\._]*/g;
|
||||
let lastIndex = 0;
|
||||
updatedStack = '';
|
||||
|
||||
while (true) {
|
||||
const result = fileRegex.exec(stack);
|
||||
@@ -142,9 +141,13 @@ export class TelemetryService implements ITelemetryService {
|
||||
}
|
||||
// Anoynimize user file paths that do not need to be retained or cleaned up.
|
||||
if (!nodeModulesRegex.test(result[0]) && cleanUpIndexes.every(([x, y]) => result.index < x || result.index >= y)) {
|
||||
updatedStack = updatedStack.slice(0, result.index) + result[0].replace(/./g, 'a') + updatedStack.slice(fileRegex.lastIndex);
|
||||
updatedStack += stack.substring(lastIndex, result.index) + '<REDACTED: user-file-path>';
|
||||
lastIndex = fileRegex.lastIndex;
|
||||
}
|
||||
}
|
||||
if (lastIndex < stack.length) {
|
||||
updatedStack += stack.substr(lastIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// sanitize with configured cleanup patterns
|
||||
@@ -171,4 +174,4 @@ Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfigurat
|
||||
'tags': ['usesOnlineServices']
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { guessMimeTypes } from 'vs/base/common/mime';
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IConfigurationService, ConfigurationTarget, ConfigurationTargetToString } from 'vs/platform/configuration/common/configuration';
|
||||
import { IKeybindingService, KeybindingSource } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { ITelemetryService, ITelemetryInfo, ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
@@ -17,11 +15,11 @@ import { ILogService } from 'vs/platform/log/common/log';
|
||||
export const NullTelemetryService = new class implements ITelemetryService {
|
||||
_serviceBrand: undefined;
|
||||
publicLog(eventName: string, data?: ITelemetryData) {
|
||||
return TPromise.wrap<void>(null);
|
||||
return Promise.resolve(void 0);
|
||||
}
|
||||
isOptedIn: true;
|
||||
getTelemetryInfo(): TPromise<ITelemetryInfo> {
|
||||
return TPromise.wrap({
|
||||
getTelemetryInfo(): Promise<ITelemetryInfo> {
|
||||
return Promise.resolve({
|
||||
instanceId: 'someValue.instanceId',
|
||||
sessionId: 'someValue.sessionId',
|
||||
machineId: 'someValue.machineId'
|
||||
@@ -31,17 +29,17 @@ export const NullTelemetryService = new class implements ITelemetryService {
|
||||
|
||||
export interface ITelemetryAppender {
|
||||
log(eventName: string, data: any): void;
|
||||
dispose(): TPromise<any>;
|
||||
dispose(): Thenable<any>;
|
||||
}
|
||||
|
||||
export function combinedAppender(...appenders: ITelemetryAppender[]): ITelemetryAppender {
|
||||
return {
|
||||
log: (e, d) => appenders.forEach(a => a.log(e, d)),
|
||||
dispose: () => TPromise.join(appenders.map(a => a.dispose()))
|
||||
dispose: () => Promise.all(appenders.map(a => a.dispose()))
|
||||
};
|
||||
}
|
||||
|
||||
export const NullAppender: ITelemetryAppender = { log: () => null, dispose: () => TPromise.as(null) };
|
||||
export const NullAppender: ITelemetryAppender = { log: () => null, dispose: () => Promise.resolve(null) };
|
||||
|
||||
|
||||
export class LogAppender implements ITelemetryAppender {
|
||||
@@ -49,8 +47,8 @@ export class LogAppender implements ITelemetryAppender {
|
||||
private commonPropertiesRegex = /^sessionID$|^version$|^timestamp$|^commitHash$|^common\./;
|
||||
constructor(@ILogService private readonly _logService: ILogService) { }
|
||||
|
||||
dispose(): TPromise<any> {
|
||||
return TPromise.as(undefined);
|
||||
dispose(): Promise<any> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
log(eventName: string, data: any): void {
|
||||
@@ -67,26 +65,27 @@ export class LogAppender implements ITelemetryAppender {
|
||||
/* __GDPR__FRAGMENT__
|
||||
"URIDescriptor" : {
|
||||
"mimeType" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"scheme": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"ext": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"path": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
export interface URIDescriptor {
|
||||
mimeType?: string;
|
||||
scheme?: string;
|
||||
ext?: string;
|
||||
path?: string;
|
||||
}
|
||||
|
||||
export function telemetryURIDescriptor(uri: URI, hashPath: (path: string) => string): URIDescriptor {
|
||||
const fsPath = uri && uri.fsPath;
|
||||
return fsPath ? { mimeType: guessMimeTypes(fsPath).join(', '), ext: paths.extname(fsPath), path: hashPath(fsPath) } : {};
|
||||
return fsPath ? { mimeType: guessMimeTypes(fsPath).join(', '), scheme: uri.scheme, ext: paths.extname(fsPath), path: hashPath(fsPath) } : {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Only add settings that cannot contain any personal/private information of users (PII).
|
||||
*/
|
||||
const configurationValueWhitelist = [
|
||||
'editor.tabCompletion',
|
||||
'editor.fontFamily',
|
||||
'editor.fontWeight',
|
||||
'editor.fontSize',
|
||||
@@ -113,8 +112,11 @@ const configurationValueWhitelist = [
|
||||
'editor.multiCursorModifier',
|
||||
'editor.quickSuggestions',
|
||||
'editor.quickSuggestionsDelay',
|
||||
'editor.parameterHints',
|
||||
'editor.parameterHints.enabled',
|
||||
'editor.parameterHints.cycle',
|
||||
'editor.autoClosingBrackets',
|
||||
'editor.autoClosingQuotes',
|
||||
'editor.autoSurround',
|
||||
'editor.autoIndent',
|
||||
'editor.formatOnType',
|
||||
'editor.formatOnPaste',
|
||||
@@ -127,11 +129,13 @@ const configurationValueWhitelist = [
|
||||
'editor.suggestSelection',
|
||||
'editor.suggestFontSize',
|
||||
'editor.suggestLineHeight',
|
||||
'editor.tabCompletion',
|
||||
'editor.selectionHighlight',
|
||||
'editor.occurrencesHighlight',
|
||||
'editor.overviewRulerLanes',
|
||||
'editor.overviewRulerBorder',
|
||||
'editor.cursorBlinking',
|
||||
'editor.cursorSmoothCaretAnimation',
|
||||
'editor.cursorStyle',
|
||||
'editor.mouseWheelZoom',
|
||||
'editor.fontLigatures',
|
||||
@@ -155,6 +159,7 @@ const configurationValueWhitelist = [
|
||||
'breadcrumbs.enabled',
|
||||
'breadcrumbs.filePath',
|
||||
'breadcrumbs.symbolPath',
|
||||
'breadcrumbs.symbolSortOrder',
|
||||
'breadcrumbs.useQuickPick',
|
||||
'explorer.openEditors.visible',
|
||||
'extensions.autoUpdate',
|
||||
@@ -180,6 +185,7 @@ const configurationValueWhitelist = [
|
||||
'workbench.editor.enablePreview',
|
||||
'workbench.editor.enablePreviewFromQuickOpen',
|
||||
'workbench.editor.showTabs',
|
||||
'workbench.editor.highlightModifiedTabs',
|
||||
'workbench.editor.swipeToNavigate',
|
||||
'workbench.sideBar.location',
|
||||
'workbench.startupEditor',
|
||||
@@ -197,7 +203,7 @@ export function configurationTelemetry(telemetryService: ITelemetryService, conf
|
||||
}
|
||||
*/
|
||||
telemetryService.publicLog('updateConfiguration', {
|
||||
configurationSource: ConfigurationTarget[event.source],
|
||||
configurationSource: ConfigurationTargetToString(event.source),
|
||||
configurationKeys: flattenKeys(event.sourceConfig)
|
||||
});
|
||||
/* __GDPR__
|
||||
@@ -207,7 +213,7 @@ export function configurationTelemetry(telemetryService: ITelemetryService, conf
|
||||
}
|
||||
*/
|
||||
telemetryService.publicLog('updateConfigurationValues', {
|
||||
configurationSource: ConfigurationTarget[event.source],
|
||||
configurationSource: ConfigurationTargetToString(event.source),
|
||||
configurationValues: flattenValues(event.sourceConfig, configurationValueWhitelist)
|
||||
});
|
||||
}
|
||||
@@ -264,5 +270,5 @@ function flattenValues(value: Object, keys: string[]): { [key: string]: any }[]
|
||||
array.push({ [key]: v });
|
||||
}
|
||||
return array;
|
||||
}, []);
|
||||
}, <{ [key: string]: any }[]>[]);
|
||||
}
|
||||
|
||||
@@ -2,47 +2,32 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as appInsights from 'applicationinsights';
|
||||
import { isObject } from 'vs/base/common/types';
|
||||
import { safeStringify, mixin } from 'vs/base/common/objects';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ITelemetryAppender } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
|
||||
let _initialized = false;
|
||||
function getClient(aiKey: string): appInsights.TelemetryClient {
|
||||
|
||||
function ensureAIEngineIsInitialized(): void {
|
||||
if (_initialized === false) {
|
||||
// we need to pass some fake key, otherwise AI throws an exception
|
||||
appInsights.setup('2588e01f-f6c9-4cd6-a348-143741f8d702')
|
||||
.setAutoCollectConsole(false)
|
||||
.setAutoCollectExceptions(false)
|
||||
let client: appInsights.TelemetryClient;
|
||||
if (appInsights.defaultClient) {
|
||||
client = new appInsights.TelemetryClient(aiKey);
|
||||
client.channel.setUseDiskRetryCaching(true);
|
||||
} else {
|
||||
appInsights.setup(aiKey)
|
||||
.setAutoCollectRequests(false)
|
||||
.setAutoCollectPerformance(false)
|
||||
.setAutoCollectRequests(false);
|
||||
|
||||
_initialized = true;
|
||||
.setAutoCollectExceptions(false)
|
||||
.setAutoCollectDependencies(false)
|
||||
.setAutoDependencyCorrelation(false)
|
||||
.setAutoCollectConsole(false)
|
||||
.setInternalLogging(false, false)
|
||||
.setUseDiskRetryCaching(true)
|
||||
.start();
|
||||
client = appInsights.defaultClient;
|
||||
}
|
||||
}
|
||||
|
||||
function getClient(aiKey: string): typeof appInsights.client {
|
||||
|
||||
ensureAIEngineIsInitialized();
|
||||
|
||||
const client = appInsights.getClient(aiKey);
|
||||
client.channel.setOfflineMode(true);
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// clear all ID fields from telemetry
|
||||
client.context.tags[client.context.keys.deviceMachineName] = '';
|
||||
client.context.tags[client.context.keys.cloudRoleInstance] = '';
|
||||
|
||||
// set envelope flags to suppress Vortex ingest header
|
||||
client.addTelemetryProcessor((envelope, contextObjects) => {
|
||||
envelope.flags = 0x200000;
|
||||
return true;
|
||||
});
|
||||
|
||||
if (aiKey.indexOf('AIF-') === 0) {
|
||||
client.config.endpointUrl = 'https://vortex.data.microsoft.com/collect/v1';
|
||||
@@ -60,12 +45,12 @@ interface Measurements {
|
||||
|
||||
export class AppInsightsAppender implements ITelemetryAppender {
|
||||
|
||||
private _aiClient: typeof appInsights.client;
|
||||
private _aiClient: appInsights.TelemetryClient;
|
||||
|
||||
constructor(
|
||||
private _eventPrefix: string,
|
||||
private _defaultData: { [key: string]: any },
|
||||
aiKeyOrClientFactory: string | (() => typeof appInsights.client), // allow factory function for testing
|
||||
aiKeyOrClientFactory: string | (() => appInsights.ITelemetryClient), // allow factory function for testing
|
||||
@ILogService private _logService?: ILogService
|
||||
) {
|
||||
if (!this._defaultData) {
|
||||
@@ -151,19 +136,25 @@ export class AppInsightsAppender implements ITelemetryAppender {
|
||||
if (this._logService) {
|
||||
this._logService.trace(`telemetry/${eventName}`, data);
|
||||
}
|
||||
this._aiClient.trackEvent(this._eventPrefix + '/' + eventName, data.properties, data.measurements);
|
||||
this._aiClient.trackEvent({
|
||||
name: this._eventPrefix + '/' + eventName,
|
||||
properties: data.properties,
|
||||
measurements: data.measurements
|
||||
});
|
||||
}
|
||||
|
||||
dispose(): TPromise<any> {
|
||||
dispose(): Promise<any> {
|
||||
if (this._aiClient) {
|
||||
return new TPromise(resolve => {
|
||||
this._aiClient.sendPendingData(() => {
|
||||
// all data flushed
|
||||
this._aiClient = undefined;
|
||||
resolve(void 0);
|
||||
return new Promise(resolve => {
|
||||
this._aiClient.flush({
|
||||
callback: () => {
|
||||
// all data flushed
|
||||
this._aiClient = undefined;
|
||||
resolve(void 0);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
|
||||
import * as Platform from 'vs/base/common/platform';
|
||||
import * as os from 'os';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as uuid from 'vs/base/common/uuid';
|
||||
import { readFile } from 'vs/base/node/pfs';
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
import product from 'vs/platform/node/product';
|
||||
|
||||
export function resolveCommonProperties(commit: string, version: string, machineId: string, installSourcePath: string): TPromise<{ [name: string]: string; }> {
|
||||
export function resolveCommonProperties(commit: string, version: string, machineId: string, installSourcePath: string): Promise<{ [name: string]: string; }> {
|
||||
const result: { [name: string]: string; } = Object.create(null);
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
@@ -30,7 +29,7 @@ export function resolveCommonProperties(commit: string, version: string, machine
|
||||
// __GDPR__COMMON__ "common.platformVersion" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
result['common.platformVersion'] = (os.release() || '').replace(/^(\d+)(\.\d+)?(\.\d+)?(.*)/, '$1$2$3');
|
||||
// __GDPR__COMMON__ "common.platform" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
result['common.platform'] = Platform.Platform[Platform.platform];
|
||||
result['common.platform'] = Platform.PlatformToString(Platform.platform);
|
||||
// __GDPR__COMMON__ "common.nodePlatform" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
|
||||
result['common.nodePlatform'] = process.platform;
|
||||
// __GDPR__COMMON__ "common.nodeArch" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
|
||||
@@ -69,4 +68,4 @@ export function resolveCommonProperties(commit: string, version: string, machine
|
||||
}, error => {
|
||||
return result;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc';
|
||||
import { ITelemetryAppender } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
|
||||
@@ -15,37 +12,32 @@ export interface ITelemetryLog {
|
||||
data?: any;
|
||||
}
|
||||
|
||||
export interface ITelemetryAppenderChannel extends IChannel {
|
||||
call(command: 'log', data: ITelemetryLog): TPromise<void>;
|
||||
call(command: string, arg: any): TPromise<any>;
|
||||
}
|
||||
|
||||
export class TelemetryAppenderChannel implements ITelemetryAppenderChannel {
|
||||
export class TelemetryAppenderChannel implements IServerChannel {
|
||||
|
||||
constructor(private appender: ITelemetryAppender) { }
|
||||
|
||||
listen<T>(event: string, arg?: any): Event<T> {
|
||||
throw new Error('No events');
|
||||
listen<T>(_, event: string): Event<T> {
|
||||
throw new Error(`Event not found: ${event}`);
|
||||
}
|
||||
|
||||
call(command: string, { eventName, data }: ITelemetryLog): TPromise<any> {
|
||||
call(_, command: string, { eventName, data }: ITelemetryLog): Thenable<any> {
|
||||
this.appender.log(eventName, data);
|
||||
return TPromise.as(null);
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
|
||||
export class TelemetryAppenderClient implements ITelemetryAppender {
|
||||
|
||||
constructor(private channel: ITelemetryAppenderChannel) { }
|
||||
constructor(private channel: IChannel) { }
|
||||
|
||||
log(eventName: string, data?: any): any {
|
||||
this.channel.call('log', { eventName, data })
|
||||
.done(null, err => `Failed to log telemetry: ${console.warn(err)}`);
|
||||
.then(undefined, err => `Failed to log telemetry: ${console.warn(err)}`);
|
||||
|
||||
return TPromise.as(null);
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
dispose(): any {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,14 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import URI from 'vs/base/common/uri';
|
||||
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import product from 'vs/platform/node/product';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
|
||||
export function addGAParameters(telemetryService: ITelemetryService, environmentService: IEnvironmentService, uri: URI, origin: string, experiment = '1'): TPromise<URI> {
|
||||
export function addGAParameters(telemetryService: ITelemetryService, environmentService: IEnvironmentService, uri: URI, origin: string, experiment = '1'): Thenable<URI> {
|
||||
if (environmentService.isBuilt && !environmentService.isExtensionDevelopment && !environmentService.args['disable-telemetry'] && !!product.enableTelemetry) {
|
||||
if (uri.scheme === 'https' && uri.authority === 'code.visualstudio.com') {
|
||||
return telemetryService.getTelemetryInfo()
|
||||
@@ -19,5 +18,5 @@ export function addGAParameters(telemetryService: ITelemetryService, environment
|
||||
});
|
||||
}
|
||||
}
|
||||
return TPromise.as(uri);
|
||||
return Promise.resolve(uri);
|
||||
}
|
||||
|
||||
@@ -3,43 +3,42 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as uuid from 'vs/base/common/uuid';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { resolveCommonProperties } from '../node/commonProperties';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { resolveCommonProperties } from 'vs/platform/telemetry/node/commonProperties';
|
||||
|
||||
export const lastSessionDateStorageKey = 'telemetry.lastSessionDate';
|
||||
|
||||
// {{ SQL CARBON EDIT }}
|
||||
import product from 'vs/platform/node/product';
|
||||
import * as Utils from 'sql/common/telemetryUtilities';
|
||||
|
||||
export function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string, version: string, machineId: string, installSourcePath: string): TPromise<{ [name: string]: string }> {
|
||||
export function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string, version: string, machineId: string, installSourcePath: string): Promise<{ [name: string]: string }> {
|
||||
return resolveCommonProperties(commit, version, machineId, installSourcePath).then(result => {
|
||||
// __GDPR__COMMON__ "common.version.shell" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
|
||||
result['common.version.shell'] = process.versions && (<any>process).versions['electron'];
|
||||
result['common.version.shell'] = process.versions && process.versions['electron'];
|
||||
// __GDPR__COMMON__ "common.version.renderer" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
|
||||
result['common.version.renderer'] = process.versions && (<any>process).versions['chrome'];
|
||||
result['common.version.renderer'] = process.versions && process.versions['chrome'];
|
||||
// {{SQL CARBON EDIT}}
|
||||
result['common.application.name'] = product.nameLong;
|
||||
// {{SQL CARBON EDIT}}
|
||||
result['common.userId'] = '';
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// const lastSessionDate = storageService.get('telemetry.lastSessionDate');
|
||||
// const firstSessionDate = storageService.get('telemetry.firstSessionDate') || new Date().toUTCString();
|
||||
// storageService.store('telemetry.firstSessionDate', firstSessionDate);
|
||||
// storageService.store('telemetry.lastSessionDate', new Date().toUTCString());
|
||||
|
||||
// // __GDPR__COMMON__ "common.firstSessionDate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
// result['common.firstSessionDate'] = firstSessionDate;
|
||||
// // __GDPR__COMMON__ "common.lastSessionDate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
// result['common.lastSessionDate'] = lastSessionDate;
|
||||
// // __GDPR__COMMON__ "common.isNewSession" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
// result['common.isNewSession'] = !lastSessionDate ? '1' : '0';
|
||||
// const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.GLOBAL);
|
||||
// if (!process.env['VSCODE_TEST_STORAGE_MIGRATION']) {
|
||||
// storageService.store(lastSessionDateStorageKey, new Date().toUTCString(), StorageScope.GLOBAL);
|
||||
// }
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// __GDPR__COMMON__ "common.instanceId" : { "classification": "EndUserPseudonymizedInformation", "purpose": "FeatureInsight" }
|
||||
// // __GDPR__COMMON__ "common.firstSessionDate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
// result['common.firstSessionDate'] = getOrCreateFirstSessionDate(storageService);
|
||||
// // __GDPR__COMMON__ "common.lastSessionDate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
// result['common.lastSessionDate'] = lastSessionDate || '';
|
||||
// // __GDPR__COMMON__ "common.isNewSession" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
// result['common.isNewSession'] = !lastSessionDate ? '1' : '0';
|
||||
// // __GDPR__COMMON__ "common.instanceId" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
// result['common.instanceId'] = getOrCreateInstanceId(storageService);
|
||||
result['common.instanceId'] = '';
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
setUsageDates(storageService);
|
||||
@@ -49,24 +48,46 @@ export function resolveWorkbenchCommonProperties(storageService: IStorageService
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// function getOrCreateInstanceId(storageService: IStorageService): string {
|
||||
// const result = storageService.get('telemetry.instanceId') || uuid.generateUuid();
|
||||
// storageService.store('telemetry.instanceId', result);
|
||||
// return result;
|
||||
// const key = 'telemetry.instanceId';
|
||||
|
||||
// let instanceId = storageService.get(key, StorageScope.GLOBAL, void 0);
|
||||
// if (instanceId) {
|
||||
// return instanceId;
|
||||
// }
|
||||
|
||||
// instanceId = uuid.generateUuid();
|
||||
// storageService.store(key, instanceId, StorageScope.GLOBAL);
|
||||
|
||||
// return instanceId;
|
||||
// }
|
||||
|
||||
function getOrCreateFirstSessionDate(storageService: IStorageService): string {
|
||||
const key = 'telemetry.firstSessionDate';
|
||||
|
||||
let firstSessionDate = storageService.get(key, StorageScope.GLOBAL, void 0);
|
||||
if (firstSessionDate) {
|
||||
return firstSessionDate;
|
||||
}
|
||||
|
||||
firstSessionDate = new Date().toUTCString();
|
||||
storageService.store(key, firstSessionDate, StorageScope.GLOBAL);
|
||||
|
||||
return firstSessionDate;
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
function setUsageDates(storageService: IStorageService): void {
|
||||
// daily last usage date
|
||||
const appStartDate = new Date('January 1, 2000');
|
||||
const dailyLastUseDate = storageService.get('telemetry.dailyLastUseDate') || appStartDate;
|
||||
storageService.store('telemetry.dailyLastUseDate', dailyLastUseDate);
|
||||
const dailyLastUseDate = storageService.get('telemetry.dailyLastUseDate', StorageScope.GLOBAL) || appStartDate;
|
||||
storageService.store('telemetry.dailyLastUseDate', dailyLastUseDate, StorageScope.GLOBAL);
|
||||
|
||||
// weekly last usage date
|
||||
const weeklyLastUseDate = storageService.get('telemetry.weeklyLastUseDate') || appStartDate;
|
||||
storageService.store('telemetry.weeklyLastUseDate', weeklyLastUseDate);
|
||||
const weeklyLastUseDate = storageService.get('telemetry.weeklyLastUseDate', StorageScope.GLOBAL) || appStartDate;
|
||||
storageService.store('telemetry.weeklyLastUseDate', weeklyLastUseDate, StorageScope.GLOBAL);
|
||||
|
||||
// monthly last usage date
|
||||
const monthlyLastUseDate = storageService.get('telemetry.monthlyLastUseDate') || appStartDate;
|
||||
storageService.store('telemetry.monthlyLastUseDate', monthlyLastUseDate);
|
||||
const monthlyLastUseDate = storageService.get('telemetry.monthlyLastUseDate', StorageScope.GLOBAL) || appStartDate;
|
||||
storageService.store('telemetry.monthlyLastUseDate', monthlyLastUseDate, StorageScope.GLOBAL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,40 +2,23 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppender';
|
||||
import { ILogService, AbstractLogService, LogLevel, DEFAULT_LOG_LEVEL } from 'vs/platform/log/common/log';
|
||||
import { ITelemetryClient, EventTelemetry } from 'applicationinsights';
|
||||
|
||||
interface IAppInsightsEvent {
|
||||
eventName: string;
|
||||
properties?: { [x: string]: string; };
|
||||
measurements?: { [x: string]: number; };
|
||||
}
|
||||
|
||||
class AppInsightsMock {
|
||||
|
||||
public events: IAppInsightsEvent[] = [];
|
||||
class AppInsightsMock implements ITelemetryClient {
|
||||
public config: any;
|
||||
public channel: any;
|
||||
public events: EventTelemetry[] = [];
|
||||
public IsTrackingPageView: boolean = false;
|
||||
public exceptions: any[] = [];
|
||||
|
||||
public trackEvent(eventName: string, properties?: { string?: string; }, measurements?: { string?: number; }): void {
|
||||
this.events.push({
|
||||
eventName,
|
||||
properties,
|
||||
measurements
|
||||
});
|
||||
}
|
||||
public trackPageView(): void {
|
||||
this.IsTrackingPageView = true;
|
||||
public trackEvent(event: any) {
|
||||
this.events.push(event);
|
||||
}
|
||||
|
||||
public trackException(exception: any): void {
|
||||
this.exceptions.push(exception);
|
||||
}
|
||||
|
||||
public sendPendingData(_callback: any): void {
|
||||
public flush(options: any): void {
|
||||
// called on dispose
|
||||
}
|
||||
}
|
||||
@@ -108,7 +91,7 @@ suite('AIAdapter', () => {
|
||||
adapter.log('testEvent');
|
||||
|
||||
assert.equal(appInsightsMock.events.length, 1);
|
||||
assert.equal(appInsightsMock.events[0].eventName, `${prefix}/testEvent`);
|
||||
assert.equal(appInsightsMock.events[0].name, `${prefix}/testEvent`);
|
||||
});
|
||||
|
||||
test('addional data', () => {
|
||||
@@ -117,7 +100,7 @@ suite('AIAdapter', () => {
|
||||
|
||||
assert.equal(appInsightsMock.events.length, 1);
|
||||
let [first] = appInsightsMock.events;
|
||||
assert.equal(first.eventName, `${prefix}/testEvent`);
|
||||
assert.equal(first.name, `${prefix}/testEvent`);
|
||||
assert.equal(first.properties['first'], '1st');
|
||||
assert.equal(first.measurements['second'], '2');
|
||||
assert.equal(first.measurements['third'], 1);
|
||||
@@ -154,7 +137,7 @@ suite('AIAdapter', () => {
|
||||
adapter.log('testEvent', { favoriteDate: date, likeRed: false, likeBlue: true, favoriteNumber: 1, favoriteColor: 'blue', favoriteCars: ['bmw', 'audi', 'ford'] });
|
||||
|
||||
assert.equal(appInsightsMock.events.length, 1);
|
||||
assert.equal(appInsightsMock.events[0].eventName, `${prefix}/testEvent`);
|
||||
assert.equal(appInsightsMock.events[0].name, `${prefix}/testEvent`);
|
||||
assert.equal(appInsightsMock.events[0].properties['favoriteColor'], 'blue');
|
||||
assert.equal(appInsightsMock.events[0].measurements['likeRed'], 0);
|
||||
assert.equal(appInsightsMock.events[0].measurements['likeBlue'], 1);
|
||||
@@ -183,7 +166,7 @@ suite('AIAdapter', () => {
|
||||
});
|
||||
|
||||
assert.equal(appInsightsMock.events.length, 1);
|
||||
assert.equal(appInsightsMock.events[0].eventName, `${prefix}/testEvent`);
|
||||
assert.equal(appInsightsMock.events[0].name, `${prefix}/testEvent`);
|
||||
|
||||
assert.equal(appInsightsMock.events[0].properties['window.title'], 'some title');
|
||||
assert.equal(appInsightsMock.events[0].measurements['window.measurements.width'], 100);
|
||||
|
||||
@@ -2,16 +2,13 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import * as fs from 'fs';
|
||||
import { resolveWorkbenchCommonProperties } from 'vs/platform/telemetry/node/workbenchCommonProperties';
|
||||
import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common/storageService';
|
||||
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
import { getRandomTestPath } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { IStorageService, StorageScope, InMemoryStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { del } from 'vs/base/node/extfs';
|
||||
import { mkdirp } from 'vs/base/node/pfs';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
@@ -22,10 +19,10 @@ suite('Telemetry - common properties', function () {
|
||||
|
||||
const commit: string = void 0;
|
||||
const version: string = void 0;
|
||||
let storageService: StorageService;
|
||||
let testStorageService: IStorageService;
|
||||
|
||||
setup(() => {
|
||||
storageService = new StorageService(new InMemoryLocalStorage(), null, TestWorkspace.id);
|
||||
testStorageService = new InMemoryStorageService();
|
||||
});
|
||||
|
||||
teardown(done => {
|
||||
@@ -33,74 +30,57 @@ suite('Telemetry - common properties', function () {
|
||||
});
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// test('default', function () {
|
||||
// return mkdirp(parentDir).then(() => {
|
||||
// fs.writeFileSync(installSource, 'my.install.source');
|
||||
|
||||
// return resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource).then(props => {
|
||||
// assert.ok('commitHash' in props);
|
||||
// assert.ok('sessionID' in props);
|
||||
// assert.ok('timestamp' in props);
|
||||
// assert.ok('common.platform' in props);
|
||||
// assert.ok('common.nodePlatform' in props);
|
||||
// assert.ok('common.nodeArch' in props);
|
||||
// assert.ok('common.timesincesessionstart' in props);
|
||||
// assert.ok('common.sequence' in props);
|
||||
|
||||
// // assert.ok('common.version.shell' in first.data); // only when running on electron
|
||||
// // assert.ok('common.version.renderer' in first.data);
|
||||
// assert.ok('common.osVersion' in props, 'osVersion');
|
||||
// assert.ok('common.platformVersion' in props, 'platformVersion');
|
||||
// assert.ok('version' in props);
|
||||
// assert.equal(props['common.source'], 'my.install.source');
|
||||
|
||||
// // {{SQL CARBON EDIT}}
|
||||
// assert.ok('common.application.name' in props);
|
||||
|
||||
// assert.ok('common.firstSessionDate' in props, 'firstSessionDate');
|
||||
// assert.ok('common.lastSessionDate' in props, 'lastSessionDate'); // conditional, see below, 'lastSessionDate'ow
|
||||
// assert.ok('common.isNewSession' in props, 'isNewSession');
|
||||
|
||||
// // machine id et al
|
||||
// assert.ok('common.instanceId' in props, 'instanceId');
|
||||
// assert.ok('common.machineId' in props, 'machineId');
|
||||
|
||||
// fs.unlinkSync(installSource);
|
||||
|
||||
// return resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource).then(props => {
|
||||
// assert.ok(!('common.source' in props));
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// test('default', async function () {
|
||||
// await mkdirp(parentDir);
|
||||
// fs.writeFileSync(installSource, 'my.install.source');
|
||||
// const props = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', installSource);
|
||||
// assert.ok('commitHash' in props);
|
||||
// assert.ok('sessionID' in props);
|
||||
// assert.ok('timestamp' in props);
|
||||
// assert.ok('common.platform' in props);
|
||||
// assert.ok('common.nodePlatform' in props);
|
||||
// assert.ok('common.nodeArch' in props);
|
||||
// assert.ok('common.timesincesessionstart' in props);
|
||||
// assert.ok('common.sequence' in props);
|
||||
// // assert.ok('common.version.shell' in first.data); // only when running on electron
|
||||
// // assert.ok('common.version.renderer' in first.data);
|
||||
// assert.ok('common.platformVersion' in props, 'platformVersion');
|
||||
// assert.ok('version' in props);
|
||||
// assert.equal(props['common.source'], 'my.install.source');
|
||||
// assert.ok('common.firstSessionDate' in props, 'firstSessionDate');
|
||||
// assert.ok('common.lastSessionDate' in props, 'lastSessionDate'); // conditional, see below, 'lastSessionDate'ow
|
||||
// assert.ok('common.isNewSession' in props, 'isNewSession');
|
||||
// // machine id et al
|
||||
// assert.ok('common.instanceId' in props, 'instanceId');
|
||||
// assert.ok('common.machineId' in props, 'machineId');
|
||||
// fs.unlinkSync(installSource);
|
||||
// const props_1 = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', installSource);
|
||||
// assert.ok(!('common.source' in props_1));
|
||||
// });
|
||||
|
||||
// test('lastSessionDate when aviablale', function () {
|
||||
// test('lastSessionDate when aviablale', async function () {
|
||||
|
||||
// storageService.store('telemetry.lastSessionDate', new Date().toUTCString());
|
||||
// testStorageService.store('telemetry.lastSessionDate', new Date().toUTCString(), StorageScope.GLOBAL);
|
||||
|
||||
// return resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource).then(props => {
|
||||
|
||||
// assert.ok('common.lastSessionDate' in props); // conditional, see below
|
||||
// assert.ok('common.isNewSession' in props);
|
||||
// assert.equal(props['common.isNewSession'], 0);
|
||||
// });
|
||||
// const props = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', installSource);
|
||||
// assert.ok('common.lastSessionDate' in props); // conditional, see below
|
||||
// assert.ok('common.isNewSession' in props);
|
||||
// assert.equal(props['common.isNewSession'], 0);
|
||||
// });
|
||||
|
||||
test('values chance on ask', function () {
|
||||
return resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource).then(props => {
|
||||
let value1 = props['common.sequence'];
|
||||
let value2 = props['common.sequence'];
|
||||
assert.ok(value1 !== value2, 'seq');
|
||||
test('values chance on ask', async function () {
|
||||
const props = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', installSource);
|
||||
let value1 = props['common.sequence'];
|
||||
let value2 = props['common.sequence'];
|
||||
assert.ok(value1 !== value2, 'seq');
|
||||
|
||||
value1 = props['timestamp'];
|
||||
value2 = props['timestamp'];
|
||||
assert.ok(value1 !== value2, 'timestamp');
|
||||
value1 = props['timestamp'];
|
||||
value2 = props['timestamp'];
|
||||
assert.ok(value1 !== value2, 'timestamp');
|
||||
|
||||
value1 = props['common.timesincesessionstart'];
|
||||
return timeout(10).then(_ => {
|
||||
value2 = props['common.timesincesessionstart'];
|
||||
assert.ok(value1 !== value2, 'timesincesessionstart');
|
||||
});
|
||||
});
|
||||
value1 = props['common.timesincesessionstart'];
|
||||
await timeout(10);
|
||||
value2 = props['common.timesincesessionstart'];
|
||||
assert.ok(value1 !== value2, 'timesincesessionstart');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,17 +2,15 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { TelemetryService } from 'vs/platform/telemetry/common/telemetryService';
|
||||
import ErrorTelemetry from 'vs/platform/telemetry/browser/errorTelemetry';
|
||||
import { NullAppender, ITelemetryAppender } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import * as Errors from 'vs/base/common/errors';
|
||||
import * as sinon from 'sinon';
|
||||
import { getConfigurationValue } from 'vs/platform/configuration/common/configuration';
|
||||
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
|
||||
|
||||
class TestTelemetryAppender implements ITelemetryAppender {
|
||||
|
||||
@@ -32,9 +30,9 @@ class TestTelemetryAppender implements ITelemetryAppender {
|
||||
return this.events.length;
|
||||
}
|
||||
|
||||
public dispose(): TPromise<any> {
|
||||
public dispose(): Promise<any> {
|
||||
this.isDisposed = true;
|
||||
return TPromise.as(null);
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +48,7 @@ class ErrorTestingSettings {
|
||||
public noSuchFileMessage: string;
|
||||
public stack: string[];
|
||||
public randomUserFile: string = 'a/path/that/doe_snt/con-tain/code/names.js';
|
||||
public anonymizedRandomUserFile: string = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
|
||||
public anonymizedRandomUserFile: string = '<REDACTED: user-file-path>';
|
||||
public nodeModulePathToRetain: string = 'node_modules/path/that/shouldbe/retained/names.js:14:15854';
|
||||
public nodeModuleAsarPathToRetain: string = 'node_modules.asar/path/that/shouldbe/retained/names.js:14:12354';
|
||||
|
||||
@@ -141,7 +139,7 @@ suite('TelemetryService', () => {
|
||||
let testAppender = new TestTelemetryAppender();
|
||||
let service = new TelemetryService({
|
||||
appender: testAppender,
|
||||
commonProperties: TPromise.as({ foo: 'JA!', get bar() { return Math.random(); } })
|
||||
commonProperties: Promise.resolve({ foo: 'JA!', get bar() { return Math.random(); } })
|
||||
}, undefined);
|
||||
|
||||
return service.publicLog('testEvent').then(_ => {
|
||||
@@ -159,7 +157,7 @@ suite('TelemetryService', () => {
|
||||
let testAppender = new TestTelemetryAppender();
|
||||
let service = new TelemetryService({
|
||||
appender: testAppender,
|
||||
commonProperties: TPromise.as({ foo: 'JA!', get bar() { return Math.random(); } })
|
||||
commonProperties: Promise.resolve({ foo: 'JA!', get bar() { return Math.random(); } })
|
||||
}, undefined);
|
||||
|
||||
return service.publicLog('testEvent', { hightower: 'xl', price: 8000 }).then(_ => {
|
||||
@@ -178,7 +176,7 @@ suite('TelemetryService', () => {
|
||||
test('TelemetryInfo comes from properties', function () {
|
||||
let service = new TelemetryService({
|
||||
appender: NullAppender,
|
||||
commonProperties: TPromise.as({
|
||||
commonProperties: Promise.resolve({
|
||||
sessionID: 'one',
|
||||
['common.instanceId']: 'two',
|
||||
['common.machineId']: 'three',
|
||||
@@ -206,16 +204,31 @@ suite('TelemetryService', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
class JoinableTelemetryService extends TelemetryService {
|
||||
|
||||
private readonly promises: Thenable<void>[] = [];
|
||||
|
||||
join(): Promise<any> {
|
||||
return Promise.all(this.promises);
|
||||
}
|
||||
|
||||
publicLog(eventName: string, data?: ITelemetryData, anonymizeFilePaths?: boolean): Thenable<void> {
|
||||
let p = super.publicLog(eventName, data, anonymizeFilePaths);
|
||||
this.promises.push(p);
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// test('Error events', sinon.test(function (this: any) {
|
||||
// test('Error events', sinon.test(async function (this: any) {
|
||||
|
||||
// let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
|
||||
// Errors.setUnexpectedErrorHandler(() => { });
|
||||
|
||||
// try {
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
// try {
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
|
||||
// let e: any = new Error('This is a test.');
|
||||
@@ -224,11 +237,13 @@ suite('TelemetryService', () => {
|
||||
// e.stack = 'blah';
|
||||
// }
|
||||
|
||||
// Errors.onUnexpectedError(e);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// assert.equal(testAppender.getEventsCount(), 1);
|
||||
// assert.equal(testAppender.events[0].eventName, 'UnhandledError');
|
||||
// assert.equal(testAppender.events[0].data.msg, 'This is a test.');
|
||||
// Errors.onUnexpectedError(e);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.equal(testAppender.getEventsCount(), 1);
|
||||
// assert.equal(testAppender.events[0].eventName, 'UnhandledError');
|
||||
// assert.equal(testAppender.events[0].data.msg, 'This is a test.');
|
||||
|
||||
// errorTelemetry.dispose();
|
||||
// service.dispose();
|
||||
@@ -266,17 +281,18 @@ suite('TelemetryService', () => {
|
||||
// }
|
||||
// }));
|
||||
|
||||
// test('Handle global errors', sinon.test(function (this: any) {
|
||||
// test('Handle global errors', sinon.test(async function (this: any) {
|
||||
// let errorStub = sinon.stub();
|
||||
// window.onerror = errorStub;
|
||||
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let testError = new Error('test');
|
||||
// (<any>window.onerror)('Error Message', 'file.js', 2, 42, testError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.equal(errorStub.alwaysCalledWithExactly('Error Message', 'file.js', 2, 42, testError), true);
|
||||
// assert.equal(errorStub.callCount, 1);
|
||||
@@ -293,12 +309,12 @@ suite('TelemetryService', () => {
|
||||
// service.dispose();
|
||||
// }));
|
||||
|
||||
// test('Error Telemetry removes PII from filename with spaces', sinon.test(function (this: any) {
|
||||
// test('Error Telemetry removes PII from filename with spaces', sinon.test(async function (this: any) {
|
||||
// let errorStub = sinon.stub();
|
||||
// window.onerror = errorStub;
|
||||
// let settings = new ErrorTestingSettings();
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let personInfoWithSpaces = settings.personalInfo.slice(0, 2) + ' ' + settings.personalInfo.slice(2);
|
||||
@@ -306,6 +322,7 @@ suite('TelemetryService', () => {
|
||||
// dangerousFilenameError.stack = settings.stack;
|
||||
// (<any>window.onerror)('dangerousFilename', settings.dangerousPathWithImportantInfo.replace(settings.personalInfo, personInfoWithSpaces) + '/test.js', 2, 42, dangerousFilenameError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.equal(errorStub.callCount, 1);
|
||||
// assert.equal(testAppender.events[0].data.file.indexOf(settings.dangerousPathWithImportantInfo.replace(settings.personalInfo, personInfoWithSpaces)), -1);
|
||||
@@ -315,49 +332,52 @@ suite('TelemetryService', () => {
|
||||
// service.dispose();
|
||||
// }));
|
||||
|
||||
|
||||
// test('Uncaught Error Telemetry removes PII from filename', sinon.test(function (this: any) {
|
||||
// let clock = this.clock;
|
||||
// let errorStub = sinon.stub();
|
||||
// window.onerror = errorStub;
|
||||
// let settings = new ErrorTestingSettings();
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let dangerousFilenameError: any = new Error('dangerousFilename');
|
||||
// dangerousFilenameError.stack = settings.stack;
|
||||
// (<any>window.onerror)('dangerousFilename', settings.dangerousPathWithImportantInfo + '/test.js', 2, 42, dangerousFilenameError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// return service.join().then(() => {
|
||||
// assert.equal(errorStub.callCount, 1);
|
||||
// assert.equal(testAppender.events[0].data.file.indexOf(settings.dangerousPathWithImportantInfo), -1);
|
||||
|
||||
// assert.equal(errorStub.callCount, 1);
|
||||
// assert.equal(testAppender.events[0].data.file.indexOf(settings.dangerousPathWithImportantInfo), -1);
|
||||
// dangerousFilenameError = new Error('dangerousFilename');
|
||||
// dangerousFilenameError.stack = settings.stack;
|
||||
// (<any>window.onerror)('dangerousFilename', settings.dangerousPathWithImportantInfo + '/test.js', 2, 42, dangerousFilenameError);
|
||||
// clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// return service.join();
|
||||
// }).then(() => {
|
||||
// assert.equal(errorStub.callCount, 2);
|
||||
// assert.equal(testAppender.events[0].data.file.indexOf(settings.dangerousPathWithImportantInfo), -1);
|
||||
// assert.equal(testAppender.events[0].data.file, settings.importantInfo + '/test.js');
|
||||
|
||||
// dangerousFilenameError = new Error('dangerousFilename');
|
||||
// dangerousFilenameError.stack = settings.stack;
|
||||
// (<any>window.onerror)('dangerousFilename', settings.dangerousPathWithImportantInfo + '/test.js', 2, 42, dangerousFilenameError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
|
||||
// assert.equal(errorStub.callCount, 2);
|
||||
// assert.equal(testAppender.events[0].data.file.indexOf(settings.dangerousPathWithImportantInfo), -1);
|
||||
// assert.equal(testAppender.events[0].data.file, settings.importantInfo + '/test.js');
|
||||
|
||||
// errorTelemetry.dispose();
|
||||
// service.dispose();
|
||||
// errorTelemetry.dispose();
|
||||
// service.dispose();
|
||||
// });
|
||||
// }));
|
||||
|
||||
// test('Unexpected Error Telemetry removes PII', sinon.test(function (this: any) {
|
||||
// test('Unexpected Error Telemetry removes PII', sinon.test(async function (this: any) {
|
||||
// let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
|
||||
// Errors.setUnexpectedErrorHandler(() => { });
|
||||
// try {
|
||||
// let settings = new ErrorTestingSettings();
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let dangerousPathWithoutImportantInfoError: any = new Error(settings.dangerousPathWithoutImportantInfo);
|
||||
// dangerousPathWithoutImportantInfoError.stack = settings.stack;
|
||||
// Errors.onUnexpectedError(dangerousPathWithoutImportantInfoError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.equal(testAppender.events[0].data.msg.indexOf(settings.personalInfo), -1);
|
||||
// assert.equal(testAppender.events[0].data.msg.indexOf(settings.filePrefix), -1);
|
||||
@@ -375,18 +395,19 @@ suite('TelemetryService', () => {
|
||||
// }
|
||||
// }));
|
||||
|
||||
// test('Uncaught Error Telemetry removes PII', sinon.test(function (this: any) {
|
||||
// test('Uncaught Error Telemetry removes PII', sinon.test(async function (this: any) {
|
||||
// let errorStub = sinon.stub();
|
||||
// window.onerror = errorStub;
|
||||
// let settings = new ErrorTestingSettings();
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let dangerousPathWithoutImportantInfoError: any = new Error('dangerousPathWithoutImportantInfo');
|
||||
// dangerousPathWithoutImportantInfoError.stack = settings.stack;
|
||||
// (<any>window.onerror)(settings.dangerousPathWithoutImportantInfo, 'test.js', 2, 42, dangerousPathWithoutImportantInfoError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.equal(errorStub.callCount, 1);
|
||||
// // Test that no file information remains, esp. personal info
|
||||
@@ -401,7 +422,7 @@ suite('TelemetryService', () => {
|
||||
// service.dispose();
|
||||
// }));
|
||||
|
||||
// test('Unexpected Error Telemetry removes PII but preserves Code file path', sinon.test(function (this: any) {
|
||||
// test('Unexpected Error Telemetry removes PII but preserves Code file path', sinon.test(async function (this: any) {
|
||||
|
||||
// let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
|
||||
// Errors.setUnexpectedErrorHandler(() => { });
|
||||
@@ -409,7 +430,7 @@ suite('TelemetryService', () => {
|
||||
// try {
|
||||
// let settings = new ErrorTestingSettings();
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let dangerousPathWithImportantInfoError: any = new Error(settings.dangerousPathWithImportantInfo);
|
||||
@@ -418,6 +439,7 @@ suite('TelemetryService', () => {
|
||||
// // Test that important information remains but personal info does not
|
||||
// Errors.onUnexpectedError(dangerousPathWithImportantInfoError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.notEqual(testAppender.events[0].data.msg.indexOf(settings.importantInfo), -1);
|
||||
// assert.equal(testAppender.events[0].data.msg.indexOf(settings.personalInfo), -1);
|
||||
@@ -436,18 +458,19 @@ suite('TelemetryService', () => {
|
||||
// }
|
||||
// }));
|
||||
|
||||
// test('Uncaught Error Telemetry removes PII but preserves Code file path', sinon.test(function (this: any) {
|
||||
// test('Uncaught Error Telemetry removes PII but preserves Code file path', sinon.test(async function (this: any) {
|
||||
// let errorStub = sinon.stub();
|
||||
// window.onerror = errorStub;
|
||||
// let settings = new ErrorTestingSettings();
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let dangerousPathWithImportantInfoError: any = new Error('dangerousPathWithImportantInfo');
|
||||
// dangerousPathWithImportantInfoError.stack = settings.stack;
|
||||
// (<any>window.onerror)(settings.dangerousPathWithImportantInfo, 'test.js', 2, 42, dangerousPathWithImportantInfoError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.equal(errorStub.callCount, 1);
|
||||
// // Test that important information remains but personal info does not
|
||||
@@ -464,7 +487,7 @@ suite('TelemetryService', () => {
|
||||
// service.dispose();
|
||||
// }));
|
||||
|
||||
// test('Unexpected Error Telemetry removes PII but preserves Code file path with node modules', sinon.test(function (this: any) {
|
||||
// test('Unexpected Error Telemetry removes PII but preserves Code file path with node modules', sinon.test(async function (this: any) {
|
||||
|
||||
// let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
|
||||
// Errors.setUnexpectedErrorHandler(() => { });
|
||||
@@ -472,7 +495,7 @@ suite('TelemetryService', () => {
|
||||
// try {
|
||||
// let settings = new ErrorTestingSettings();
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let dangerousPathWithImportantInfoError: any = new Error(settings.dangerousPathWithImportantInfo);
|
||||
@@ -481,6 +504,7 @@ suite('TelemetryService', () => {
|
||||
|
||||
// Errors.onUnexpectedError(dangerousPathWithImportantInfoError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.notEqual(testAppender.events[0].data.callstack.indexOf('(' + settings.nodeModuleAsarPathToRetain), -1);
|
||||
// assert.notEqual(testAppender.events[0].data.callstack.indexOf('(' + settings.nodeModulePathToRetain), -1);
|
||||
@@ -495,18 +519,19 @@ suite('TelemetryService', () => {
|
||||
// }
|
||||
// }));
|
||||
|
||||
// test('Uncaught Error Telemetry removes PII but preserves Code file path', sinon.test(function (this: any) {
|
||||
// test('Uncaught Error Telemetry removes PII but preserves Code file path', sinon.test(async function (this: any) {
|
||||
// let errorStub = sinon.stub();
|
||||
// window.onerror = errorStub;
|
||||
// let settings = new ErrorTestingSettings();
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let dangerousPathWithImportantInfoError: any = new Error('dangerousPathWithImportantInfo');
|
||||
// dangerousPathWithImportantInfoError.stack = settings.stack;
|
||||
// (<any>window.onerror)(settings.dangerousPathWithImportantInfo, 'test.js', 2, 42, dangerousPathWithImportantInfoError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.equal(errorStub.callCount, 1);
|
||||
|
||||
@@ -520,7 +545,7 @@ suite('TelemetryService', () => {
|
||||
// }));
|
||||
|
||||
|
||||
// test('Unexpected Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinon.test(function (this: any) {
|
||||
// test('Unexpected Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinon.test(async function (this: any) {
|
||||
|
||||
// let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
|
||||
// Errors.setUnexpectedErrorHandler(() => { });
|
||||
@@ -528,7 +553,7 @@ suite('TelemetryService', () => {
|
||||
// try {
|
||||
// let settings = new ErrorTestingSettings();
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender, piiPaths: [settings.personalInfo + '/resources/app/'] }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender, piiPaths: [settings.personalInfo + '/resources/app/'] }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let dangerousPathWithImportantInfoError: any = new Error(settings.dangerousPathWithImportantInfo);
|
||||
@@ -537,6 +562,7 @@ suite('TelemetryService', () => {
|
||||
// // Test that important information remains but personal info does not
|
||||
// Errors.onUnexpectedError(dangerousPathWithImportantInfoError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.notEqual(testAppender.events[0].data.msg.indexOf(settings.importantInfo), -1);
|
||||
// assert.equal(testAppender.events[0].data.msg.indexOf(settings.personalInfo), -1);
|
||||
@@ -555,18 +581,19 @@ suite('TelemetryService', () => {
|
||||
// }
|
||||
// }));
|
||||
|
||||
// test('Uncaught Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinon.test(function (this: any) {
|
||||
// test('Uncaught Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinon.test(async function (this: any) {
|
||||
// let errorStub = sinon.stub();
|
||||
// window.onerror = errorStub;
|
||||
// let settings = new ErrorTestingSettings();
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender, piiPaths: [settings.personalInfo + '/resources/app/'] }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender, piiPaths: [settings.personalInfo + '/resources/app/'] }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let dangerousPathWithImportantInfoError: any = new Error('dangerousPathWithImportantInfo');
|
||||
// dangerousPathWithImportantInfoError.stack = settings.stack;
|
||||
// (<any>window.onerror)(settings.dangerousPathWithImportantInfo, 'test.js', 2, 42, dangerousPathWithImportantInfoError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.equal(errorStub.callCount, 1);
|
||||
// // Test that important information remains but personal info does not
|
||||
@@ -583,7 +610,7 @@ suite('TelemetryService', () => {
|
||||
// service.dispose();
|
||||
// }));
|
||||
|
||||
// test('Unexpected Error Telemetry removes PII but preserves Missing Model error message', sinon.test(function (this: any) {
|
||||
// test('Unexpected Error Telemetry removes PII but preserves Missing Model error message', sinon.test(async function (this: any) {
|
||||
|
||||
// let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
|
||||
// Errors.setUnexpectedErrorHandler(() => { });
|
||||
@@ -591,7 +618,7 @@ suite('TelemetryService', () => {
|
||||
// try {
|
||||
// let settings = new ErrorTestingSettings();
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let missingModelError: any = new Error(settings.missingModelMessage);
|
||||
@@ -601,6 +628,7 @@ suite('TelemetryService', () => {
|
||||
// // error message does (Received model events for missing model)
|
||||
// Errors.onUnexpectedError(missingModelError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.notEqual(testAppender.events[0].data.msg.indexOf(settings.missingModelPrefix), -1);
|
||||
// assert.equal(testAppender.events[0].data.msg.indexOf(settings.personalInfo), -1);
|
||||
@@ -618,18 +646,19 @@ suite('TelemetryService', () => {
|
||||
// }
|
||||
// }));
|
||||
|
||||
// test('Uncaught Error Telemetry removes PII but preserves Missing Model error message', sinon.test(function (this: any) {
|
||||
// test('Uncaught Error Telemetry removes PII but preserves Missing Model error message', sinon.test(async function (this: any) {
|
||||
// let errorStub = sinon.stub();
|
||||
// window.onerror = errorStub;
|
||||
// let settings = new ErrorTestingSettings();
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let missingModelError: any = new Error('missingModelMessage');
|
||||
// missingModelError.stack = settings.stack;
|
||||
// (<any>window.onerror)(settings.missingModelMessage, 'test.js', 2, 42, missingModelError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.equal(errorStub.callCount, 1);
|
||||
// // Test that no file information remains, but this particular
|
||||
@@ -647,7 +676,7 @@ suite('TelemetryService', () => {
|
||||
// service.dispose();
|
||||
// }));
|
||||
|
||||
// test('Unexpected Error Telemetry removes PII but preserves No Such File error message', sinon.test(function (this: any) {
|
||||
// test('Unexpected Error Telemetry removes PII but preserves No Such File error message', sinon.test(async function (this: any) {
|
||||
|
||||
// let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
|
||||
// Errors.setUnexpectedErrorHandler(() => { });
|
||||
@@ -655,7 +684,7 @@ suite('TelemetryService', () => {
|
||||
// try {
|
||||
// let settings = new ErrorTestingSettings();
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let noSuchFileError: any = new Error(settings.noSuchFileMessage);
|
||||
@@ -665,6 +694,7 @@ suite('TelemetryService', () => {
|
||||
// // error message does (ENOENT: no such file or directory)
|
||||
// Errors.onUnexpectedError(noSuchFileError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.notEqual(testAppender.events[0].data.msg.indexOf(settings.noSuchFilePrefix), -1);
|
||||
// assert.equal(testAppender.events[0].data.msg.indexOf(settings.personalInfo), -1);
|
||||
@@ -682,7 +712,7 @@ suite('TelemetryService', () => {
|
||||
// }
|
||||
// }));
|
||||
|
||||
// test('Uncaught Error Telemetry removes PII but preserves No Such File error message', sinon.test(function (this: any) {
|
||||
// test('Uncaught Error Telemetry removes PII but preserves No Such File error message', sinon.test(async function (this: any) {
|
||||
// let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
|
||||
// Errors.setUnexpectedErrorHandler(() => { });
|
||||
|
||||
@@ -691,13 +721,14 @@ suite('TelemetryService', () => {
|
||||
// window.onerror = errorStub;
|
||||
// let settings = new ErrorTestingSettings();
|
||||
// let testAppender = new TestTelemetryAppender();
|
||||
// let service = new TelemetryService({ appender: testAppender }, undefined);
|
||||
// let service = new JoinableTelemetryService({ appender: testAppender }, undefined);
|
||||
// const errorTelemetry = new ErrorTelemetry(service);
|
||||
|
||||
// let noSuchFileError: any = new Error('noSuchFileMessage');
|
||||
// noSuchFileError.stack = settings.stack;
|
||||
// (<any>window.onerror)(settings.noSuchFileMessage, 'test.js', 2, 42, noSuchFileError);
|
||||
// this.clock.tick(ErrorTelemetry.ERROR_FLUSH_TIMEOUT);
|
||||
// await service.join();
|
||||
|
||||
// assert.equal(errorStub.callCount, 1);
|
||||
// // Test that no file information remains, but this particular
|
||||
@@ -744,7 +775,7 @@ suite('TelemetryService', () => {
|
||||
enableTelemetry: enableTelemetry
|
||||
} as any;
|
||||
},
|
||||
updateValue(): TPromise<void> {
|
||||
updateValue(): Promise<void> {
|
||||
return null;
|
||||
},
|
||||
inspect(key: string) {
|
||||
@@ -758,7 +789,7 @@ suite('TelemetryService', () => {
|
||||
},
|
||||
keys() { return { default: [], user: [], workspace: [], workspaceFolder: [] }; },
|
||||
onDidChangeConfiguration: emitter.event,
|
||||
reloadConfiguration(): TPromise<void> { return null; },
|
||||
reloadConfiguration(): Promise<void> { return null; },
|
||||
getConfigurationData() { return null; }
|
||||
});
|
||||
|
||||
@@ -774,4 +805,4 @@ suite('TelemetryService', () => {
|
||||
|
||||
service.dispose();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user