Skip to content

Commit

Permalink
Use experimentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AmelBawa-msft committed Jan 23, 2025
1 parent 733f43a commit 70ddb26
Show file tree
Hide file tree
Showing 22 changed files with 93 additions and 93 deletions.
2 changes: 1 addition & 1 deletion doc/admx/DesktopAppInstaller.admx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="EnableExperiments" class="Machine" displayName="$(string.EnableExperiments)" explainText="$(string.EnableExperimentsExplanation)" key="Software\Policies\Microsoft\Windows\AppInstaller" valueName="EnableExperiments">
<policy name="EnableExperimentation" class="Machine" displayName="$(string.EnableExperimentation)" explainText="$(string.EnableExperimentationExplanation)" key="Software\Policies\Microsoft\Windows\AppInstaller" valueName="EnableExperimentation">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<enabledValue>
Expand Down
8 changes: 4 additions & 4 deletions doc/admx/en-US/DesktopAppInstaller.adml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ If you disable this setting, users will not be able to change settings for the W
If you enable or do not configure this setting, users will be able to enable experimental features for the Windows Package Manager.

If you disable this setting, users will not be able to enable experimental features for the Windows Package Manager.</string>
<string id="EnableExperiments">Enable Windows Package Manager Experiments</string>
<string id="EnableExperimentsExplanation">This policy controls whether users can enable experiments in the Windows Package Manager.
<string id="EnableExperimentation">Enable Windows Package Manager Feature Experimentation</string>
<string id="EnableExperimentationExplanation">This policy controls whether a user will be the recipient of feature experimentation while using the Windows Package Manager.

If you enable or do not configure this setting, users will be able to enable experiments for the Windows Package Manager.
If you enable, or do not configure this setting, user may receive experiences intended to analyze features and functionality experiences in the Windows Package Manager.

If you disable this setting, users will not be able to enable experiments for the Windows Package Manager.</string>
If you disable this setting, user will be excluded from receiving any modified experience in the Windows Package Manager.</string>
<string id="EnableLocalManifestFiles">Enable Windows Package Manager Local Manifest Files</string>
<string id="EnableLocalManifestFilesExplanation">This policy controls whether users can install packages with local manifest files.

