Skip to content
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

feat: implement remote feature flag controller #12427

Merged
merged 55 commits into from
Dec 2, 2024
Merged

Conversation

joaoloureirop
Copy link
Contributor

@joaoloureirop joaoloureirop commented Nov 26, 2024

Description

Introduction of @metamask/remote-feature-flag-controller library.

Remote feature flag controller manages data flow, retry policy, and cache expiry.
The controller consumer manages default values, data persistency, and data distribution.

See ADR for a in-depth description

Technical decisions

Controller init on Engine.ts with feature flags fetching only on cold app starts.

@metamask/remote-feature-flag-controller is only asked to fetch feature flags after its init in Engine.ts. Ensures feature flags are only fetched on cold app starts.

Fallback values

Default values are used when remote feature flags are undefined.
The fallback mechanism is implemented by each feature flag selector app/selectors/featureFlagsController/<featureFlagName>

In this PR we include minimumAppVersion selector, which manages the LD feature flag mobile-minimum-versions

One selector per each feature flag

LD feature flags can be boolean, number, strings on JSON objects.
We've decided to have each feature flag with its own selector

A feature flag selector contains:

  • state selectors for each feature flag value.
  • business logic
  • defaults for when feature flags values are undefined.
  • TS types.
  • unit tests and mocked data.

This architecture offers a clear separation between each feature flag and the logic behind it, allowing easier manipulation.
Code owners are assigned to each feature flag.

Related issues

Fixes: https://github.com/MetaMask/mobile-planning/issues/2054
Fixes: https://github.com/MetaMask/mobile-planning/issues/1975

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@joaoloureirop joaoloureirop self-assigned this Nov 26, 2024
@joaoloureirop joaoloureirop changed the title feat: feature-flag-controller feat: implement remote feature flag controller Nov 26, 2024
@gauthierpetetin gauthierpetetin added the team-mobile-platform Mobile Platform team label Nov 26, 2024
app/core/Engine.ts Outdated Show resolved Hide resolved
metro.config.js Outdated Show resolved Hide resolved
metro.config.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
yarn.lock Outdated Show resolved Hide resolved
@joaoloureirop joaoloureirop added the Run Smoke E2E Triggers smoke e2e on Bitrise label Nov 29, 2024
Copy link
Contributor

github-actions bot commented Nov 29, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 9cd1bf0
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/18207d2d-9854-41b3-916d-d079e3ca8ba8

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@joaoloureirop joaoloureirop added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Nov 29, 2024
Copy link
Contributor

@NicolasMassart NicolasMassart left a comment

Choose a reason for hiding this comment

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

update tests please

@joaoloureirop
Copy link
Contributor Author

I've revisited the controller initialisation testing.

  • unit test that can't be validated without mocking the feature flag service were removed.
  • unit tests names were improved.

For the selector, the unit test names were updated

Thanks for your review @NicolasMassart

Copy link
Contributor

@NicolasMassart NicolasMassart left a comment

Choose a reason for hiding this comment

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

allowing myself to fix some typos and missing 'when' directly

@joaoloureirop joaoloureirop added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Dec 2, 2024
Copy link
Contributor

github-actions bot commented Dec 2, 2024

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 7d59ace
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/c37fffe4-8bd7-4b96-9ebd-bb90f5d49aac

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

Copy link

sonarqubecloud bot commented Dec 2, 2024

Copy link
Contributor

@NicolasMassart NicolasMassart left a comment

Choose a reason for hiding this comment

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

Looks good to me on the code side.

@joaoloureirop joaoloureirop added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise needs-qa Any New Features that needs a full manual QA prior to being added to a release. labels Dec 2, 2024
@joaoloureirop joaoloureirop added this pull request to the merge queue Dec 2, 2024
Merged via the queue into main with commit a8c0783 Dec 2, 2024
46 of 52 checks passed
@joaoloureirop joaoloureirop deleted the feat/feature-flags branch December 2, 2024 18:34
@github-actions github-actions bot removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Dec 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2024
@metamaskbot metamaskbot added the release-7.38.0 Issue or pull request that will be included in release 7.38.0 label Dec 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-7.38.0 Issue or pull request that will be included in release 7.38.0 Run Smoke E2E Triggers smoke e2e on Bitrise team-mobile-platform Mobile Platform team
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

10 participants