-
-
Notifications
You must be signed in to change notification settings - Fork 284
fix: Normalize remote feature flag value wrappers #8908
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
Changes from all commits
761c717
4b6e1cc
b0a1f11
9dc313d
363c9fd
1de7517
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import type { Json, SemVerVersion } from '@metamask/utils'; | |
|
|
||
| import type { AbstractClientConfigApiService } from './client-config-api-service/abstract-client-config-api-service'; | ||
| import type { RemoteFeatureFlagControllerMethodActions } from './remote-feature-flag-controller-method-action-types'; | ||
| import { ThresholdVersion } from './remote-feature-flag-controller-types'; | ||
| import type { | ||
| FeatureFlags, | ||
| ServiceResponse, | ||
|
|
@@ -118,6 +119,19 @@ export function getDefaultRemoteFeatureFlagControllerState(): RemoteFeatureFlagC | |
| }; | ||
| } | ||
|
|
||
| function normalizeThresholdValue(featureFlag: FeatureFlagScopeValue): Json { | ||
| if (featureFlag.thresholdVersion === ThresholdVersion.DirectValue) { | ||
| return featureFlag.value; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor, could still be useful to also include Not sure how this will impact the new AB testing hooks.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good points let's add that if and when it becomes necessary then |
||
| } | ||
|
|
||
| // Unknown threshold versions fall back to the legacy wrapper shape for | ||
| // backwards compatibility with existing threshold feature flag configs. | ||
| return { | ||
| name: featureFlag.name, | ||
| value: featureFlag.value, | ||
| }; | ||
| } | ||
|
NicolasMassart marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * The RemoteFeatureFlagController manages the retrieval and caching of remote feature flags. | ||
| * It fetches feature flags from a remote API, caches them, and provides methods to access | ||
|
|
@@ -371,11 +385,9 @@ export class RemoteFeatureFlagController extends BaseController< | |
| return threshold <= featureFlag.scope.value; | ||
| }, | ||
| ); | ||
|
|
||
| if (selectedGroup) { | ||
| processedValue = { | ||
| name: selectedGroup.name, | ||
| value: selectedGroup.value, | ||
| }; | ||
| processedValue = normalizeThresholdValue(selectedGroup); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.