Expand Down
12 changes: 6 additions & 6 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@
}
}
},
"Experiments": {
"description": "Experiments",
"Experimentation": {
"description": "Feature Experimentation",
"type": "object",
"properties": {
"CDN": {
Expand All @@ -317,8 +317,8 @@
}
}
},
"AllowExperiments": {
"description": "Controls whether experiments are allowed or not",
"AllowExperimentation": {
"description": "Controls whether feature experimentation is allowed or not",
"type": "boolean",
"default": true
}
Expand Down Expand Up @@ -398,13 +398,13 @@
},
{
"properties": {
"experiments": { "$ref": "#/definitions/Experiments" }
"experimentation": { "$ref": "#/definitions/Experimentation" }
},
"additionalItems": true
},
{
"properties": {
"allowExperiments": { "$ref": "#/definitions/AllowExperiments" }
"allowExperimentation": { "$ref": "#/definitions/AllowExperimentation" }
},
"additionalItems": true
}
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw
Original file line number Diff line number Diff line change
Expand Up @@ -897,8 +897,8 @@ They can be configured through the settings file 'winget settings'.</value>
<data name="PolicyEnableExperimentalFeatures" xml:space="preserve">
<value>Enable Windows App Installer Experimental Features</value>
</data>
<data name="PolicyEnableExperiments" xml:space="preserve">
<value>Enable Windows App Installer Experiments</value>
<data name="PolicyEnableExperimentation" xml:space="preserve">
<value>Enable Windows Package Manager Feature Experimentation</value>
</data>
<data name="PolicyEnableMSStoreSource" xml:space="preserve">
<value>Enable Windows App Installer Microsoft Store Source</value>
Expand Down
68 changes: 34 additions & 34 deletions src/AppInstallerCLITests/Experiment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,62 +21,62 @@ TEST_CASE("Experiment_GroupPolicyControl", "[experiment]")
{
SECTION("Not configured")
{
ExperimentsTest experiments;
ExperimentationTest experimentation;
GroupPolicyTestOverride policies;
policies.SetState(TogglePolicy::Policy::Experiments, PolicyState::NotConfigured);
policies.SetState(TogglePolicy::Policy::Experimentation, PolicyState::NotConfigured);
ASSERT_EXPERIMENT(true, ExperimentToggleSource::Default);
}

SECTION("Enabled")
{
ExperimentsTest experiments;
ExperimentationTest experimentation;
GroupPolicyTestOverride policies;
policies.SetState(TogglePolicy::Policy::Experiments, PolicyState::Enabled);
policies.SetState(TogglePolicy::Policy::Experimentation, PolicyState::Enabled);
ASSERT_EXPERIMENT(true, ExperimentToggleSource::Default);
}

SECTION("Disabled")
{
ExperimentsTest experiments;
ExperimentationTest experimentation;
GroupPolicyTestOverride policies;
policies.SetState(TogglePolicy::Policy::Experiments, PolicyState::Disabled);
policies.SetState(TogglePolicy::Policy::Experimentation, PolicyState::Disabled);
ASSERT_EXPERIMENT(false, ExperimentToggleSource::Policy);
}
}

TEST_CASE("Experiment_GroupPolicyDisabled_ReturnFalse", "[experiment]")
{
ExperimentsTest experiments;
ExperimentationTest experimentation;
TestUserSettings settings;
settings.Set<Setting::Experiments>({{s_TestExperimentName, true}});
settings.Set<Setting::Experimentation>({{s_TestExperimentName, true}});

// If the policy is disabled, then also the user settings should be ignored.
GroupPolicyTestOverride policies;
policies.SetState(TogglePolicy::Policy::Experiments, PolicyState::Disabled);
policies.SetState(TogglePolicy::Policy::Experimentation, PolicyState::Disabled);
ASSERT_EXPERIMENT(false, ExperimentToggleSource::Policy);
}

TEST_CASE("Experiment_GroupPolicyEnabled", "[experiment]")
{
SECTION("Global experiments disabled in user settings")
SECTION("Global experimentation disabled in user settings")
{
GroupPolicyTestOverride policies;
policies.SetState(TogglePolicy::Policy::Experiments, PolicyState::Enabled);
ExperimentsTest experiments;
policies.SetState(TogglePolicy::Policy::Experimentation, PolicyState::Enabled);
ExperimentationTest experimentation;
TestUserSettings settings;
settings.Set<Setting::AllowExperiments>(false);
settings.Set<Setting::Experiments>({{s_TestExperimentName, true}});
settings.Set<Setting::AllowExperimentation>(false);
settings.Set<Setting::Experimentation>({{s_TestExperimentName, true}});
ASSERT_EXPERIMENT(false, ExperimentToggleSource::UserSettingGlobalControl);
}

SECTION("Individual experiment disabled in user settings")
{
GroupPolicyTestOverride policies;
policies.SetState(TogglePolicy::Policy::Experiments, PolicyState::Enabled);
ExperimentsTest experiments;
policies.SetState(TogglePolicy::Policy::Experimentation, PolicyState::Enabled);
ExperimentationTest experimentation;
TestUserSettings settings;
settings.Set<Setting::AllowExperiments>(true);
settings.Set<Setting::Experiments>({{s_TestExperimentName, false}});
settings.Set<Setting::AllowExperimentation>(true);
settings.Set<Setting::Experimentation>({{s_TestExperimentName, false}});
ASSERT_EXPERIMENT(false, ExperimentToggleSource::UserSettingIndividualControl);
}
}
Expand All @@ -86,52 +86,52 @@ TEST_CASE("Experiment_UserSettingsIndividualControl", "[experiment]")
SECTION("Individual experiment not configured in user settings")
{
// Default value are used
ExperimentsTest experiments;
ExperimentationTest experimentation;
ASSERT_EXPERIMENT(true, ExperimentToggleSource::Default);
}

SECTION("Individual experiment enabled in user settings")
{
ExperimentsTest experiments;
ExperimentationTest experimentation;
TestUserSettings settings;
settings.Set<Setting::Experiments>({{s_TestExperimentName, true}});
settings.Set<Setting::Experimentation>({{s_TestExperimentName, true}});
ASSERT_EXPERIMENT(true, ExperimentToggleSource::UserSettingIndividualControl);
}

SECTION("Individual experiment disabled in user settings")
{
ExperimentsTest experiments;
ExperimentationTest experimentation;
TestUserSettings settings;
settings.Set<Setting::Experiments>({{s_TestExperimentName, false}});
settings.Set<Setting::Experimentation>({{s_TestExperimentName, false}});
ASSERT_EXPERIMENT(false, ExperimentToggleSource::UserSettingIndividualControl);
}
}

TEST_CASE("Experiment_UserSettingsGlobalControl", "[experiment]")
{
SECTION("Global experiments not configured in user settings")
SECTION("Global experimentation not configured in user settings")
{
ExperimentsTest experiments;
ExperimentationTest experimentation;
TestUserSettings settings;
settings.Set<Setting::Experiments>({{s_TestExperimentName, true}});
settings.Set<Setting::Experimentation>({{s_TestExperimentName, true}});
ASSERT_EXPERIMENT(true, ExperimentToggleSource::UserSettingIndividualControl);
}

SECTION("Global experiments enabled in user settings")
SECTION("Global experimentation enabled in user settings")
{
ExperimentsTest experiments;
ExperimentationTest experimentation;
TestUserSettings settings;
settings.Set<Setting::AllowExperiments>(true);
settings.Set<Setting::Experiments>({{s_TestExperimentName, true}});
settings.Set<Setting::AllowExperimentation>(true);
settings.Set<Setting::Experimentation>({{s_TestExperimentName, true}});
ASSERT_EXPERIMENT(true, ExperimentToggleSource::UserSettingIndividualControl);
}

SECTION("Global experiments disabled in user settings")
SECTION("Global experimentation disabled in user settings")
{
ExperimentsTest experiments;
ExperimentationTest experimentation;
TestUserSettings settings;
settings.Set<Setting::AllowExperiments>(false);
settings.Set<Setting::Experiments>({{s_TestExperimentName, true}});
settings.Set<Setting::AllowExperimentation>(false);
settings.Set<Setting::Experimentation>({{s_TestExperimentName, true}});
ASSERT_EXPERIMENT(false, ExperimentToggleSource::UserSettingGlobalControl);
}
}
2 changes: 1 addition & 1 deletion src/AppInstallerCLITests/GroupPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ TEST_CASE("GroupPolicy_AllEnabled", "[groupPolicy]")
SetRegistryValue(policiesKey.get(), EnableWindowsPackageManagerCommandLineInterfaces, 1);
SetRegistryValue(policiesKey.get(), ConfigurationPolicyValueName, 1);
SetRegistryValue(policiesKey.get(), ProxyCommandLineOptionsPolicyValueName, 1);
SetRegistryValue(policiesKey.get(), EnableExperimentsPolicyValueName , 1);
SetRegistryValue(policiesKey.get(), EnableExperimentationPolicyValueName , 1);

GroupPolicy groupPolicy{ policiesKey.get() };
for (const auto& policy : TogglePolicy::GetAllPolicies())
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLITests/TestSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ namespace TestCommon
m_toggles[policy] = state;
}

