Skip to content

feat: add metaMetricsIds explicit targeting to threshold feature flags#9340

Merged
pedronfigueiredo merged 6 commits into
mainfrom
pnf/ff-user-overrides
Jul 3, 2026
Merged

feat: add metaMetricsIds explicit targeting to threshold feature flags#9340
pedronfigueiredo merged 6 commits into
mainfrom
pnf/ff-user-overrides

Conversation

@pedronfigueiredo

@pedronfigueiredo pedronfigueiredo commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds optional metaMetricsIds?: string[] field to FeatureFlagScopeValue in the remote feature flag controller types
  • When the current user's MetaMetrics ID matches an entry's metaMetricsIds list, that entry is selected immediately, bypassing hash-based rollout
  • Explicit-ID matches bypass the threshold cache; hash-based fallback continues to use and populate the cache as before
  • metaMetricsIds values are redacted from rawRemoteFeatureFlags before persisting to state, so they never appear in state logs or debug snapshots
  • Local overrides still take precedence over explicit-ID targeting

Behaviour

  • IDs are compared case-insensitively after trimming whitespace
  • First matching entry wins when multiple entries share the same ID
  • Entries with malformed metaMetricsIds (non-array) are silently skipped; those entries still participate in hash-based selection
  • Intended for QA and Product Manager testing in any environment, not general-purpose segmentation

Test plan

  • All existing tests pass (66 total)
  • New metaMetricsIds explicit targeting describe block covers: exact match, first-match-wins, hash fallback, malformed entries, non-string items, normalization, cache bypass, cache fallback population, state redaction, and ThresholdVersion.DirectValue compatibility

Note

Medium Risk
Changes core threshold selection and persists redacted flag payloads; misconfigured remote metaMetricsIds could steer specific users in production, though hash rollout and local overrides behavior remain.

Overview
Adds optional metaMetricsIds on threshold flag entries so QA/PM users can be pinned to a variant before hash-based rollout runs.

Threshold processing now checks findExplicitIdMatch first (trim + case-insensitive ID compare, first matching entry wins, malformed lists skipped); on match it resolves the entry’s value and optional group name without writing thresholdCache. Otherwise behavior is unchanged: hash threshold + cache.

redactMetaMetricsIds strips targeting lists from rawRemoteFeatureFlags and processed remoteFeatureFlags before state persistence so IDs do not appear in logs or debug snapshots. Types and changelog are updated; a large test suite covers match, fallback, cache, redaction, and ThresholdVersion.DirectValue.

Reviewed by Cursor Bugbot for commit c77249e. Bugbot is set up for automated code reviews on this repo. Configure here.

@pedronfigueiredo pedronfigueiredo requested review from a team as code owners July 1, 2026 12:39

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 0a800c3. Configure here.

@matthewwalsh0 matthewwalsh0 requested a review from dan437 July 2, 2026 11:00
dan437
dan437 previously approved these changes Jul 3, 2026
pedronfigueiredo and others added 6 commits July 3, 2026 16:47
Strip metaMetricsIds from processedFlags before writing them to
remoteFeatureFlags state and #processedRemoteFeatureFlags. Previously,
metaMetricsIds were only redacted from rawRemoteFeatureFlags, but
threshold arrays preserved as-is (e.g. when metaMetricsId is not
available) would leak explicit-targeting IDs into state, logs, and
debug snapshots.

Also fixes Prettier formatting and updates changelog PR link.
Fixes jest/no-conditional-expect lint failure by asserting the
resolved flag shape directly, since explicit-ID matches always
resolve to an object.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…old flags

Rebase onto main's breaking change (#9289) that returns the selected
threshold value directly instead of wrapping it in { name, value },
storing the selected group name in featureFlagThresholdGroups instead.
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Jul 3, 2026
Merged via the queue into main with commit f865e12 Jul 3, 2026
413 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/ff-user-overrides branch July 3, 2026 23:44
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.

3 participants