Refresh master with initial release/0.24 snapshot (#332)

* Initial port of release/0.24 source code

* Fix additional headers

* Fix a typo in launch.json
This commit is contained in:
Karl Burtram
2017-12-15 15:38:57 -08:00
committed by GitHub
parent 271b3a0b82
commit 6ad0df0e3e
7118 changed files with 107999 additions and 56466 deletions

View File

@@ -143,6 +143,17 @@ export default class ErrorTelemetry {
private _flushBuffer(): void {
for (let error of this._buffer) {
/* __GDPR__
"UnhandledError" : {
"message" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" },
"name": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" },
"stack": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" },
"id": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" },
"line": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" },
"column": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
}
*/
// __GDPR__TODO__ what's the complete set of properties?
this._telemetryService.publicLog('UnhandledError', error);
}
this._buffer.length = 0;

View File

@@ -24,7 +24,7 @@ export class IdleMonitor extends Disposable {
private _onStatusChange: Emitter<UserStatus>;
get onStatusChange(): Event<UserStatus> { return this._onStatusChange.event; }
constructor(idleTime) {
constructor(idleTime: number) {
super();
this._status = null;

View File

@@ -8,8 +8,12 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { IStorageService } from 'vs/platform/storage/common/storage';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
/* __GDPR__FRAGMENT__
"IExperiments" : {
"deployToAzureQuickLink" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
export interface IExperiments {
deployToAzureQuickLink: boolean;
}
export const IExperimentService = createDecorator<IExperimentService>('experimentService');
@@ -25,7 +29,7 @@ export class ExperimentService implements IExperimentService {
_serviceBrand: any;
private experiments: IExperiments;
private experiments: IExperiments = {}; // Shortcut while there are no experiments.
constructor(
@IStorageService private storageService: IStorageService,
@@ -57,12 +61,12 @@ function applyOverrides(experiments: IExperiments, configurationService: IConfig
function splitExperimentsRandomness(storageService: IStorageService): IExperiments {
const random1 = getExperimentsRandomness(storageService);
const [random2, /* showTaskDocumentation */] = splitRandom(random1);
const [/* random3 */, deployToAzureQuickLink] = splitRandom(random2);
const [/* random2 */, /* ripgrepQuickSearch */] = splitRandom(random1);
// const [/* random3 */, /* deployToAzureQuickLink */] = splitRandom(random2);
// const [random4, /* mergeQuickLinks */] = splitRandom(random3);
// const [random5, /* enableWelcomePage */] = splitRandom(random4);
return {
deployToAzureQuickLink
// ripgrepQuickSearch,
};
}
@@ -84,6 +88,5 @@ function splitRandom(random: number): [number, boolean] {
}
function getExperimentsOverrides(configurationService: IConfigurationService): IExperiments {
const config: any = configurationService.getConfiguration('telemetry');
return config && config.experiments || {};
return configurationService.getConfiguration<any>('experiments') || {};
}

View File

@@ -64,7 +64,12 @@ export class TelemetryService implements ITelemetryService {
if (this._configurationService) {
this._updateUserOptIn();
this._configurationService.onDidUpdateConfiguration(this._updateUserOptIn, this, this._disposables);
this._configurationService.onDidChangeConfiguration(this._updateUserOptIn, this, this._disposables);
/* __GDPR__
"optInStatus" : {
"optIn" : { "classification": "SystemMetaData", "purpose": "BusinessInsight" }
}
*/
this.publicLog('optInStatus', { optIn: this._userOptIn });
}
}

View File

@@ -9,7 +9,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
import { guessMimeTypes } from 'vs/base/common/mime';
import paths = require('vs/base/common/paths');
import URI from 'vs/base/common/uri';
import { ConfigurationSource, IConfigurationService } from 'vs/platform/configuration/common/configuration';
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';
@@ -39,42 +39,22 @@ export function combinedAppender(...appenders: ITelemetryAppender[]): ITelemetry
export const NullAppender: ITelemetryAppender = { log: () => null };
// --- util
export function anonymize(input: string): string {
if (!input) {
return input;
/* __GDPR__FRAGMENT__
"URIDescriptor" : {
"mimeType" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"ext": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"path": { "classification": "CustomerContent", "purpose": "FeatureInsight" }
}
let r = '';
for (let i = 0; i < input.length; i++) {
let ch = input[i];
if (ch >= '0' && ch <= '9') {
r += '0';
continue;
}
if (ch >= 'a' && ch <= 'z') {
r += 'a';
continue;
}
if (ch >= 'A' && ch <= 'Z') {
r += 'A';
continue;
}
r += ch;
}
return r;
}
*/
export interface URIDescriptor {
mimeType?: string;
ext?: string;
path?: string;
}
export function telemetryURIDescriptor(uri: URI): URIDescriptor {
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: anonymize(fsPath) } : {};
return fsPath ? { mimeType: guessMimeTypes(fsPath).join(', '), ext: paths.extname(fsPath), path: hashPath(fsPath) } : {};
}
/**
@@ -178,14 +158,26 @@ const configurationValueWhitelist = [
];
export function configurationTelemetry(telemetryService: ITelemetryService, configurationService: IConfigurationService): IDisposable {
return configurationService.onDidUpdateConfiguration(event => {
if (event.source !== ConfigurationSource.Default) {
return configurationService.onDidChangeConfiguration(event => {
if (event.source !== ConfigurationTarget.DEFAULT) {
/* __GDPR__
"updateConfiguration" : {
"configurationSource" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"configurationKeys": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
telemetryService.publicLog('updateConfiguration', {
configurationSource: ConfigurationSource[event.source],
configurationSource: ConfigurationTarget[event.source],
configurationKeys: flattenKeys(event.sourceConfig)
});
/* __GDPR__
"updateConfigurationValues" : {
"configurationSource" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"configurationValues": { "classification": "CustomerContent", "purpose": "FeatureInsight" }
}
*/
telemetryService.publicLog('updateConfigurationValues', {
configurationSource: ConfigurationSource[event.source],
configurationSource: ConfigurationTarget[event.source],
configurationValues: flattenValues(event.sourceConfig, configurationValueWhitelist)
});
}
@@ -194,6 +186,11 @@ 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] });
});
}
@@ -201,6 +198,11 @@ export function lifecycleTelemetry(telemetryService: ITelemetryService, lifecycl
export function keybindingsTelemetry(telemetryService: ITelemetryService, keybindingService: IKeybindingService): IDisposable {
return keybindingService.onDidUpdateKeybindings(event => {
if (event.source === KeybindingSource.User && event.keybindings) {
/* __GDPR__
"updateKeybindings" : {
"bindings": { "classification": "CustomerContent", "purpose": "FeatureInsight" }
}
*/
telemetryService.publicLog('updateKeybindings', {
bindings: event.keybindings.map(binding => ({
key: binding.key,

View File

@@ -77,7 +77,7 @@ export class AppInsightsAppender implements ITelemetryAppender {
for (let prop in flat) {
// enforce property names less than 150 char, take the last 150 char
prop = prop.length > 150 ? prop.substr(prop.length - 149) : prop;
var value = flat[prop];
const value = flat[prop];
if (typeof value === 'number') {
measurements[prop] = value;
@@ -105,7 +105,7 @@ export class AppInsightsAppender implements ITelemetryAppender {
return;
}
for (var item of Object.getOwnPropertyNames(obj)) {
for (let item of Object.getOwnPropertyNames(obj)) {
const value = obj[item];
const index = prefix ? prefix + item : item;

View File

@@ -14,16 +14,25 @@ import product from 'vs/platform/node/product';
export const machineIdStorageKey = 'telemetry.machineId';
export const machineIdIpcChannel = 'vscode:machineId';
export function resolveCommonProperties(commit: string, version: string): TPromise<{ [name: string]: string; }> {
export function resolveCommonProperties(commit: string, version: string, source: string): TPromise<{ [name: string]: string; }> {
const result: { [name: string]: string; } = Object.create(null);
// __GDPR__COMMON__ "sessionID" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['sessionID'] = uuid.generateUuid() + Date.now();
// __GDPR__COMMON__ "commitHash" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['commitHash'] = commit;
// __GDPR__COMMON__ "version" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['version'] = version;
// __GDPR__COMMON__ "common.osVersion" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.osVersion'] = os.release();
// __GDPR__COMMON__ "common.platform" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.platform'] = Platform.Platform[Platform.platform];
// __GDPR__COMMON__ "common.nodePlatform" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
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;
@@ -32,14 +41,17 @@ export function resolveCommonProperties(commit: string, version: string): TPromi
let seq = 0;
const startTime = Date.now();
Object.defineProperties(result, {
// __GDPR__COMMON__ "timestamp" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
'timestamp': {
get: () => new Date(),
enumerable: true
},
// __GDPR__COMMON__ "common.timesincesessionstart" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
'common.timesincesessionstart': {
get: () => Date.now() - startTime,
enumerable: true
},
// __GDPR__COMMON__ "common.sequence" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
'common.sequence': {
get: () => seq++,
enumerable: true

View File

@@ -0,0 +1,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 { TPromise } from 'vs/base/common/winjs.base';
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> {
if (environmentService.isBuilt && !environmentService.isExtensionDevelopment && !environmentService.args['disable-telemetry'] && !!product.enableTelemetry) {
if (uri.scheme === 'https' && uri.authority === 'code.visualstudio.com') {
return telemetryService.getTelemetryInfo()
.then(info => {
return uri.with({ query: `${uri.query ? uri.query + '&' : ''}utm_source=VsCode&utm_medium=${encodeURIComponent(origin)}&utm_campaign=${encodeURIComponent(info.instanceId)}&utm_content=${encodeURIComponent(experiment)}` });
});
}
}
return TPromise.as(uri);
}

View File

@@ -3,10 +3,8 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as winreg from 'winreg';
import * as os from 'os';
import { TPromise } from 'vs/base/common/winjs.base';
import * as errors from 'vs/base/common/errors';
import * as uuid from 'vs/base/common/uuid';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { getMachineId } from 'vs/base/node/id';
@@ -16,12 +14,13 @@ import { resolveCommonProperties, machineIdStorageKey } from '../node/commonProp
import product from 'vs/platform/node/product';
import * as Utils from 'sql/common/telemetryUtilities';
const SQM_KEY: string = '\\Software\\Microsoft\\SQMClient';
export function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string, version: string): TPromise<{ [name: string]: string }> {
return resolveCommonProperties(commit, version).then(result => {
export function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string, version: string, source: string): TPromise<{ [name: string]: string }> {
return resolveCommonProperties(commit, version, source).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" }
result['common.version.renderer'] = process.versions && (<any>process).versions['chrome'];
// __GDPR__COMMON__ "common.osVersion" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.osVersion'] = os.release();
// {{SQL CARBON EDIT}}
@@ -33,19 +32,19 @@ export function resolveWorkbenchCommonProperties(storageService: IStorageService
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 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));
if (process.platform === 'win32') {
promises.push(getSqmUserId(storageService).then(value => result['common.sqm.userid'] = value));
promises.push(getSqmMachineId(storageService).then(value => result['common.sqm.machineid'] = value));
}
return TPromise.join(promises).then(() => result);
});
}
@@ -68,61 +67,6 @@ export function getOrCreateMachineId(storageService: IStorageService): TPromise<
return result;
});
}
function getSqmUserId(storageService: IStorageService): TPromise<string> {
const sqmUserId = storageService.get('telemetry.sqm.userId');
if (sqmUserId) {
return TPromise.as(sqmUserId);
}
return getWinRegKeyData(SQM_KEY, 'UserId', winreg.HKCU).then(result => {
if (result) {
storageService.store('telemetry.sqm.userId', result);
return result;
}
return undefined;
});
}
function getSqmMachineId(storageService: IStorageService): TPromise<string> {
let sqmMachineId = storageService.get('telemetry.sqm.machineId');
if (sqmMachineId) {
return TPromise.as(sqmMachineId);
}
return getWinRegKeyData(SQM_KEY, 'MachineId', winreg.HKLM).then(result => {
if (result) {
storageService.store('telemetry.sqm.machineId', result);
return result;
}
return undefined;
});
}
function getWinRegKeyData(key: string, name: string, hive: string): TPromise<string> {
return new TPromise<string>((resolve, reject) => {
if (process.platform === 'win32') {
try {
const reg = new winreg({ hive, key });
reg.get(name, (e, result) => {
if (e || !result) {
reject(null);
} else {
resolve(result.value);
}
});
} catch (err) {
errors.onUnexpectedError(err);
reject(err);
}
} else {
resolve(null);
}
}).then(undefined, err => {
// we only want success
return undefined;
});
}
// {{SQL CARBON EDIT}}
// Get the unique ID for the current user
function getUserId(storageService: IStorageService): Promise<string> {

View File

@@ -14,6 +14,7 @@ suite('Telemetry - common properties', function () {
const commit = void 0;
const version = void 0;
const source = void 0;
let storageService;
setup(() => {
@@ -22,7 +23,7 @@ suite('Telemetry - common properties', function () {
test('default', function () {
return resolveWorkbenchCommonProperties(storageService, commit, version).then(props => {
return resolveWorkbenchCommonProperties(storageService, commit, version, source).then(props => {
assert.ok('commitHash' in props);
assert.ok('sessionID' in props);
@@ -37,6 +38,7 @@ suite('Telemetry - common properties', function () {
// 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);
// {{SQL CARBON EDIT}}
assert.ok('common.application.name' in props);
@@ -48,10 +50,6 @@ suite('Telemetry - common properties', function () {
// machine id et al
assert.ok('common.instanceId' in props, 'instanceId');
assert.ok('common.machineId' in props, 'machineId');
if (process.platform === 'win32') { // SQM only on windows
assert.ok('common.sqm.userid' in props, 'userid');
assert.ok('common.sqm.machineid' in props, 'machineid');
}
});
});
@@ -60,7 +58,7 @@ suite('Telemetry - common properties', function () {
storageService.store('telemetry.lastSessionDate', new Date().toUTCString());
return resolveWorkbenchCommonProperties(storageService, commit, version).then(props => {
return resolveWorkbenchCommonProperties(storageService, commit, version, source).then(props => {
assert.ok('common.lastSessionDate' in props); // conditional, see below
assert.ok('common.isNewSession' in props);
@@ -69,7 +67,7 @@ suite('Telemetry - common properties', function () {
});
test('values chance on ask', function () {
return resolveWorkbenchCommonProperties(storageService, commit, version).then(props => {
return resolveWorkbenchCommonProperties(storageService, commit, version, source).then(props => {
let value1 = props['common.sequence'];
let value2 = props['common.sequence'];
assert.ok(value1 !== value2, 'seq');

View File

@@ -681,24 +681,25 @@ suite('TelemetryService', () => {
enableTelemetry: enableTelemetry
} as any;
},
getConfigurationData(): any {
getValue(key) {
return getConfigurationValue(this.getConfiguration(), key);
},
updateValue() {
return null;
},
reloadConfiguration() {
return TPromise.as(this.getConfiguration());
},
lookup(key: string) {
inspect(key: string) {
return {
value: getConfigurationValue(this.getConfiguration(), key),
default: getConfigurationValue(this.getConfiguration(), key),
user: getConfigurationValue(this.getConfiguration(), key),
workspace: null,
folder: null
workspaceFolder: null
};
},
keys() { return { default: [], user: [], workspace: [], folder: [] }; },
values() { return {}; },
onDidUpdateConfiguration: emitter.event
keys() { return { default: [], user: [], workspace: [], workspaceFolder: [] }; },
onDidChangeConfiguration: emitter.event,
reloadConfiguration() { return null; },
getConfigurationData() { return null; }
});
assert.equal(service.isOptedIn, false);