Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report telemetry only for opted in settings #202844

Merged
merged 1 commit into from
Jan 19, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/vs/workbench/browser/workbench.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
localize('workbench.activityBar.location.side', "Show the Activity Bar to the side of the Primary Side Bar."),
localize('workbench.activityBar.location.top', "Show the Activity Bar on top of the Primary Side Bar."),
localize('workbench.activityBar.location.hide', "Hide the Activity Bar.")
]
],
tags: ['FeatureInsight']
},
'workbench.activityBar.iconClickBehavior': {
'type': 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
description: localize('extensions.autoUpdate', "Controls the automatic update behavior of extensions. The updates are fetched from a Microsoft online service."),
default: true,
scope: ConfigurationScope.APPLICATION,
tags: ['usesOnlineServices']
tags: ['usesOnlineServices', 'FeatureInsight']
},
'extensions.autoCheckUpdates': {
type: 'boolean',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { ConfigurationModel, ConfigurationChangeEvent, mergeChanges } from 'vs/p
import { IConfigurationChangeEvent, ConfigurationTarget, IConfigurationOverrides, isConfigurationOverrides, IConfigurationData, IConfigurationValue, IConfigurationChange, ConfigurationTargetToString, IConfigurationUpdateOverrides, isConfigurationUpdateOverrides, IConfigurationService, IConfigurationUpdateOptions } from 'vs/platform/configuration/common/configuration';
import { IPolicyConfiguration, NullPolicyConfiguration, PolicyConfiguration } from 'vs/platform/configuration/common/configurations';
import { Configuration } from 'vs/workbench/services/configuration/common/configurationModels';
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';
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';
import { Registry } from 'vs/platform/registry/common/platform';
import { IConfigurationRegistry, Extensions, allSettings, windowSettings, resourceSettings, applicationSettings, machineSettings, machineOverridableSettings, ConfigurationScope, IConfigurationPropertySchema, keyFromOverrideIdentifiers, OVERRIDE_PROPERTY_PATTERN, resourceLanguageSettingsSchemaId, configurationDefaultsSchemaId } from 'vs/platform/configuration/common/configurationRegistry';
import { IConfigurationRegistry, Extensions, allSettings, windowSettings, resourceSettings, applicationSettings, machineSettings, machineOverridableSettings, ConfigurationScope, IConfigurationPropertySchema, keyFromOverrideIdentifiers, OVERRIDE_PROPERTY_PATTERN, resourceLanguageSettingsSchemaId, configurationDefaultsSchemaId, IRegisteredConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry';
import { IStoredWorkspaceFolder, isStoredWorkspaceFolder, IWorkspaceFolderCreationData, getStoredWorkspaceFolder, toWorkspaceFolders } from 'vs/platform/workspaces/common/workspaces';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ConfigurationEditing, EditableConfigurationTarget } from 'vs/workbench/services/configuration/common/configurationEditing';
Expand Down Expand Up @@ -1325,48 +1325,49 @@ class ResetConfigurationDefaultsOverridesCache extends Disposable implements IWo
}
}

class ConfigurationTelemetryContribution extends Disposable implements IWorkbenchContribution {
class ConfigurationTelemetryContribution implements IWorkbenchContribution {

private readonly configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);

constructor(
@IConfigurationService private readonly configurationService: WorkspaceService,
@ITelemetryService telemetryService: ITelemetryService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
) {
super();
type UpdatedSettingClassification = {
owner: 'sandy081';
comment: 'Event reporting the updated setting';
setting: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'name of the setting' };
value: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'value of the setting' };
source: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'source of the setting' };
};
type UpdatedSettingEvent = {
setting: string;
value: string;
source: string;
};
const { user, workspace } = configurationService.keys();
const updatedUserSettings: { [key: string]: any } = {};
for (const k of user) {
if (!k.startsWith(`${TASKS_CONFIGURATION_KEY}.`) && !k.startsWith(`${LAUNCH_CONFIGURATION_KEY}.`)) {
updatedUserSettings[k] = this.getValueToReport(k, ConfigurationTarget.USER_LOCAL) ?? '';
const userSource = ConfigurationTargetToString(ConfigurationTarget.USER_LOCAL);
for (const setting of user) {
const schema = this.configurationRegistry.getConfigurationProperties()[setting];
if (schema.tags?.includes('FeatureInsight')) {
const value = this.getValueToReport(setting, ConfigurationTarget.USER_LOCAL, schema);
this.telemetryService.publicLog2<UpdatedSettingEvent, UpdatedSettingClassification>('updatedsetting', { setting, value, source: userSource });
}
}
const updatedWorkspaceSettings: { [key: string]: any } = {};
for (const k of workspace) {
if (!k.startsWith(`${TASKS_CONFIGURATION_KEY}.`) && !k.startsWith(`${LAUNCH_CONFIGURATION_KEY}.`)) {
updatedWorkspaceSettings[k] = this.getValueToReport(k, ConfigurationTarget.WORKSPACE) ?? '';
const worskpaceSource = ConfigurationTargetToString(ConfigurationTarget.WORKSPACE);
for (const setting of workspace) {
const schema = this.configurationRegistry.getConfigurationProperties()[setting];
if (schema.tags?.includes('FeatureInsight')) {
const value = this.getValueToReport(setting, ConfigurationTarget.WORKSPACE, schema);
this.telemetryService.publicLog2<UpdatedSettingEvent, UpdatedSettingClassification>('updatedsetting', { setting, value, source: worskpaceSource });
}
}
type UpdatedSettingsClassification = {
owner: 'sandy081';
comment: 'Event reporting updated settings';
settings: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'stringified updated settings object' };
};
type UpdatedSettingsEvent = {
settings: string;
};
telemetryService.publicLog2<UpdatedSettingsEvent, UpdatedSettingsClassification>('updatedsettings:user', { settings: JSON.stringify(updatedUserSettings) });
telemetryService.publicLog2<UpdatedSettingsEvent, UpdatedSettingsClassification>('updatedsettings:workspace', { settings: JSON.stringify(updatedWorkspaceSettings) });
}

/**
* Report value of a setting only if it is an enum, boolean, or number or an array of those.
*/
private getValueToReport(key: string, target: ConfigurationTarget): any {
const schema = this.configurationRegistry.getConfigurationProperties()[key];
if (!schema) {
return undefined;
}
private getValueToReport(key: string, target: ConfigurationTarget, schema: IRegisteredConfigurationPropertySchema): any {
const configurationModel = this.configurationService.getConfigurationModel(target);
const value = configurationModel?.getValue(key);
if (isNumber(value) || isBoolean(value)) {
Expand Down