mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)
* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 * fix pipelines * fix strict-null-checks * add missing files
This commit is contained in:
@@ -13,8 +13,16 @@ export const lastSessionDateStorageKey = 'telemetry.lastSessionDate';
|
||||
import * as Platform from 'vs/base/common/platform';
|
||||
import * as uuid from 'vs/base/common/uuid';
|
||||
import { cleanRemoteAuthority } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
|
||||
export async function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string | undefined, version: string | undefined, machineId: string, remoteAuthority?: string): Promise<{ [name: string]: string | undefined }> {
|
||||
export async function resolveWorkbenchCommonProperties(
|
||||
storageService: IStorageService,
|
||||
commit: string | undefined,
|
||||
version: string | undefined,
|
||||
machineId: string,
|
||||
remoteAuthority?: string,
|
||||
resolveAdditionalProperties?: () => { [key: string]: any }
|
||||
): Promise<{ [name: string]: string | undefined }> {
|
||||
const result: { [name: string]: string | undefined; } = Object.create(null);
|
||||
const firstSessionDate = storageService.get(firstSessionDateStorageKey, StorageScope.GLOBAL)!;
|
||||
const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.GLOBAL)!;
|
||||
@@ -68,6 +76,10 @@ export async function resolveWorkbenchCommonProperties(storageService: IStorageS
|
||||
}
|
||||
});
|
||||
|
||||
if (resolveAdditionalProperties) {
|
||||
mixin(result, resolveAdditionalProperties());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ export interface ITelemetryServiceConfig {
|
||||
|
||||
export class TelemetryService implements ITelemetryService {
|
||||
|
||||
static IDLE_START_EVENT_NAME = 'UserIdleStart';
|
||||
static IDLE_STOP_EVENT_NAME = 'UserIdleStop';
|
||||
static readonly IDLE_START_EVENT_NAME = 'UserIdleStart';
|
||||
static readonly IDLE_STOP_EVENT_NAME = 'UserIdleStop';
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ export const NullTelemetryService = new class implements ITelemetryService {
|
||||
return this.publicLog(eventName, data as ITelemetryData);
|
||||
}
|
||||
setEnabled() { }
|
||||
isOptedIn: true;
|
||||
isOptedIn = true;
|
||||
getTelemetryInfo(): Promise<ITelemetryInfo> {
|
||||
return Promise.resolve({
|
||||
instanceId: 'someValue.instanceId',
|
||||
|
||||
@@ -7,7 +7,6 @@ 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}}
|
||||
@@ -18,8 +17,7 @@ export async function resolveCommonProperties(
|
||||
machineId: string | undefined,
|
||||
msftInternalDomains: string[] | undefined,
|
||||
installSourcePath: string,
|
||||
product?: string,
|
||||
resolveAdditionalProperties?: () => { [key: string]: any }
|
||||
product?: string
|
||||
): Promise<{ [name: string]: string | boolean | undefined; }> {
|
||||
const result: { [name: string]: string | boolean | undefined; } = Object.create(null);
|
||||
// {{SQL CARBON EDIT}} start
|
||||
@@ -54,9 +52,9 @@ export async function resolveCommonProperties(
|
||||
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
|
||||
// const msftInternal = verifyMicrosoftInternalDomain(msftInternalDomains || []); {{SQL CARBON EDIT}} remove msftinternal
|
||||
// if (msftInternal) {
|
||||
// // __GDPR__COMMON__ "common.msftInternal" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
// // __GDPR__COMMON__ "common.msftInternal" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
|
||||
// result['common.msftInternal'] = msftInternal;
|
||||
// }
|
||||
|
||||
@@ -95,24 +93,14 @@ export async function resolveCommonProperties(
|
||||
// ignore error
|
||||
}
|
||||
|
||||
if (resolveAdditionalProperties) {
|
||||
mixin(result, resolveAdditionalProperties());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function verifyMicrosoftInternalDomain(domainList: string[]): boolean {
|
||||
function verifyMicrosoftInternalDomain(domainList: readonly 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;
|
||||
return domainList.some(msftDomain => domain === msftDomain);
|
||||
}
|
||||
|
||||
@@ -17,10 +17,9 @@ export async function resolveWorkbenchCommonProperties(
|
||||
machineId: string,
|
||||
msftInternalDomains: string[] | undefined,
|
||||
installSourcePath: string,
|
||||
remoteAuthority?: string,
|
||||
resolveAdditionalProperties?: () => { [key: string]: any }
|
||||
remoteAuthority?: string
|
||||
): Promise<{ [name: string]: string | boolean | undefined }> {
|
||||
const result = await resolveCommonProperties(commit, version, machineId, msftInternalDomains, installSourcePath, undefined, resolveAdditionalProperties);
|
||||
const result = await resolveCommonProperties(commit, version, machineId, msftInternalDomains, installSourcePath, undefined);
|
||||
const instanceId = storageService.get(instanceStorageKey, StorageScope.GLOBAL)!;
|
||||
const firstSessionDate = storageService.get(firstSessionDateStorageKey, StorageScope.GLOBAL)!;
|
||||
const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.GLOBAL)!;
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { resolveWorkbenchCommonProperties } from 'vs/platform/telemetry/browser/workbenchCommonProperties';
|
||||
import { IStorageService, InMemoryStorageService } from 'vs/platform/storage/common/storage';
|
||||
|
||||
suite('Browser Telemetry - common properties', function () {
|
||||
|
||||
const commit: string = (undefined)!;
|
||||
const version: string = (undefined)!;
|
||||
let testStorageService: IStorageService;
|
||||
|
||||
setup(() => {
|
||||
testStorageService = new InMemoryStorageService();
|
||||
});
|
||||
|
||||
test('mixes in additional properties', async function () {
|
||||
const resolveCommonTelemetryProperties = () => {
|
||||
return {
|
||||
'userId': '1'
|
||||
};
|
||||
};
|
||||
|
||||
const props = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', 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.timesincesessionstart' in props);
|
||||
assert.ok('common.sequence' in props);
|
||||
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.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, resolveCommonTelemetryProperties);
|
||||
assert.equal(props['userId'], '1');
|
||||
|
||||
const props2 = await resolveWorkbenchCommonProperties(testStorageService, commit, version, 'someMachineId', undefined, resolveCommonTelemetryProperties);
|
||||
assert.equal(props2['userId'], '2');
|
||||
});
|
||||
});
|
||||
@@ -81,52 +81,4 @@ suite('Telemetry - common properties', function () {
|
||||
value2 = props['common.timesincesessionstart'];
|
||||
assert.ok(value1 !== value2, 'timesincesessionstart');
|
||||
});
|
||||
|
||||
test.skip('mixes in additional properties', async function () { // {{SQL CARBON EDIT}} skip test
|
||||
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