-
-
Notifications
You must be signed in to change notification settings - Fork 274
fix: RemoteFeatureFlagController client version change cache invalidation #7827
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
base: main
Are you sure you want to change the base?
Changes from all commits
4d10ee5
312609f
9f93669
016bbe9
daa2655
6dfa4ae
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 |
|---|---|---|
|
|
@@ -168,6 +168,7 @@ export class RemoteFeatureFlagController extends BaseController< | |
| * @param options.disabled - Determines if the controller should be disabled initially. Defaults to false. | ||
| * @param options.getMetaMetricsId - Returns metaMetricsId. | ||
| * @param options.clientVersion - The current client version for version-based feature flag filtering. Must be a valid 3-part SemVer version string. | ||
| * @param options.prevClientVersion - The previous client version for feature flag cache invalidation. | ||
| */ | ||
| constructor({ | ||
| messenger, | ||
|
|
@@ -177,6 +178,7 @@ export class RemoteFeatureFlagController extends BaseController< | |
| disabled = false, | ||
| getMetaMetricsId, | ||
| clientVersion, | ||
| prevClientVersion, | ||
|
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. Now stateless. We can pass in a constructor parameter for the previous version. Example on clients: // the persisted current app ver is the new prevClientVersion we will pass into the `RemoteFeatureFlagController`.
const prevClientVersion =
persistedState.AppMetadataController?.currentAppVersion;
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. I'll spin up preview builds on mobile and extension to validate. |
||
| }: { | ||
| messenger: RemoteFeatureFlagControllerMessenger; | ||
| state?: Partial<RemoteFeatureFlagControllerState>; | ||
|
|
@@ -185,20 +187,32 @@ export class RemoteFeatureFlagController extends BaseController< | |
| fetchInterval?: number; | ||
| disabled?: boolean; | ||
| clientVersion: string; | ||
| prevClientVersion?: string; | ||
| }) { | ||
| if (!isValidSemVerVersion(clientVersion)) { | ||
| throw new Error( | ||
| `Invalid clientVersion: "${clientVersion}". Must be a valid 3-part SemVer version string`, | ||
| ); | ||
| } | ||
|
|
||
| const initialState: RemoteFeatureFlagControllerState = { | ||
| ...getDefaultRemoteFeatureFlagControllerState(), | ||
| ...state, | ||
| }; | ||
|
|
||
| const hasClientVersionChanged = | ||
| isValidSemVerVersion(prevClientVersion) && | ||
| prevClientVersion !== clientVersion; | ||
|
|
||
| super({ | ||
| name: controllerName, | ||
| metadata: remoteFeatureFlagControllerMetadata, | ||
| messenger, | ||
| state: { | ||
| ...getDefaultRemoteFeatureFlagControllerState(), | ||
| ...state, | ||
| ...initialState, | ||
| cacheTimestamp: hasClientVersionChanged | ||
| ? 0 | ||
| : initialState.cacheTimestamp, | ||
| }, | ||
| }); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.