Initial VS Code 1.19 source merge (#571)

* Initial 1.19 xcopy

* Fix yarn build

* Fix numerous build breaks

* Next batch of build break fixes

* More build break fixes

* Runtime breaks

* Additional post merge fixes

* Fix windows setup file

* Fix test failures.

* Update license header blocks to refer to source eula
This commit is contained in:
Karl Burtram
2018-01-28 23:37:17 -08:00
committed by GitHub
parent 9a1ac20710
commit 251ae01c3e
8009 changed files with 93378 additions and 35634 deletions

View File

@@ -1,78 +0,0 @@
/*---------------------------------------------------------------------------------------------
* 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 { TimeoutTimer } from 'vs/base/common/async';
import Event, { Emitter } from 'vs/base/common/event';
import { Disposable } from 'vs/base/common/lifecycle';
import * as dom from 'vs/base/browser/dom';
export enum UserStatus {
Idle,
Active
}
export class IdleMonitor extends Disposable {
private _lastActiveTime: number;
private _idleCheckTimeout: TimeoutTimer;
private _status: UserStatus;
private _idleTime: number;
private _onStatusChange: Emitter<UserStatus>;
get onStatusChange(): Event<UserStatus> { return this._onStatusChange.event; }
constructor(idleTime: number) {
super();
this._status = null;
this._idleCheckTimeout = this._register(new TimeoutTimer());
this._lastActiveTime = -1;
this._idleTime = idleTime;
this._onStatusChange = new Emitter<UserStatus>();
this._register(dom.addDisposableListener(document, 'mousemove', () => this._onUserActive()));
this._register(dom.addDisposableListener(document, 'keydown', () => this._onUserActive()));
this._onUserActive();
}
get status(): UserStatus {
return this._status;
}
private _onUserActive(): void {
this._lastActiveTime = (new Date()).getTime();
if (this._status !== UserStatus.Active) {
this._status = UserStatus.Active;
this._scheduleIdleCheck();
this._onStatusChange.fire(this._status);
}
}
private _onUserIdle(): void {
if (this._status !== UserStatus.Idle) {
this._status = UserStatus.Idle;
this._onStatusChange.fire(this._status);
}
}
private _scheduleIdleCheck(): void {
const minimumTimeWhenUserCanBecomeIdle = this._lastActiveTime + this._idleTime;
const timeout = minimumTimeWhenUserCanBecomeIdle - (new Date()).getTime();
this._idleCheckTimeout.setIfNotSet(() => this._checkIfUserIsIdle(), timeout);
}
private _checkIfUserIsIdle(): void {
const actualIdleTime = (new Date()).getTime() - this._lastActiveTime;
if (actualIdleTime >= this._idleTime) {
this._onUserIdle();
} else {
this._scheduleIdleCheck();
}
}
}

View File

@@ -7,6 +7,7 @@
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { deepClone } from 'vs/base/common/objects';
/* __GDPR__FRAGMENT__
"IExperiments" : {
@@ -88,5 +89,5 @@ function splitRandom(random: number): [number, boolean] {
}
function getExperimentsOverrides(configurationService: IConfigurationService): IExperiments {
return configurationService.getConfiguration<any>('experiments') || {};
return deepClone(configurationService.getValue<any>('experiments')) || {};
}

View File

@@ -34,7 +34,10 @@ export class TelemetryAppenderClient implements ITelemetryAppender {
constructor(private channel: ITelemetryAppenderChannel) { }
log(eventName: string, data?: any): any {
return this.channel.call('log', { eventName, data });
this.channel.call('log', { eventName, data })
.done(null, err => `Failed to log telemetry: ${console.warn(err)}`);
return TPromise.as(null);
}
dispose(): any {

View File

@@ -75,7 +75,7 @@ export class TelemetryService implements ITelemetryService {
}
private _updateUserOptIn(): void {
const config = this._configurationService.getConfiguration<any>(TELEMETRY_SECTION_ID);
const config = this._configurationService.getValue<any>(TELEMETRY_SECTION_ID);
this._userOptIn = config ? config.enableTelemetry : this._userOptIn;
}

View File

@@ -11,17 +11,16 @@ import paths = require('vs/base/common/paths');
import URI from 'vs/base/common/uri';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { IKeybindingService, KeybindingSource } from 'vs/platform/keybinding/common/keybinding';
import { ILifecycleService, ShutdownReason } from 'vs/platform/lifecycle/common/lifecycle';
import { ITelemetryService, ITelemetryInfo, ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
export const NullTelemetryService = {
_serviceBrand: undefined,
export const NullTelemetryService = new class implements ITelemetryService {
_serviceBrand: undefined;
publicLog(eventName: string, data?: ITelemetryData) {
return TPromise.as<void>(null);
},
isOptedIn: true,
return TPromise.wrap<void>(null);
}
isOptedIn: true;
getTelemetryInfo(): TPromise<ITelemetryInfo> {
return TPromise.as({
return TPromise.wrap({
instanceId: 'someValue.instanceId',
sessionId: 'someValue.sessionId',
machineId: 'someValue.machineId'
@@ -184,17 +183,6 @@ export function configurationTelemetry(telemetryService: ITelemetryService, conf
});
}
export function lifecycleTelemetry(telemetryService: ITelemetryService, lifecycleService: ILifecycleService): IDisposable {
return lifecycleService.onShutdown(event => {
/* __GDPR__
"shutdown" : {
"reason" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
telemetryService.publicLog('shutdown', { reason: ShutdownReason[event] });
});
}
export function keybindingsTelemetry(telemetryService: ITelemetryService, keybindingService: IKeybindingService): IDisposable {
return keybindingService.onDidUpdateKeybindings(event => {
if (event.source === KeybindingSource.User && event.keybindings) {

View File

@@ -7,16 +7,15 @@ 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 const machineIdStorageKey = 'telemetry.machineId';
export const machineIdIpcChannel = 'vscode:machineId';
export function resolveCommonProperties(commit: string, version: string, source: string): TPromise<{ [name: string]: string; }> {
export function resolveCommonProperties(commit: string, version: string, machineId: string, installSourcePath: string): TPromise<{ [name: string]: string; }> {
const result: { [name: string]: string; } = Object.create(null);
// __GDPR__COMMON__ "common.machineId" : { "classification": "EndUserPseudonymizedInformation", "purpose": "FeatureInsight" }
result['common.machineId'] = machineId;
// __GDPR__COMMON__ "sessionID" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['sessionID'] = uuid.generateUuid() + Date.now();
// __GDPR__COMMON__ "commitHash" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
@@ -31,9 +30,7 @@ export function resolveCommonProperties(commit: string, version: string, source:
result['common.nodePlatform'] = process.platform;
// __GDPR__COMMON__ "common.nodeArch" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.nodeArch'] = process.arch;
// __GDPR__COMMON__ "common.source" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.source'] = source;
// {{SQL CARBON EDIT}}
result['common.application.name'] = product.nameLong;
@@ -58,5 +55,13 @@ export function resolveCommonProperties(commit: string, version: string, source:
}
});
return TPromise.as(result);
return readFile(installSourcePath, 'utf8').then(contents => {
// __GDPR__COMMON__ "common.source" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.source'] = contents.slice(0, 30);
return result;
}, error => {
return result;
});
}

View File

@@ -7,15 +7,14 @@ import * as os from 'os';
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 { getMachineId } from 'vs/base/node/id';
import { resolveCommonProperties, machineIdStorageKey } from '../node/commonProperties';
import { resolveCommonProperties } from '../node/commonProperties';
// {{ 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, source: string): TPromise<{ [name: string]: string }> {
return resolveCommonProperties(commit, version, source).then(result => {
export function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string, version: string, machineId: string, installSourcePath: string): TPromise<{ [name: string]: string }> {
return resolveCommonProperties(commit, version, machineId, installSourcePath).then(result => {
// __GDPR__COMMON__ "common.version.shell" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.version.shell'] = process.versions && (<any>process).versions['electron'];
// __GDPR__COMMON__ "common.version.renderer" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
@@ -38,35 +37,19 @@ export function resolveWorkbenchCommonProperties(storageService: IStorageService
result['common.lastSessionDate'] = lastSessionDate;
// __GDPR__COMMON__ "common.isNewSession" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.isNewSession'] = !lastSessionDate ? '1' : '0';
const promises: TPromise<any>[] = [];
// __GDPR__COMMON__ "common.instanceId" : { "classification": "EndUserPseudonymizedInformation", "purpose": "FeatureInsight" }
promises.push(getOrCreateInstanceId(storageService).then(value => result['common.instanceId'] = value));
// __GDPR__COMMON__ "common.machineId" : { "classification": "EndUserPseudonymizedInformation", "purpose": "FeatureInsight" }
promises.push(getOrCreateMachineId(storageService).then(value => result['common.machineId'] = value));
result['common.instanceId'] = getOrCreateInstanceId(storageService);
return TPromise.join(promises).then(() => result);
});
}
function getOrCreateInstanceId(storageService: IStorageService): TPromise<string> {
let result = storageService.get('telemetry.instanceId') || uuid.generateUuid();
storageService.store('telemetry.instanceId', result);
return TPromise.as(result);
}
export function getOrCreateMachineId(storageService: IStorageService): TPromise<string> {
let result = storageService.get(machineIdStorageKey);
if (result) {
return TPromise.as(result);
}
return getMachineId().then(result => {
storageService.store(machineIdStorageKey, result);
return result;
});
}
function getOrCreateInstanceId(storageService: IStorageService): string {
const result = storageService.get('telemetry.instanceId') || uuid.generateUuid();
storageService.store('telemetry.instanceId', result);
return result;
}
// {{SQL CARBON EDIT}}
// Get the unique ID for the current user
function getUserId(storageService: IStorageService): Promise<string> {

View File

@@ -9,8 +9,8 @@ import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppen
interface IAppInsightsEvent {
eventName: string;
properties?: { string?: string; };
measurements?: { string?: number; };
properties?: { [x: string]: string; };
measurements?: { [x: string]: number; };
}
class AppInsightsMock {
@@ -34,7 +34,7 @@ class AppInsightsMock {
this.exceptions.push(exception);
}
public sendPendingData(callback): void {
public sendPendingData(_callback: any): void {
// called on dispose
}
}
@@ -74,18 +74,18 @@ suite('AIAdapter', () => {
test('property limits', () => {
var reallyLongPropertyName = 'abcdefghijklmnopqrstuvwxyz';
for (var i = 0; i < 6; i++) {
for (let i = 0; i < 6; i++) {
reallyLongPropertyName += 'abcdefghijklmnopqrstuvwxyz';
}
assert(reallyLongPropertyName.length > 150);
var reallyLongPropertyValue = 'abcdefghijklmnopqrstuvwxyz012345678901234567890123';
for (var i = 0; i < 21; i++) {
for (let i = 0; i < 21; i++) {
reallyLongPropertyValue += 'abcdefghijklmnopqrstuvwxyz012345678901234567890123';
}
assert(reallyLongPropertyValue.length > 1024);
var data = {};
var data = Object.create(null);
data[reallyLongPropertyName] = '1234';
data['reallyLongPropertyValue'] = reallyLongPropertyValue;
adapter.log('testEvent', data);

View File

@@ -5,40 +5,52 @@
'use strict';
import * as assert from 'assert';
import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs';
import { TPromise } from 'vs/base/common/winjs.base';
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 { del } from 'vs/base/node/extfs';
import { mkdirp } from 'vs/base/node/pfs';
suite('Telemetry - common properties', function () {
const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'telemetryservice');
const installSource = path.join(parentDir, 'installSource');
const commit = void 0;
const version = void 0;
const source = void 0;
let storageService;
const commit: string = void 0;
const version: string = void 0;
let storageService: StorageService;
setup(() => {
storageService = new StorageService(new InMemoryLocalStorage(), null, TestWorkspace.id);
});
teardown(done => {
del(parentDir, os.tmpdir(), done);
});
test('default', function () {
return mkdirp(parentDir).then(() => {
fs.writeFileSync(installSource, 'my.install.source');
return resolveWorkbenchCommonProperties(storageService, commit, version, source).then(props => {
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('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('version' in props);
assert.ok('common.source' 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('version' in props);
assert.equal(props['common.source'], 'my.install.source');
// {{SQL CARBON EDIT}}
assert.ok('common.application.name' in props);
@@ -47,10 +59,16 @@ suite('Telemetry - common properties', function () {
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');
// 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));
});
});
});
});
@@ -58,7 +76,7 @@ suite('Telemetry - common properties', function () {
storageService.store('telemetry.lastSessionDate', new Date().toUTCString());
return resolveWorkbenchCommonProperties(storageService, commit, version, source).then(props => {
return resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource).then(props => {
assert.ok('common.lastSessionDate' in props); // conditional, see below
assert.ok('common.isNewSession' in props);
@@ -67,7 +85,7 @@ suite('Telemetry - common properties', function () {
});
test('values chance on ask', function () {
return resolveWorkbenchCommonProperties(storageService, commit, version, source).then(props => {
return resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource).then(props => {
let value1 = props['common.sequence'];
let value2 = props['common.sequence'];
assert.ok(value1 !== value2, 'seq');

View File

@@ -40,16 +40,16 @@ class TestTelemetryAppender implements ITelemetryAppender {
}
class ErrorTestingSettings {
public personalInfo;
public importantInfo;
public filePrefix;
public dangerousPathWithoutImportantInfo;
public dangerousPathWithImportantInfo;
public missingModelPrefix;
public missingModelMessage;
public noSuchFilePrefix;
public noSuchFileMessage;
public stack;
public personalInfo: string;
public importantInfo: string;
public filePrefix: string;
public dangerousPathWithoutImportantInfo: string;
public dangerousPathWithImportantInfo: string;
public missingModelPrefix: string;
public missingModelMessage: string;
public noSuchFilePrefix: string;
public noSuchFileMessage: string;
public stack: string[];
constructor() {
this.personalInfo = 'DANGEROUS/PATH';
@@ -203,7 +203,7 @@ suite('TelemetryService', () => {
});
}));
test('Error events', sinon.test(function () {
test('Error events', sinon.test(function (this: any) {
let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });
@@ -262,7 +262,7 @@ suite('TelemetryService', () => {
// }
// }));
test('Handle global errors', sinon.test(function () {
test('Handle global errors', sinon.test(function (this: any) {
let errorStub = sinon.stub();
window.onerror = errorStub;
@@ -289,7 +289,7 @@ suite('TelemetryService', () => {
service.dispose();
}));
test('Uncaught Error Telemetry removes PII from filename', sinon.test(function () {
test('Uncaught Error Telemetry removes PII from filename', sinon.test(function (this: any) {
let errorStub = sinon.stub();
window.onerror = errorStub;
let settings = new ErrorTestingSettings();
@@ -318,7 +318,7 @@ suite('TelemetryService', () => {
service.dispose();
}));
test('Unexpected Error Telemetry removes PII', sinon.test(function () {
test('Unexpected Error Telemetry removes PII', sinon.test(function (this: any) {
let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });
try {
@@ -348,7 +348,7 @@ suite('TelemetryService', () => {
}
}));
test('Uncaught Error Telemetry removes PII', sinon.test(function () {
test('Uncaught Error Telemetry removes PII', sinon.test(function (this: any) {
let errorStub = sinon.stub();
window.onerror = errorStub;
let settings = new ErrorTestingSettings();
@@ -374,7 +374,7 @@ suite('TelemetryService', () => {
service.dispose();
}));
test('Unexpected Error Telemetry removes PII but preserves Code file path', sinon.test(function () {
test('Unexpected Error Telemetry removes PII but preserves Code file path', sinon.test(function (this: any) {
let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });
@@ -409,7 +409,7 @@ suite('TelemetryService', () => {
}
}));
test('Uncaught Error Telemetry removes PII but preserves Code file path', sinon.test(function () {
test('Uncaught Error Telemetry removes PII but preserves Code file path', sinon.test(function (this: any) {
let errorStub = sinon.stub();
window.onerror = errorStub;
let settings = new ErrorTestingSettings();
@@ -437,7 +437,7 @@ suite('TelemetryService', () => {
service.dispose();
}));
test('Unexpected Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinon.test(function () {
test('Unexpected Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinon.test(function (this: any) {
let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });
@@ -472,7 +472,7 @@ suite('TelemetryService', () => {
}
}));
test('Uncaught Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinon.test(function () {
test('Uncaught Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinon.test(function (this: any) {
let errorStub = sinon.stub();
window.onerror = errorStub;
let settings = new ErrorTestingSettings();
@@ -500,7 +500,7 @@ suite('TelemetryService', () => {
service.dispose();
}));
test('Unexpected Error Telemetry removes PII but preserves Missing Model error message', sinon.test(function () {
test('Unexpected Error Telemetry removes PII but preserves Missing Model error message', sinon.test(function (this: any) {
let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });
@@ -535,7 +535,7 @@ suite('TelemetryService', () => {
}
}));
test('Uncaught Error Telemetry removes PII but preserves Missing Model error message', sinon.test(function () {
test('Uncaught Error Telemetry removes PII but preserves Missing Model error message', sinon.test(function (this: any) {
let errorStub = sinon.stub();
window.onerror = errorStub;
let settings = new ErrorTestingSettings();
@@ -564,7 +564,7 @@ suite('TelemetryService', () => {
service.dispose();
}));
test('Unexpected Error Telemetry removes PII but preserves No Such File error message', sinon.test(function () {
test('Unexpected Error Telemetry removes PII but preserves No Such File error message', sinon.test(function (this: any) {
let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });
@@ -599,7 +599,7 @@ suite('TelemetryService', () => {
}
}));
test('Uncaught Error Telemetry removes PII but preserves No Such File error message', sinon.test(function () {
test('Uncaught Error Telemetry removes PII but preserves No Such File error message', sinon.test(function (this: any) {
let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });
@@ -676,29 +676,26 @@ suite('TelemetryService', () => {
appender: testAppender
}, {
_serviceBrand: undefined,
getConfiguration() {
getValue() {
return {
enableTelemetry: enableTelemetry
} as any;
},
getValue(key) {
return getConfigurationValue(this.getConfiguration(), key);
},
updateValue() {
updateValue(): TPromise<void> {
return null;
},
inspect(key: string) {
return {
value: getConfigurationValue(this.getConfiguration(), key),
default: getConfigurationValue(this.getConfiguration(), key),
user: getConfigurationValue(this.getConfiguration(), key),
value: getConfigurationValue(this.getValue(), key),
default: getConfigurationValue(this.getValue(), key),
user: getConfigurationValue(this.getValue(), key),
workspace: null,
workspaceFolder: null
};
},
keys() { return { default: [], user: [], workspace: [], workspaceFolder: [] }; },
onDidChangeConfiguration: emitter.event,
reloadConfiguration() { return null; },
reloadConfiguration(): TPromise<void> { return null; },
getConfigurationData() { return null; }
});