mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 19:48:37 -05:00
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:
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
23
src/vs/platform/telemetry/node/telemetryNodeUtils.ts
Normal file
23
src/vs/platform/telemetry/node/telemetryNodeUtils.ts
Normal 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);
|
||||
}
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user