feat(remote-feature-flag-controller): segment threshold flags by metaMetricsFlags with canonical ID default - #9325
Open
asalsys wants to merge 16 commits into
Open
Conversation
…y and support canonical id segmentation Threshold flags now expose selected values directly, track group names in featureFlagThresholdGroups, and can use getCanonicalId when idType is canonical. Co-authored-by: Cursor <cursoragent@cursor.com>
…nd changelog links Default threshold segmentation to canonical ID, link changelog entries to PR #9325, add wallet changelog entry, and fix ESLint violations. Co-authored-by: Cursor <cursoragent@cursor.com>
asalsys
enabled auto-merge
July 1, 2026 03:11
1 task
NicolasMassart
previously approved these changes
Jul 7, 2026
NicolasMassart
self-requested a review
July 7, 2026 16:14
NicolasMassart
previously approved these changes
Jul 7, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1e9b936. Configure here.
|
|
||
| it('ignores non-string items within metaMetricsIds when matching', async () => { | ||
| const mockFlags = { | ||
| const mockFlags: FeatureFlags = { |
There was a problem hiding this comment.
Hash fallback test misses MetaMetrics opt-in
Medium Severity
The malformed-metaMetricsIds hash-fallback case still expects the MetaMetrics bucketing result for testFlag, but never lists that flag in metaMetricsFlags. With the new canonical default, this path hashes getCanonicalProfileId instead, so the assertion no longer validates the intended MetaMetrics fallback behavior.
Reviewed by Cursor Bugbot for commit 1e9b936. Configure here.
tommasini
approved these changes
Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
getCanonicalProfileIdconstructor callback and optionalmetaMetricsFlagsmap for threshold flag segmentation.metaMetricsFlagsuse MetaMetrics ID instead.@metamask/walletremote feature flag controller initialization.Segmentation Behavior
metaMetricsFlagsgetCanonicalProfileId()metaMetricsFlagsgetMetaMetricsId()If the selected identifier is empty, threshold arrays are preserved as-is and not processed.
Example threshold config using canonical segmentation by default:
{ "myCanonicalFlag": [ { "name": "groupA", "scope": { "type": "threshold", "value": 0.5 }, "value": "valueA" }, { "name": "groupB", "scope": { "type": "threshold", "value": 1.0 }, "value": "valueB" } ] }Example controller setup for a flag that should keep MetaMetrics segmentation:
Migration
Consumers must pass
getCanonicalProfileIdfor threshold flags that should use canonical profile segmentation, which is now the default for flags absent frommetaMetricsFlags.Existing threshold flags that must keep MetaMetrics-based bucketing should be listed in
metaMetricsFlagsand continue to providegetMetaMetricsId.Test plan
yarn workspace @metamask/remote-feature-flag-controller run jest --no-coverage src/utils/user-segmentation-utils.test.ts src/remote-feature-flag-controller.test.tsmetaMetricsFlagsusegetCanonicalProfileIdfor segmentationmetaMetricsFlagsusegetMetaMetricsIdfor segmentationRelated
Note
High Risk
Changes default A/B bucketing for threshold flags, so users can land in different groups unless legacy flags are listed in
metaMetricsFlags; rollout and cache behavior are user-facing and migration-sensitive.Overview
Threshold rollout no longer always keys off MetaMetrics ID.
RemoteFeatureFlagControllernow accepts optionalgetCanonicalProfileIdandmetaMetricsFlags: flags not listed in the map hashcanonicalProfileId + flag namefor bucketing and cache keys; flags in the map keep MetaMetrics-based segmentation (for legacy behavior).When the chosen segmentation ID is empty, threshold arrays are left unprocessed (same as before for missing MetaMetrics). Explicit
metaMetricsIdstargeting is unchanged but only runs when MetaMetrics ID is available.calculateThresholdForFlagis generalized to any non-empty segmentation ID. StalethresholdCachecleanup now drops entries for either the current MetaMetrics or canonical ID.@metamask/walletforwards the new options into remote feature flag initialization. Tests and changelogs are updated accordingly.Reviewed by Cursor Bugbot for commit 9c6a7a1. Bugbot is set up for automated code reviews on this repo. Configure here.