mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode e0762af258c0b20320ed03f3871a41967acc4421 (#7404)
* Merge from vscode e0762af258c0b20320ed03f3871a41967acc4421 * readd svgs
This commit is contained in:
@@ -7,10 +7,20 @@ import * as Platform from 'vs/base/common/platform';
|
||||
import * as os from 'os';
|
||||
import * as uuid from 'vs/base/common/uuid';
|
||||
import { readFile } from 'vs/base/node/pfs';
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
|
||||
import product from 'vs/platform/product/common/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; }> {
|
||||
|
||||
export async function resolveCommonProperties(
|
||||
commit: string | undefined,
|
||||
version: string | undefined,
|
||||
machineId: string | undefined,
|
||||
msftInternalDomains: string[] | undefined,
|
||||
installSourcePath: string,
|
||||
product?: string,
|
||||
resolveAdditionalProperties?: () => { [key: string]: any }
|
||||
): Promise<{ [name: string]: string | boolean | undefined; }> {
|
||||
const result: { [name: string]: string | boolean | undefined; } = Object.create(null);
|
||||
// {{SQL CARBON EDIT}} start
|
||||
if (productObject.quality !== 'stable') {
|
||||
@@ -85,6 +95,10 @@ export async function resolveCommonProperties(commit: string | undefined, versio
|
||||
// ignore error
|
||||
}
|
||||
|
||||
if (resolveAdditionalProperties) {
|
||||
mixin(result, resolveAdditionalProperties());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,17 @@ import { cleanRemoteAuthority } from 'vs/platform/telemetry/common/telemetryUtil
|
||||
|
||||
import product from 'vs/platform/product/common/product'; // {{ SQL CARBON EDIT }}
|
||||
|
||||
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);
|
||||
export async function resolveWorkbenchCommonProperties(
|
||||
storageService: IStorageService,
|
||||
commit: string | undefined,
|
||||
version: string | undefined,
|
||||
machineId: string,
|
||||
msftInternalDomains: string[] | undefined,
|
||||
installSourcePath: string,
|
||||
remoteAuthority?: string,
|
||||
resolveAdditionalProperties?: () => { [key: string]: any }
|
||||
): Promise<{ [name: string]: string | boolean | undefined }> {
|
||||
const result = await resolveCommonProperties(commit, version, machineId, msftInternalDomains, installSourcePath, undefined, resolveAdditionalProperties);
|
||||
const instanceId = storageService.get(instanceStorageKey, StorageScope.GLOBAL)!;
|
||||
const firstSessionDate = storageService.get(firstSessionDateStorageKey, StorageScope.GLOBAL)!;
|
||||
const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.GLOBAL)!;
|
||||
|
||||
@@ -81,4 +81,52 @@ suite('Telemetry - common properties', function () {
|
||||
value2 = props['common.timesincesessionstart'];
|
||||
assert.ok(value1 !== value2, 'timesincesessionstart');
|
||||
});
|
||||
|
||||
test('mixes in additional properties', async function () {
|
||||
const resolveCommonTelemetryProperties = () => {
|
||||
return {
|
||||
'userId': '1'
|
||||
};
|
||||
};
|
||||
|
||||
const props = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', undefined, installSource, undefined, resolveCommonTelemetryProperties);
|
||||
|
||||
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.platformVersion' in props, 'platformVersion');
|
||||
assert.ok('version' in props);
|
||||
assert.ok('common.firstSessionDate' in props, 'firstSessionDate');
|
||||
assert.ok('common.lastSessionDate' in props, 'lastSessionDate');
|
||||
assert.ok('common.isNewSession' in props, 'isNewSession');
|
||||
assert.ok('common.instanceId' in props, 'instanceId');
|
||||
assert.ok('common.machineId' in props, 'machineId');
|
||||
|
||||
assert.equal(props['userId'], '1');
|
||||
});
|
||||
|
||||
test('mixes in additional dyanmic properties', async function () {
|
||||
let i = 1;
|
||||
const resolveCommonTelemetryProperties = () => {
|
||||
return Object.defineProperties({}, {
|
||||
'userId': {
|
||||
get: () => {
|
||||
return i++;
|
||||
},
|
||||
enumerable: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const props = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', undefined, installSource, undefined, resolveCommonTelemetryProperties);
|
||||
assert.equal(props['userId'], '1');
|
||||
|
||||
const props2 = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', undefined, installSource, undefined, resolveCommonTelemetryProperties);
|
||||
assert.equal(props2['userId'], '2');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user