Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslint-plugin-local/code-no-telemetry-common-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const commonTelemetryProperties = new Set([
'common.useragent',
'common.istouchdevice',
'common.copilottrackingid',
'common.isagentswindow',
]);

export default new class NoTelemetryCommonProperty implements eslint.Rule.RuleModule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class TelemetryService extends Disposable implements ITelemetryService {
appenders.push(new TelemetryLogAppender('', false, loggerService, environmentService, productService));
const config: ITelemetryServiceConfig = {
appenders,
commonProperties: resolveWorkbenchCommonProperties(storageService, productService, isInternal, environmentService.remoteAuthority, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
commonProperties: resolveWorkbenchCommonProperties(storageService, productService, environmentService, isInternal, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
// Use the web origin as a cleanup pattern (analogous to appRoot on desktop).
// This strips the origin from web URLs in stack traces so the useful
// relative path (e.g. /static/build/bundle.js:1:200953) is preserved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { mixin } from '../../../../base/common/objects.js';
import { ICommonProperties, firstSessionDateStorageKey, lastSessionDateStorageKey, machineIdKey } from '../../../../platform/telemetry/common/telemetry.js';
import { Gesture } from '../../../../base/browser/touch.js';
import { IProductService } from '../../../../platform/product/common/productService.js';
import { IWorkbenchEnvironmentService } from '../../environment/common/environmentService.js';

/**
* General function to help reduce the individuality of user agents
Expand All @@ -24,9 +25,9 @@ function cleanUserAgent(userAgent: string): string {
export function resolveWorkbenchCommonProperties(
storageService: IStorageService,
productService: IProductService,
environmentService: IWorkbenchEnvironmentService,
isInternalTelemetry: boolean,
remoteAuthority?: string,
resolveAdditionalProperties?: () => { [key: string]: unknown }
resolveAdditionalProperties?: () => { [key: string]: unknown },
): ICommonProperties {
const { commit, version, embedderIdentifier: productIdentifier, removeTelemetryMachineId: removeMachineId } = productService ?? {};
const result: ICommonProperties = Object.create(null);
Expand Down Expand Up @@ -56,7 +57,7 @@ export function resolveWorkbenchCommonProperties(
// __GDPR__COMMON__ "common.isNewSession" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.isNewSession'] = !lastSessionDate ? '1' : '0';
// __GDPR__COMMON__ "common.remoteAuthority" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
result['common.remoteAuthority'] = cleanRemoteAuthority(remoteAuthority, productService);
result['common.remoteAuthority'] = cleanRemoteAuthority(environmentService.remoteAuthority, productService);

// __GDPR__COMMON__ "common.machineId" : { "endPoint": "MacAddressHash", "classification": "EndUserPseudonymizedInformation", "purpose": "FeatureInsight" }
result['common.machineId'] = machineId;
Expand Down Expand Up @@ -105,6 +106,11 @@ export function resolveWorkbenchCommonProperties(
mixin(result, resolveAdditionalProperties());
}

if (environmentService.isSessionsWindow) {
// __GDPR__COMMON__ "common.isAgentsWindow" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.isAgentsWindow'] = true;
}

return result;
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ import { ICommonProperties, firstSessionDateStorageKey, lastSessionDateStorageKe
import { cleanRemoteAuthority } from '../../../../platform/telemetry/common/telemetryUtils.js';
import { INodeProcess } from '../../../../base/common/platform.js';
import { IProductService } from '../../../../platform/product/common/productService.js';
import { IWorkbenchEnvironmentService } from '../../environment/common/environmentService.js';

export function resolveWorkbenchCommonProperties(
storageService: IStorageService,
productService: IProductService,
environmentService: IWorkbenchEnvironmentService,
release: string,
hostname: string,
machineId: string,
sqmId: string,
devDeviceId: string,
isInternalTelemetry: boolean,
process: INodeProcess,
remoteAuthority?: string,
telemetryAppName?: string,
): ICommonProperties {
const { commit, version, date: releaseDate } = productService ?? {};
const result = resolveCommonProperties(release, hostname, process.arch, commit, version, machineId, sqmId, devDeviceId, isInternalTelemetry, releaseDate, telemetryAppName);
const result = resolveCommonProperties(release, hostname, process.arch, commit, version, machineId, sqmId, devDeviceId, isInternalTelemetry, releaseDate);
const firstSessionDate = storageService.get(firstSessionDateStorageKey, StorageScope.APPLICATION)!;
const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.APPLICATION)!;

Expand All @@ -39,9 +39,14 @@ export function resolveWorkbenchCommonProperties(
// __GDPR__COMMON__ "common.isNewSession" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.isNewSession'] = !lastSessionDate ? '1' : '0';
// __GDPR__COMMON__ "common.remoteAuthority" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
result['common.remoteAuthority'] = cleanRemoteAuthority(remoteAuthority, productService);
result['common.remoteAuthority'] = cleanRemoteAuthority(environmentService.remoteAuthority, productService);
// __GDPR__COMMON__ "common.cli" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.cli'] = !!process.env['VSCODE_CLI'];

if (environmentService.isSessionsWindow) {
// __GDPR__COMMON__ "common.isAgentsWindow" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.isAgentsWindow'] = true;
}

return result;
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@ export class TelemetryService extends Disposable implements ITelemetryService {
commonProperties: resolveWorkbenchCommonProperties(
storageService,
productService,
environmentService,
environmentService.os.release,
environmentService.os.hostname,
environmentService.machineId,
environmentService.sqmId,
environmentService.devDeviceId,
isInternal,
process,
environmentService.remoteAuthority,
environmentService.isSessionsWindow ? productService.agentsTelemetryAppName : undefined
),
piiPaths: getPiiPathsFromEnvironment(environmentService),
sendErrorTelemetry: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { resolveWorkbenchCommonProperties } from '../../browser/workbenchCommonP
import { InMemoryStorageService } from '../../../../../platform/storage/common/storage.js';
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js';
import { hasKey } from '../../../../../base/common/types.js';
import { IWorkbenchEnvironmentService } from '../../../environment/common/environmentService.js';

suite('Browser Telemetry - common properties', function () {
let testStorageService: InMemoryStorageService;
Expand All @@ -28,7 +29,7 @@ suite('Browser Telemetry - common properties', function () {
};
};

const props = resolveWorkbenchCommonProperties(testStorageService, undefined!, false, undefined, resolveCommonTelemetryProperties);
const props = resolveWorkbenchCommonProperties(testStorageService, undefined!, { isSessionsWindow: false } as IWorkbenchEnvironmentService, false, resolveCommonTelemetryProperties);

assert.ok(hasKey(props, {
commitHash: true,
Expand Down Expand Up @@ -59,10 +60,10 @@ suite('Browser Telemetry - common properties', function () {
});
};

const props = resolveWorkbenchCommonProperties(testStorageService, undefined!, false, undefined, resolveCommonTelemetryProperties);
const props = resolveWorkbenchCommonProperties(testStorageService, undefined!, { isSessionsWindow: false } as IWorkbenchEnvironmentService, false, resolveCommonTelemetryProperties);
assert.strictEqual(props['userId'], 1);

const props2 = resolveWorkbenchCommonProperties(testStorageService, undefined!, false, undefined, resolveCommonTelemetryProperties);
const props2 = resolveWorkbenchCommonProperties(testStorageService, undefined!, { isSessionsWindow: false } as IWorkbenchEnvironmentService, false, resolveCommonTelemetryProperties);
assert.strictEqual(props2['userId'], 2);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { StorageScope, InMemoryStorageService, StorageTarget } from '../../../..
import { timeout } from '../../../../../base/common/async.js';
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js';
import { hasKey } from '../../../../../base/common/types.js';
import { IWorkbenchEnvironmentService } from '../../../environment/common/environmentService.js';

suite('Telemetry - common properties', function () {
let testStorageService: InMemoryStorageService;
Expand All @@ -25,7 +26,7 @@ suite('Telemetry - common properties', function () {
});

test('default', function () {
const props = resolveWorkbenchCommonProperties(testStorageService, undefined!, release(), hostname(), 'someMachineId', 'someSqmId', 'somedevDeviceId', false, process);
const props = resolveWorkbenchCommonProperties(testStorageService, undefined!, { isSessionsWindow: false } as IWorkbenchEnvironmentService, release(), hostname(), 'someMachineId', 'someSqmId', 'somedevDeviceId', false, process);
assert.ok(hasKey(props, {
commitHash: true,
sessionID: true,
Expand All @@ -51,14 +52,14 @@ suite('Telemetry - common properties', function () {

testStorageService.store('telemetry.lastSessionDate', new Date().toUTCString(), StorageScope.APPLICATION, StorageTarget.MACHINE);

const props = resolveWorkbenchCommonProperties(testStorageService, undefined!, release(), hostname(), 'someMachineId', 'someSqmId', 'somedevDeviceId', false, process);
const props = resolveWorkbenchCommonProperties(testStorageService, undefined!, { isSessionsWindow: false } as IWorkbenchEnvironmentService, release(), hostname(), 'someMachineId', 'someSqmId', 'somedevDeviceId', false, process);
assert.ok(props['common.lastSessionDate']); // conditional, see below
assert.ok(props['common.isNewSession']);
assert.strictEqual(props['common.isNewSession'], '0');
});

test('values chance on ask', async function () {
const props = resolveWorkbenchCommonProperties(testStorageService, undefined!, release(), hostname(), 'someMachineId', 'someSqmId', 'somedevDeviceId', false, process);
const props = resolveWorkbenchCommonProperties(testStorageService, undefined!, { isSessionsWindow: false } as IWorkbenchEnvironmentService, release(), hostname(), 'someMachineId', 'someSqmId', 'somedevDeviceId', false, process);
let value1 = props['common.sequence'];
let value2 = props['common.sequence'];
assert.ok(value1 !== value2, 'seq');
Expand Down
Loading