Skip to content

Commit 5eac27c

Browse files
authored
report single event (microsoft#202705)
1 parent 3695bca commit 5eac27c

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

src/vs/workbench/services/configuration/browser/configurationService.ts

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { ConfigurationModel, ConfigurationChangeEvent, mergeChanges } from 'vs/p
1515
import { IConfigurationChangeEvent, ConfigurationTarget, IConfigurationOverrides, isConfigurationOverrides, IConfigurationData, IConfigurationValue, IConfigurationChange, ConfigurationTargetToString, IConfigurationUpdateOverrides, isConfigurationUpdateOverrides, IConfigurationService, IConfigurationUpdateOptions } from 'vs/platform/configuration/common/configuration';
1616
import { IPolicyConfiguration, NullPolicyConfiguration, PolicyConfiguration } from 'vs/platform/configuration/common/configurations';
1717
import { Configuration } from 'vs/workbench/services/configuration/common/configurationModels';
18-
import { FOLDER_CONFIG_FOLDER_NAME, defaultSettingsSchemaId, userSettingsSchemaId, workspaceSettingsSchemaId, folderSettingsSchemaId, IConfigurationCache, machineSettingsSchemaId, LOCAL_MACHINE_SCOPES, IWorkbenchConfigurationService, RestrictedSettings, PROFILE_SCOPES, LOCAL_MACHINE_PROFILE_SCOPES, profileSettingsSchemaId, APPLY_ALL_PROFILES_SETTING } from 'vs/workbench/services/configuration/common/configuration';
18+
import { FOLDER_CONFIG_FOLDER_NAME, defaultSettingsSchemaId, userSettingsSchemaId, workspaceSettingsSchemaId, folderSettingsSchemaId, IConfigurationCache, machineSettingsSchemaId, LOCAL_MACHINE_SCOPES, IWorkbenchConfigurationService, RestrictedSettings, PROFILE_SCOPES, LOCAL_MACHINE_PROFILE_SCOPES, profileSettingsSchemaId, APPLY_ALL_PROFILES_SETTING, TASKS_CONFIGURATION_KEY, LAUNCH_CONFIGURATION_KEY } from 'vs/workbench/services/configuration/common/configuration';
1919
import { Registry } from 'vs/platform/registry/common/platform';
2020
import { IConfigurationRegistry, Extensions, allSettings, windowSettings, resourceSettings, applicationSettings, machineSettings, machineOverridableSettings, ConfigurationScope, IConfigurationPropertySchema, keyFromOverrideIdentifiers, OVERRIDE_PROPERTY_PATTERN, resourceLanguageSettingsSchemaId, configurationDefaultsSchemaId } from 'vs/platform/configuration/common/configurationRegistry';
2121
import { IStoredWorkspaceFolder, isStoredWorkspaceFolder, IWorkspaceFolderCreationData, getStoredWorkspaceFolder, toWorkspaceFolders } from 'vs/platform/workspaces/common/workspaces';
@@ -1331,39 +1331,37 @@ class ConfigurationTelemetryContribution extends Disposable implements IWorkbenc
13311331

13321332
constructor(
13331333
@IConfigurationService private readonly configurationService: WorkspaceService,
1334-
@ITelemetryService private readonly telemetryService: ITelemetryService,
1334+
@ITelemetryService telemetryService: ITelemetryService,
13351335
) {
13361336
super();
1337-
13381337
const { user, workspace } = configurationService.keys();
1339-
for (const key of user) {
1340-
this.reportConfiguration(key, ConfigurationTarget.USER_LOCAL);
1338+
const updatedUserSettings: { [key: string]: any } = {};
1339+
for (const k of user) {
1340+
if (!k.startsWith(`${TASKS_CONFIGURATION_KEY}.`) && !k.startsWith(`${LAUNCH_CONFIGURATION_KEY}.`)) {
1341+
updatedUserSettings[k] = this.getValueToReport(k, ConfigurationTarget.USER_LOCAL) ?? '';
1342+
}
13411343
}
1342-
for (const key of workspace) {
1343-
this.reportConfiguration(key, ConfigurationTarget.WORKSPACE);
1344+
const updatedWorkspaceSettings: { [key: string]: any } = {};
1345+
for (const k of workspace) {
1346+
if (!k.startsWith(`${TASKS_CONFIGURATION_KEY}.`) && !k.startsWith(`${LAUNCH_CONFIGURATION_KEY}.`)) {
1347+
updatedWorkspaceSettings[k] = this.getValueToReport(k, ConfigurationTarget.WORKSPACE) ?? '';
1348+
}
13441349
}
1345-
}
1346-
1347-
private reportConfiguration(key: string, target: ConfigurationTarget): void {
1348-
type UpdateConfigurationClassification = {
1350+
type UpdatedSettingsClassification = {
13491351
owner: 'sandy081';
1350-
comment: 'Event which fires for updated configurations';
1351-
source: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'What configuration file was updated i.e user or workspace' };
1352-
key: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'What configuration key was updated' };
1353-
value?: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Value of the key that was updated' };
1352+
comment: 'Event reporting updated settings';
1353+
settings: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'stringified updated settings object' };
13541354
};
1355-
type UpdateConfigurationEvent = {
1356-
source: string;
1357-
key: string;
1358-
value?: any;
1355+
type UpdatedSettingsEvent = {
1356+
settings: string;
13591357
};
1360-
this.telemetryService.publicLog2<UpdateConfigurationEvent, UpdateConfigurationClassification>('updateConfiguration', {
1361-
source: ConfigurationTargetToString(target),
1362-
key,
1363-
value: this.getValueToReport(key, target)
1364-
});
1358+
telemetryService.publicLog2<UpdatedSettingsEvent, UpdatedSettingsClassification>('updatedsettings:user', { settings: JSON.stringify(updatedUserSettings) });
1359+
telemetryService.publicLog2<UpdatedSettingsEvent, UpdatedSettingsClassification>('updatedsettings:workspace', { settings: JSON.stringify(updatedWorkspaceSettings) });
13651360
}
13661361

1362+
/**
1363+
* Report value of a setting only if it is an enum, boolean, or number or an array of those.
1364+
*/
13671365
private getValueToReport(key: string, target: ConfigurationTarget): any {
13681366
const schema = this.configurationRegistry.getConfigurationProperties()[key];
13691367
if (!schema) {

0 commit comments

Comments
 (0)