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

Add feature flags plugin w/ config implementation and example feature #22221

Merged
merged 38 commits into from
May 28, 2024

Conversation

caddoo
Copy link
Contributor

@caddoo caddoo commented May 15, 2024

Description:

This contains the following:

  • Feature flag plugin for core
  • Single implementation of feature flag storage which is in the configuration file
  • A manager that supports multiple storage methods for features and can be expanded on later
  • An example feature called 'Example'
  • Showing an optional HTML comment in the markup of the home of Matomo is the flag is enabled
  • Added migration and bumped to new version 5.1.0-b5 so the plugin can be activated
  • Console command to enable/disable/delete feature flag

To Test:

Add the following to your config:

[FeatureFlags]
Example_feature = "enabled"

Then go to the main dashboard, look at the source code and look for the content:

<!-- Feature flag example enabled -->

Then play around with the value, of the config:
disabled / remove it completely.

In the console you can enable/disable/delete using the following:

./console featureflags:enable Example
./console featureflags:disable Example
./console featureflags:delete Example

You can try this if you want, by adding a new feature flag class to another plugin that implements the FeatureFlagInterface.

Then test if you can enable that feature flag as well.

Once the featureflag plugin is installed/activated, the DI will be available and can be used by just injecting FeatureFlagManager into the constructor of a class that needs it.

Review

@caddoo caddoo force-pushed the dev17998featureflag branch 2 times, most recently from 07bbb1e to dce6b57 Compare May 15, 2024 05:52
@caddoo caddoo marked this pull request as ready for review May 15, 2024 05:57
@sgiehl
Copy link
Member

sgiehl commented May 15, 2024

@caddoo You may need to add the new plugin here to ensure it's always active:

protected $pluginToAlwaysActivate = array(
'BulkTracking',
'CoreVue',
'CoreHome',
'CoreUpdater',
'CoreAdminHome',
'CoreConsole',
'CorePluginsAdmin',
'CoreVisualizations',
'Installation',
'SitesManager',
'UsersManager',
'Intl',
'API',
'Proxy',
'LanguagesManager',
'WebsiteMeasurable',
// default Piwik theme, always enabled
self::DEFAULT_THEME,
);

@caddoo caddoo added the Needs Review PRs that need a code review label May 15, 2024
@caddoo caddoo requested a review from a team May 15, 2024 07:46
@caddoo caddoo requested a review from a team May 16, 2024 05:17
@michalkleiner michalkleiner added the Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. label May 16, 2024
@caddoo caddoo removed the Needs Review PRs that need a code review label May 17, 2024
@caddoo caddoo force-pushed the dev17998featureflag branch 2 times, most recently from f4a6c45 to 13de0ca Compare May 20, 2024 03:25
@caddoo caddoo added the Needs Review PRs that need a code review label May 20, 2024
@caddoo caddoo requested review from a team, sgiehl and michalkleiner and removed request for a team May 20, 2024 04:45
plugins/FeatureFlags/Commands/ManageFeatureFlags.php Outdated Show resolved Hide resolved
plugins/FeatureFlags/Commands/ManageFeatureFlags.php Outdated Show resolved Hide resolved
plugins/FeatureFlags/Commands/ManageFeatureFlags.php Outdated Show resolved Hide resolved
plugins/FeatureFlags/Commands/ManageFeatureFlags.php Outdated Show resolved Hide resolved
core/Updates/5.1.0-b5.php Outdated Show resolved Hide resolved
plugins/FeatureFlags/Commands/ManageFeatureFlags.php Outdated Show resolved Hide resolved
plugins/FeatureFlags/Storage/ConfigFeatureFlagStorage.php Outdated Show resolved Hide resolved
plugins/FeatureFlags/Commands/EnableFeatureFlag.php Outdated Show resolved Hide resolved
core/Updates/5.1.0-b5.php Outdated Show resolved Hide resolved
Copy link
Member

@mneudert mneudert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a final screenshot update as the order of "always activated plugins" has changed after the latest changes.

@sgiehl sgiehl added this to the 5.1.0 milestone May 27, 2024
@caddoo caddoo modified the milestones: 5.1.0, 5.2.0 May 27, 2024
@sgiehl sgiehl merged commit badd00e into 5.x-dev May 28, 2024
24 of 25 checks passed
@sgiehl sgiehl deleted the dev17998featureflag branch May 28, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants