Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)

* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463

* fix config changes

* fix strictnull checks
This commit is contained in:
Anthony Dresser
2019-09-15 22:38:26 -07:00
committed by GitHub
parent fa6c52699e
commit ea0f9e6ce9
1226 changed files with 21541 additions and 17633 deletions

View File

@@ -12,6 +12,7 @@ export interface ITelemetryInfo {
sessionId: string;
machineId: string;
instanceId: string;
msftInternal?: boolean;
}
export interface ITelemetryData {
@@ -22,7 +23,7 @@ export interface ITelemetryData {
export interface ITelemetryService {
_serviceBrand: any;
_serviceBrand: undefined;
/**
* Sends a telemetry event that has been privacy approved.
@@ -43,4 +44,4 @@ export interface ITelemetryService {
export const instanceStorageKey = 'telemetry.instanceId';
export const currentSessionDateStorageKey = 'telemetry.currentSessionDate';
export const firstSessionDateStorageKey = 'telemetry.firstSessionDate';
export const lastSessionDateStorageKey = 'telemetry.lastSessionDate';
export const lastSessionDateStorageKey = 'telemetry.lastSessionDate';

View File

@@ -27,7 +27,7 @@ export class TelemetryService implements ITelemetryService {
static IDLE_START_EVENT_NAME = 'UserIdleStart';
static IDLE_STOP_EVENT_NAME = 'UserIdleStop';
_serviceBrand: any;
_serviceBrand: undefined;
private _appender: ITelemetryAppender;
private _commonProperties: Promise<{ [name: string]: any; }>;
@@ -104,8 +104,9 @@ export class TelemetryService implements ITelemetryService {
let sessionId = values['sessionID'];
let instanceId = values['common.instanceId'];
let machineId = values['common.machineId'];
let msftInternal = values['common.msftInternal'];
return { sessionId, instanceId, machineId };
return { sessionId, instanceId, machineId, msftInternal };
}
dispose(): void {

View File

@@ -5,7 +5,6 @@
import { IDisposable } from 'vs/base/common/lifecycle';
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';
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
@@ -81,118 +80,6 @@ export interface URIDescriptor {
path?: string;
}
/**
* Only add settings that cannot contain any personal/private information of users (PII).
*/
const configurationValueWhitelist = [
'editor.fontFamily',
'editor.fontWeight',
'editor.fontSize',
'editor.lineHeight',
'editor.letterSpacing',
'editor.lineNumbers',
'editor.rulers',
'editor.wordSeparators',
'editor.tabSize',
'editor.indentSize',
'editor.insertSpaces',
'editor.detectIndentation',
'editor.roundedSelection',
'editor.scrollBeyondLastLine',
'editor.minimap.enabled',
'editor.minimap.side',
'editor.minimap.renderCharacters',
'editor.minimap.maxColumn',
'editor.find.seedSearchStringFromSelection',
'editor.find.autoFindInSelection',
'editor.wordWrap',
'editor.wordWrapColumn',
'editor.wrappingIndent',
'editor.mouseWheelScrollSensitivity',
'editor.multiCursorModifier',
'editor.quickSuggestions',
'editor.quickSuggestionsDelay',
'editor.parameterHints.enabled',
'editor.parameterHints.cycle',
'editor.autoClosingBrackets',
'editor.autoClosingQuotes',
'editor.autoSurround',
'editor.autoIndent',
'editor.formatOnType',
'editor.formatOnPaste',
'editor.suggestOnTriggerCharacters',
'editor.acceptSuggestionOnEnter',
'editor.acceptSuggestionOnCommitCharacter',
'editor.snippetSuggestions',
'editor.emptySelectionClipboard',
'editor.wordBasedSuggestions',
'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',
'editor.hideCursorInOverviewRuler',
'editor.renderWhitespace',
'editor.renderControlCharacters',
'editor.renderIndentGuides',
'editor.renderLineHighlight',
'editor.codeLens',
'editor.folding',
'editor.showFoldingControls',
'editor.matchBrackets',
'editor.glyphMargin',
'editor.useTabStops',
'editor.trimAutoWhitespace',
'editor.stablePeek',
'editor.dragAndDrop',
'editor.formatOnSave',
'editor.colorDecorators',
'breadcrumbs.enabled',
'breadcrumbs.filePath',
'breadcrumbs.symbolPath',
'breadcrumbs.symbolSortOrder',
'breadcrumbs.useQuickPick',
'explorer.openEditors.visible',
'extensions.autoUpdate',
'files.associations',
'files.autoGuessEncoding',
'files.autoSave',
'files.autoSaveDelay',
'files.encoding',
'files.eol',
'files.hotExit',
'files.trimTrailingWhitespace',
'git.confirmSync',
'git.enabled',
'http.proxyStrictSSL',
'javascript.validate.enable',
'php.builtInCompletions.enable',
'php.validate.enable',
'php.validate.run',
'terminal.integrated.fontFamily',
'window.openFilesInNewWindow',
'window.restoreWindows',
'window.nativeFullScreen',
'window.zoomLevel',
'workbench.editor.enablePreview',
'workbench.editor.enablePreviewFromQuickOpen',
'workbench.editor.showTabs',
'workbench.editor.highlightModifiedTabs',
'workbench.sideBar.location',
'workbench.startupEditor',
'workbench.statusBar.visible',
'workbench.welcome.enabled',
];
export function configurationTelemetry(telemetryService: ITelemetryService, configurationService: IConfigurationService): IDisposable {
return configurationService.onDidChangeConfiguration(event => {
if (event.source !== ConfigurationTarget.DEFAULT) {
@@ -208,44 +95,10 @@ export function configurationTelemetry(telemetryService: ITelemetryService, conf
configurationSource: ConfigurationTargetToString(event.source),
configurationKeys: flattenKeys(event.sourceConfig)
});
type UpdateConfigurationValuesClassification = {
configurationSource: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
configurationValues: { classification: 'CustomerContent', purpose: 'FeatureInsight' };
};
type UpdateConfigurationValuesEvent = {
configurationSource: string;
configurationValues: { [key: string]: any }[];
};
telemetryService.publicLog2<UpdateConfigurationValuesEvent, UpdateConfigurationValuesClassification>('updateConfigurationValues', {
configurationSource: ConfigurationTargetToString(event.source),
configurationValues: flattenValues(event.sourceConfig, configurationValueWhitelist)
});
}
});
}
export function keybindingsTelemetry(telemetryService: ITelemetryService, keybindingService: IKeybindingService): IDisposable {
return keybindingService.onDidUpdateKeybindings(event => {
if (event.source === KeybindingSource.User && event.keybindings) {
type UpdateKeybindingsClassification = {
bindings: { classification: 'CustomerContent', purpose: 'FeatureInsight' };
};
type UpdateKeybindingsEvents = {
bindings: { key: string, command: string, when: string | undefined, args: boolean | undefined }[];
};
telemetryService.publicLog2<UpdateKeybindingsEvents, UpdateKeybindingsClassification>('updateKeybindings', {
bindings: event.keybindings.map(binding => ({
key: binding.key,
command: binding.command,
when: binding.when,
args: binding.args ? true : undefined
}))
});
}
});
}
export interface Properties {
[key: string]: string;
}
@@ -349,18 +202,3 @@ function flatKeys(result: string[], prefix: string, value: { [key: string]: any
result.push(prefix);
}
}
function flattenValues(value: { [key: string]: any } | undefined, keys: string[]): { [key: string]: any }[] {
if (!value) {
return [];
}
return keys.reduce((array, key) => {
const v = key.split('.')
.reduce((tmp, k) => tmp && typeof tmp === 'object' ? tmp[k] : undefined, value);
if (typeof v !== 'undefined') {
array.push({ [key]: v });
}
return array;
}, <{ [key: string]: any }[]>[]);
}

View File

@@ -8,13 +8,11 @@ import * as os from 'os';
import * as uuid from 'vs/base/common/uuid';
import { readFile } from 'vs/base/node/pfs';
// {{SQL CARBON EDIT}}
import product from 'vs/platform/product/node/product';
const productObject = product;
export async function resolveCommonProperties(commit: string | undefined, version: string | undefined, machineId: string | undefined, installSourcePath: string, product?: string): Promise<{ [name: string]: string | undefined; }> {
const result: { [name: string]: string | undefined; } = Object.create(null);
// {{SQL CARBON EDIT}}
import product from 'vs/platform/product/node/product'; // {{SQL CARBON EDIT}}
const productObject = product; // {{SQL CARBON EDIT}}
export async function resolveCommonProperties(commit: string | undefined, version: string | undefined, machineId: string | undefined, msftInternalDomains: string[] | undefined, installSourcePath: string, product?: string): Promise<{ [name: string]: string | boolean | undefined; }> {
const result: { [name: string]: string | boolean | undefined; } = Object.create(null);
// {{SQL CARBON EDIT}} start
if (productObject.quality !== 'stable') {
// __GDPR__COMMON__ "common.machineId" : { "endPoint": "MacAddressHash", "classification": "EndUserPseudonymizedInformation", "purpose": "FeatureInsight" }
result['common.machineId'] = machineId;
@@ -31,8 +29,7 @@ export async function resolveCommonProperties(commit: string | undefined, versio
result['sessionID'] = '';
// __GDPR__COMMON__ "commitHash" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['commitHash'] = '';
}
} // {{SQL CARBON EDIT}} end
// __GDPR__COMMON__ "version" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['version'] = version;
// __GDPR__COMMON__ "common.platformVersion" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
@@ -47,6 +44,12 @@ export async function resolveCommonProperties(commit: string | undefined, versio
result['common.product'] = productObject.nameShort || 'desktop'; // {{SQL CARBON EDIT}}
result['common.application.name'] = productObject.nameLong; // {{SQL CARBON EDIT}}
// const msftInternal = verifyMicrosoftInternalDomain(msftInternalDomains || []); {{SQL CARBON EDIT}} remove msft internal
// if (msftInternal) {
// // __GDPR__COMMON__ "common.msftInternal" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
// result['common.msftInternal'] = msftInternal;
// }
// dynamic properties which value differs on each call
let seq = 0;
const startTime = Date.now();
@@ -84,3 +87,18 @@ export async function resolveCommonProperties(commit: string | undefined, versio
return result;
}
function verifyMicrosoftInternalDomain(domainList: string[]): boolean {
if (!process || !process.env || !process.env['USERDNSDOMAIN']) {
return false;
}
const domain = process.env['USERDNSDOMAIN']!.toLowerCase();
for (let msftDomain of domainList) {
if (domain === msftDomain) {
return true;
}
}
return false;
}

View File

@@ -1,20 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { URI } from 'vs/base/common/uri';
import product from 'vs/platform/product/node/product';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
export async function addGAParameters(telemetryService: ITelemetryService, environmentService: IEnvironmentService, uri: URI, origin: string, experiment = '1'): Promise<URI> {
if (environmentService.isBuilt && !environmentService.isExtensionDevelopment && !environmentService.args['disable-telemetry'] && !!product.enableTelemetry) {
if (uri.scheme === 'https' && uri.authority === 'code.visualstudio.com') {
const info = await telemetryService.getTelemetryInfo();
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 uri;
}

View File

@@ -10,8 +10,8 @@ import { cleanRemoteAuthority } from 'vs/platform/telemetry/common/telemetryUtil
import product from 'vs/platform/product/node/product'; // {{ SQL CARBON EDIT }}
export async function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string | undefined, version: string | undefined, machineId: string, installSourcePath: string, remoteAuthority?: string): Promise<{ [name: string]: string | undefined }> {
const result = await resolveCommonProperties(commit, version, machineId, installSourcePath);
export async function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string | undefined, version: string | undefined, machineId: string, msftInternalDomains: string[] | undefined, installSourcePath: string, remoteAuthority?: string): Promise<{ [name: string]: string | boolean | undefined }> {
const result = await resolveCommonProperties(commit, version, machineId, msftInternalDomains, installSourcePath);
const instanceId = storageService.get(instanceStorageKey, StorageScope.GLOBAL)!;
const firstSessionDate = storageService.get(firstSessionDateStorageKey, StorageScope.GLOBAL)!;
const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.GLOBAL)!;

View File

@@ -24,7 +24,7 @@ class AppInsightsMock implements ITelemetryClient {
}
class TestableLogService extends AbstractLogService implements ILogService {
_serviceBrand: any;
_serviceBrand: undefined;
public logs: string[] = [];

View File

@@ -31,7 +31,7 @@ suite('Telemetry - common properties', function () {
test.skip('default', async function () { // {{SQL CARBON EDIT}} skip test
await mkdirp(parentDir);
fs.writeFileSync(installSource, 'my.install.source');
const props = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', installSource);
const props = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', undefined, installSource);
assert.ok('commitHash' in props);
assert.ok('sessionID' in props);
assert.ok('timestamp' in props);
@@ -52,7 +52,7 @@ suite('Telemetry - common properties', function () {
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);
const props_1 = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', undefined, installSource);
assert.ok(!('common.source' in props_1));
});
@@ -60,14 +60,14 @@ suite('Telemetry - common properties', function () {
testStorageService.store('telemetry.lastSessionDate', new Date().toUTCString(), StorageScope.GLOBAL);
const props = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', installSource);
const props = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', undefined, installSource);
assert.ok('common.lastSessionDate' in props); // conditional, see below
assert.ok('common.isNewSession' in props);
assert.equal(props['common.isNewSession'], 0);
});
test.skip('values chance on ask', async function () { // {{SQL CARBON EDIT}} skip test
const props = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', installSource);
const props = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', undefined, installSource);
let value1 = props['common.sequence'];
let value2 = props['common.sequence'];
assert.ok(value1 !== value2, 'seq');

View File

@@ -730,29 +730,29 @@ suite('TelemetryService', () => {
let service = new TelemetryService({
appender: testAppender
}, {
_serviceBrand: undefined,
getValue() {
return {
enableTelemetry: enableTelemetry
} as any;
},
updateValue(): Promise<void> {
return null!;
},
inspect(key: string) {
return {
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(): Promise<void> { return null!; },
getConfigurationData() { return null; }
});
_serviceBrand: undefined,
getValue() {
return {
enableTelemetry: enableTelemetry
} as any;
},
updateValue(): Promise<void> {
return null!;
},
inspect(key: string) {
return {
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(): Promise<void> { return null!; },
getConfigurationData() { return null; }
});
assert.equal(service.isOptedIn, false);