Skip to content

docs: update remote feature flag threshold API#176

Closed
asalsys wants to merge 1 commit into
mainfrom
docs/remote-feature-flag-threshold-api
Closed

docs: update remote feature flag threshold API#176
asalsys wants to merge 1 commit into
mainfrom
docs/remote-feature-flag-threshold-api

Conversation

@asalsys

@asalsys asalsys commented Jul 2, 2026

Copy link
Copy Markdown

Summary

Updates remote feature flags documentation to reflect the RemoteFeatureFlagController API changes in MetaMask/core#9325, MetaMask/core#9289:

  • Threshold flags return the selected value directly from remoteFeatureFlags (no { name, value } wrapper).
  • Selected group names are exposed via featureFlagThresholdGroups when the winning threshold entry includes name.
  • Documents optional idType on threshold entries (canonical by default, metametrics for legacy MetaMetrics segmentation).
  • Updates the local override example to use a direct flag value.

Test plan

  • Reviewed markdown for accuracy against RemoteFeatureFlagController behavior in core PR #9325

Made with Cursor

Document featureFlagThresholdGroups, canonical ID as the default threshold
segmentation identifier, and removal of the legacy { name, value } wrapper.

Co-authored-by: Cursor <cursoragent@cursor.com>
@asalsys asalsys requested review from DDDDDanica and removed request for DDDDDanica July 2, 2026 14:08
@asalsys asalsys closed this Jul 2, 2026
@asalsys asalsys deleted the docs/remote-feature-flag-threshold-api branch July 2, 2026 14:10
@asalsys asalsys restored the docs/remote-feature-flag-threshold-api branch July 2, 2026 14:41
@asalsys asalsys reopened this Jul 2, 2026
@asalsys asalsys closed this Jul 2, 2026
@asalsys asalsys deleted the docs/remote-feature-flag-threshold-api branch July 2, 2026 14:46
pull Bot pushed a commit to dmrazzy/core that referenced this pull request Jul 2, 2026
…y and track threshold groups (MetaMask#9289)

## Summary

- **BREAKING:** Threshold feature flags now return the selected `value`
directly from `remoteFeatureFlags` instead of a `{ name, value }`
wrapper object.
- Add optional `featureFlagThresholdGroups` state field (`Record<string,
string>`) that maps feature flag names to their selected threshold group
name when the selected threshold entry includes `name`.
- Remove `normalizeThresholdValue` and the legacy `{ name, value }`
wrapper fallback.

## References

- Fixes
[MCWP-655](https://consensyssoftware.atlassian.net/browse/MCWP-655)

## Motivation

Separating the processed flag value from threshold group metadata makes
it easier for consumers to use threshold flags as plain values
(booleans, objects, etc.) without unwrapping. The new
`featureFlagThresholdGroups` field provides explicit access to A/B group
assignment when the selected threshold entry includes `name`.

Entries that only define `thresholdName` (for example in
`thresholdVersion: 2` configs) still resolve to the selected `value`,
but do not populate `featureFlagThresholdGroups` because that field is
driven by `name`.

## Migration

Consumers that previously read threshold group names from
`remoteFeatureFlags[flagName].name` should instead:

1. Read the flag value directly from `remoteFeatureFlags[flagName]`.
2. Read the threshold group name from
`featureFlagThresholdGroups[flagName]` when available (populated when
the selected threshold entry includes `name`).

**Before:**
```ts
const flag = remoteFeatureFlags.myThresholdFlag;
// { name: 'groupB', value: { enabled: true } }
const groupName = flag.name;
const value = flag.value;
```

**After:**
```ts
const value = remoteFeatureFlags.myThresholdFlag;
// { enabled: true }

const groupName = featureFlagThresholdGroups.myThresholdFlag;
// 'groupB'
```

## Related

- Documentation:
[MetaMask/contributor-docs#176](MetaMask/contributor-docs#176)

## Test plan

- [x] `yarn workspace @metamask/remote-feature-flag-controller run test`
— all tests pass with 100% coverage
- [x] Threshold flags return the selected `value` directly from
`remoteFeatureFlags`
- [x] Threshold flags populate `featureFlagThresholdGroups` when the
selected entry includes `name`
- [x] Threshold flags with only `thresholdName` return the value
directly and leave `featureFlagThresholdGroups` empty
- [x] Stale `featureFlagThresholdGroups` entries are cleaned up when
flags are removed from the server response

[MCWP-655]:
https://consensyssoftware.atlassian.net/browse/MCWP-655?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Breaking change to the public shape of threshold flag values affects
all consumers of `remoteFeatureFlags`; persisted state gains a new field
but assignment logic is otherwise unchanged.
> 
> **Overview**
> **BREAKING:** Threshold/A/B flags in `remoteFeatureFlags` now expose
the selected entry’s **`value` only** (string, boolean, object, etc.)
instead of a `{ name, value }` wrapper. Group assignment moves to a new
optional persisted state field **`featureFlagThresholdGroups`**
(`flagName → group name`) when the winning threshold item has a `name`.
> 
> Processing drops **`normalizeThresholdValue`** and
**`ThresholdVersion`** branching—legacy wrappers and “direct value vs
wrapper” version handling are gone; threshold arrays are resolved the
same way regardless of `thresholdVersion`. On each fetch,
**`featureFlagThresholdGroups` is rebuilt** from the current server
payload so entries for removed flags are cleared (covered by tests).
> 
> **Migration:** read values from `remoteFeatureFlags[flag]`; read group
names from `featureFlagThresholdGroups[flag]` when present.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
98b74a2. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
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.

1 participant