WordPress-iOS
WordPress-iOS copied to clipboard
Remote Feature Flags: Add cache expiry logic and make authenticated request if possible
Closes #19279 Closes #19291
Description
- Added cache expiry logic to
RemoteFeatureFlagStore, and added a parameter toRemoteFeatureFlagStore.updateIfNeededto be able to bypass this logic. - Refactored
RemoteFeatureFlagStore.updateIfNeededto accept an instance ofFeatureFlagRemoteso we can pass an authenticated remote if possible. - Now we attempt to update the feature flags on every launch and relaunch.
- We also attempt to update the feature flags whenever the user logs in or out.
Testing Instructions
Pre-testing notes
- The current endpoint does not support integer build numbers so by default the request always fails. Before testing, please manually update the app's build number to
1for example. - In order to easily test the cache expiry logic, you can manually update the value of
RemoteFeatureFlagStore.Constants.CacheTTLto a small value. (60 seconds for example) - Some testing instructions will require a network debugging app like Charles or Proxyman.
Cache Expiry
- Delete the app
- Install and run the app
- Once the app is launched check that a request to the
feature-flagsendpoint is made. - Before the TTL passes, send the app to the background then re-open it.
- Check that a request to the
feature-flagsendpoint is NOT made. - Wait for the TTL to pass
- Send the app to the background then re-open it.
- Check that a request to the
feature-flagsendpoint is made. - Before the TTL passes, terminate the app and then launch it.
- Check that a request to the
feature-flagsendpoint is NOT made.
Authenticated requests
- Make sure you're logged in
- Trigger a refresh by relaunching the app after the TTL has passed
- Check the request and make sure that the headers contain the Bearer token
- Log out
- Trigger a refresh by relaunching the app after the TTL has passed
- Check the request and make sure that the headers do not contain the Bearer token
Different Triggers
- Make sure to set a long TTL
- Delete the app
- Install and run the app
- Once the app is launched check that a request to the
feature-flagsendpoint is made. - Log in to the app
- Make sure that a request to the
feature-flagsendpoint is made. - Logout of the app
- Make sure that a request to the
feature-flagsendpoint is made. - Signup for a new account
- Make sure that a request to the
feature-flagsendpoint is made.
Regression Notes
-
Potential unintended areas of impact N/A
-
What I did to test those areas of impact (or what existing automated tests I relied on) N/A
-
What automated tests I added (or what prevented me from doing so) Will add unit tests in another PR.
PR submission checklist:
- [x] I have completed the Regression Notes.
- [x] I have considered adding unit tests for my changes.
- [x] I have considered adding accessibility improvements for my changes.
- [x] I have considered if this change warrants user-facing release notes and have added them to
RELEASE-NOTES.txtif necessary.
You can test the changes in Jetpack from this Pull Request by:
- Clicking here or scanning the QR code below to access App Center
- Then installing the build number
pr19293-4043c0aon your iPhone
You can test the changes in WordPress from this Pull Request by:
- Clicking here or scanning the QR code below to access App Center
- Then installing the build number
pr19293-4043c0aon your iPhone
Forgot to mention earlier that we should add release notes.
@momo-ozawa I feel that none of the changes here are user-facing. They're also too low-level and would be challenging to test during beta testing. Wdyt?
Hey @hassaanelgarem 👋
I feel that none of the changes here are user-facing
I was thinking of using the [internal] tag.
They're also too low-level and would be challenging to test during beta testing. Wdyt?
Hmm, might be worth checking in with the quality team about this.
might be worth checking in with the quality team about this.
Agreed!
@pachlava This PR amends existing logic surrounding the remote feature flags. Now we make a request to the /feature-flags endpoint on each launch and relaunch, given that cache hasn't expired yet. We also refresh the flags on each login and logout. We currently don't use any remote feature flags, so there's no noticeable changes to the app. Given these changes, do you think it warrants an internal release note?
@pachlava This PR amends existing logic surrounding the remote feature flags. Now we make a request to the /feature-flags endpoint on each launch and relaunch, given that cache hasn't expired yet. We also refresh the flags on each login and logout. We currently don't use any remote feature flags, so there's no noticeable changes to the app. Given these changes, do you think it warrants an internal release note?
@hassaanelgarem 👋
I'm sorry for such a long delay before my reply. With this exact PR, and the described testing scenarios - I would not expect this to be a part of release notes, usually. However, if you want the PR to get an additional attention during internal beta testing, I think it can be prefixed with [Internal] then. In such a case, it won't be mentioned it in the public CfT.
Usually, the CfT runner and creator (cc @tiagomar, who runs the WPiOS ones) takes a look into the whole milestone, and decides if PRs not listed in the release notes should still be tested during beta testing. But as I wrote above, this can be facilitated by using the [Internal] prefix.
We will no longer implement a cache expiry logic. More details here: https://github.com/wordpress-mobile/WordPress-iOS/issues/19279#issuecomment-1271087569
@momo-ozawa @jkmassel I removed the TTL logic completely. The PR is now ready for a re-review 🙏
Looks like all of Jeremy's comments have been addressed, plus @momo-ozawa has approved this. I'm going to merge this so it can be part of the 21.0 beta.
It should be straightforward to disable this in the release branch if some issues will be identified by removing the few calls to the method that tiggers the fetch.