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

fix(flags): Ensure activity log reflects removing variants #29379

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

haacked
Copy link
Contributor

@haacked haacked commented Feb 28, 2025

Updates the activity log for feature flags to describe two types of variant deletions:

  1. When individual variants are deleted, but there are still variants left.
  2. When all variants are removed (via changing release toggle).

Problem

Fixes #26115

Turns out activity log doesn't mention when a variant is removed. It also didn't describe when all variants are removed (as would happen if you changed the release toggle to boolean or remote config)

Changes

We'll start with a feature flag with four variants.

Screenshot 2025-02-28 at 3 14 35 PM

And remove two of them, adjusting the rollout percentages to sum to 100%.

Screenshot 2025-02-28 at 3 23 02 PM

Activity log shows:

Screenshot 2025-02-28 at 3 23 15 PM

Ok, let's remove all variants by changing this to a remote config setting:

Screenshot 2025-02-28 at 3 25 08 PM

Screenshot 2025-02-28 at 3 25 17 PM

Finally, let's go back to a feature flag with variants:

Screenshot 2025-02-28 at 3 27 33 PM

And we'll change its release toggle to boolean with no other changes.

Screenshot 2025-02-28 at 3 27 44 PM

Just to make sure we get a standalone log.

Screenshot 2025-02-28 at 3 27 55 PM

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Manual tests and some unit tests.

Supports removing individual variants as well as all of them.

Fixes #26115
@haacked haacked requested a review from a team February 28, 2025 23:29
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR enhances the feature flag activity log to properly track and display variant deletions, addressing a gap in the previous implementation.

  • Added test cases in frontend/src/lib/components/ActivityLog/activityLogLogic.feature-flag.test.tsx to verify proper logging of individual variant deletions and complete variant removal
  • Implemented logic in frontend/src/scenes/feature-flags/activityDescriptions.tsx to detect when variants are removed by comparing before/after states using Sets
  • Added specific handling for the case when all variants are removed (when changing from multivariate to boolean/remote config)
  • Created human-readable activity log messages that clearly indicate which variants were removed
  • Ensured the implementation works for both individual variant removals and bulk removals

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Contributor

github-actions bot commented Feb 28, 2025

Size Change: 0 B

Total Size: 9.73 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 9.73 MB

compressed-size-action

@haacked
Copy link
Contributor Author

haacked commented Feb 28, 2025

@dmarticus in the original issue you mentioned "Clean up the feature flag history" but it wasn't clear to me what you meant by that. My suggestion is we get this PR in first so that we start logging when variants are removed. We can always follow up with a new issue for improvements to the presentation of the activity log.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

6 snapshot changes in total. 0 added, 6 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add feature flag variant deletion to the feature flag history
2 participants