ExperimentsTest::~ExperimentsTest()
ExperimentationTest::~ExperimentationTest()
{
AppInstaller::Logging::Telemetry().ResetExperiments();
AppInstaller::Logging::Telemetry().ResetExperimentCache();
}
}
6 changes: 3 additions & 3 deletions src/AppInstallerCLITests/TestSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace TestCommon
const std::wstring EnableWindowsPackageManagerCommandLineInterfaces = L"EnableWindowsPackageManagerCommandLineInterfaces";
const std::wstring ConfigurationPolicyValueName = L"EnableWindowsPackageManagerConfiguration";
const std::wstring ProxyCommandLineOptionsPolicyValueName = L"EnableWindowsPackageManagerProxyCommandLineOptions";
const std::wstring EnableExperimentsPolicyValueName = L"EnableExperiments";
const std::wstring EnableExperimentationPolicyValueName = L"EnableExperimentation";

const std::wstring SourceUpdateIntervalPolicyValueName = L"SourceAutoUpdateInterval";
const std::wstring SourceUpdateIntervalPolicyOldValueName = L"SourceAutoUpdateIntervalInMinutes";
Expand All @@ -49,9 +49,9 @@ namespace TestCommon
{
};

struct ExperimentsTest
struct ExperimentationTest
{
~ExperimentsTest();
~ExperimentationTest();
};

struct GroupPolicyTestOverride : AppInstaller::Settings::GroupPolicy
Expand Down
10 changes: 5 additions & 5 deletions src/AppInstallerCommonCore/AppInstallerTelemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ namespace AppInstaller::Logging
}
}

std::wstring GetExperimentsJson(const Settings:: ExperimentStateCache& experiments)
std::wstring GetExperimentationJson(const Settings:: ExperimentStateCache& experimentation)
{
Json::Value root;
for (const auto& experiment : experiments)
for (const auto& experiment : experimentation)
{
auto name = std::string(Settings::Experiment::GetExperiment(experiment.first).JsonName());
root[name] = experiment.second.ToJson();
Expand Down Expand Up @@ -787,7 +787,7 @@ namespace AppInstaller::Logging
}

#ifndef AICLI_DISABLE_TEST_HOOKS
void TelemetryTraceLogger::ResetExperiments()
void TelemetryTraceLogger::ResetExperimentCache()
{
m_summary.ExperimentCache.clear();
}
Expand All @@ -806,7 +806,7 @@ namespace AppInstaller::Logging

if (m_useSummary)
{
auto experimentsJson = GetExperimentsJson(m_summary.ExperimentCache);
auto experimentationJson = GetExperimentationJson(m_summary.ExperimentCache);

TraceLoggingWriteActivity(
g_hTraceProvider,
Expand Down Expand Up @@ -873,7 +873,7 @@ namespace AppInstaller::Logging
AICLI_TraceLoggingStringView(m_summary.RepairExecutionType, "RepairExecutionType"),
TraceLoggingUInt32(m_summary.RepairErrorCode, "RepairErrorCode"),
TelemetryPrivacyDataTag(PDT_ProductAndServicePerformance | PDT_ProductAndServiceUsage | PDT_SoftwareSetupAndInventory),
AICLI_TraceLoggingJsonWString(experimentsJson, "ExperimentsJson"),
AICLI_TraceLoggingJsonWString(experimentationJson, "ExperimentationJson"),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES));
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/AppInstallerCommonCore/Experiment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ namespace AppInstaller::Settings
}

auto experiment = Experiment::GetExperiment(key);
if (!GroupPolicies().IsEnabled(TogglePolicy::Policy::Experiments))
if (!GroupPolicies().IsEnabled(TogglePolicy::Policy::Experimentation))
{
AICLI_LOG(Core, Verbose, << "Experiment " << experiment.Name() <<
" is disabled due to group policy: " << TogglePolicy::GetPolicy(TogglePolicy::Policy::Experiments).RegValueName());
" is disabled due to group policy: " << TogglePolicy::GetPolicy(TogglePolicy::Policy::Experimentation).RegValueName());
return { false, ExperimentToggleSource::Policy };
}

auto experimentJsonName = experiment.JsonName();
if (!userSettings.Get<Setting::AllowExperiments>())
if (!userSettings.Get<Setting::AllowExperimentation>())
{
AICLI_LOG(Core, Verbose, << "Experiment " << experiment.Name() <<
" is disabled due to experiments not allowed from user settings");
" is disabled due to experimentation not allowed from user settings");
return { false, ExperimentToggleSource::UserSettingGlobalControl };
}

auto userSettingsExperiments = userSettings.Get<Setting::Experiments>();
auto userSettingsExperimentIter = userSettingsExperiments.find(experimentJsonName);
if (userSettingsExperimentIter != userSettingsExperiments.end())
auto userSettingsExperimentation = userSettings.Get<Setting::Experimentation>();
auto userSettingsExperimentIter = userSettingsExperimentation.find(experimentJsonName);
if (userSettingsExperimentIter != userSettingsExperimentation.end())
{
auto isEnabled = userSettingsExperimentIter->second;
AICLI_LOG(Core, Verbose, << "Experiment " << experiment.Name() << " is set to " << (isEnabled ? "true" : "false") << " in user settings");
Expand Down Expand Up @@ -102,7 +102,7 @@ namespace AppInstaller::Settings
}
}

std::vector<Experiment> Experiment::GetAllExperiments()
std::vector<Experiment> Experiment::GetExperimentation()
{
std::vector<Experiment> result;

Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCommonCore/Public/AppInstallerTelemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ namespace AppInstaller::Logging
Settings::ExperimentState GetExperimentState(AppInstaller::Experiment::ExperimentKey key);

#ifndef AICLI_DISABLE_TEST_HOOKS
void ResetExperiments();
void ResetExperimentCache();
#endif

protected:
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCommonCore/Public/winget/Experiment.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace AppInstaller::Settings
static ExperimentState GetState(AppInstaller::Experiment::ExperimentKey feature);
static ExperimentState GetStateInternal(AppInstaller::Experiment::ExperimentKey feature);
static Experiment GetExperiment(AppInstaller::Experiment::ExperimentKey key);
static std::vector<Experiment> GetAllExperiments();
static std::vector<Experiment> GetExperimentation();

const std::string Name() const { return m_name; }
const std::string JsonName() const { return m_jsonName; }
Expand Down
14 changes: 7 additions & 7 deletions src/AppInstallerCommonCore/Public/winget/UserSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ namespace AppInstaller::Settings
ConfigureDefaultModuleRoot,
// Interactivity
InteractivityDisable,
// Experiments
Experiments,
AllowExperiments,
// Experimentation
Experimentation,
AllowExperimentation,
#ifndef AICLI_DISABLE_TEST_HOOKS
// Debug
EnableSelfInitiatedMinidump,
Expand Down Expand Up @@ -208,10 +208,10 @@ namespace AppInstaller::Settings
// Interactivity
SETTINGMAPPING_SPECIALIZATION(Setting::InteractivityDisable, bool, bool, false, ".interactivity.disable"sv);

// Experiments
using Experiments_t = std::map<std::string, bool>;
SETTINGMAPPING_SPECIALIZATION(Setting::Experiments, Experiments_t, Experiments_t, {}, ".experiments"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::AllowExperiments, bool, bool, true, ".allowExperiments"sv);
// Experimentation
using Experimentation_t = std::map<std::string, bool>;
SETTINGMAPPING_SPECIALIZATION(Setting::Experimentation, Experimentation_t, Experimentation_t, {}, ".experimentation"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::AllowExperimentation, bool, bool, true, ".allowExperimentation"sv);

// Used to deduce the SettingVariant type; making a variant that includes std::monostate and all SettingMapping types.
template <size_t... I>
Expand Down
Loading

0 comments on commit 70ddb26

Please sign in to comment.