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

Ensure Staging environment badge is shown for beta builds on iOS and Android #2647

Merged
merged 44 commits into from
May 19, 2021

Conversation

Jag96
Copy link
Contributor

@Jag96 Jag96 commented Apr 30, 2021

@roryabraham will you please review this?

Details

Since we use the same builds for staging and production, both staging and production builds on iOS and Android use the production .env, so we need another way to differentiate whether the app is staging or production. iOS allows us to check if the app is a TestFlight build, so this PR adds a nativeModule to check that on startup. For the Android check, there isn't an easy way to do this, so we have to query the play store and grab the current version from the html.

Fixed Issues

Fixes #2597

Tests

  1. Run the app on dev on all platforms and sign out, confirm that you see a dev badge on the sign-in screen logo. On desktop, confirm you see a dev badge for the doc icon.
  2. Login to any account, confirm after logging in you see a dev badge on the main app screen next to Chats
  3. Confirm that after logging out, the proper icon shows on staging and dev
  4. On desktop, run npm run desktop-build-staging, then open the Expensify.cash app inside dist/mac. Confirm the icon has the stg badge.
  5. Confirm on the sign-in screen the icon has a stg badge. Sign in and confirm the stg badge shows up next to Chats
  6. Update your .env file to include ENVIRONMENT=PROD and run the app on web/ios, confirm you see no badges on the sign-in screen and in the app
  7. Update the return statement in EnvironmentChecker.m to return [NSNumber numberWithBool:isRunningTestFlightBeta]; and set ENVIRONMENT=PROD in your .env file. Confirm that when running the app, you see the STG badge (we'll test this live once its merged to confirm it shows up properly on the actual TestFlight)
  8. On Android, set the ENVIRONMENT to PROD and run the app. Confirm that you see the STG badge
  9. Update the CONST.PLAY_STORE_URL constant inside setEnvironment/index.android.js to be a nonsense URL. Run the app again, confirm no badge is shown
  10. Reset the CONST.PLAY_STORE_URL value so it is correct again, then update the version value inside package.json and package-lock.json to the Current Version from https://play.google.com/store/apps/details?id=com.expensify.chat&hl=en
  11. Run the Android app, confirm no badge shows

QA Steps

  1. Confirm that when running the app on staging, an STG badge appears on the sign-in screen icon, and in the main app next to Chats (after login) on Desktop, iOS, and Web
    2. Confirm that on desktop, the desktop icon shows with the STG badge
  2. Sign out of the app, confirm STG still shows on the login screen icon
  3. Confirm that when running the app on prod (all platforms), there are no badges

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

@Jag96 Jag96 requested a review from roryabraham April 30, 2021 03:33
@Jag96 Jag96 requested a review from a team as a code owner April 30, 2021 03:33
@Jag96 Jag96 self-assigned this Apr 30, 2021
@MelvinBot MelvinBot requested review from francoisl and removed request for a team April 30, 2021 03:33
roryabraham
roryabraham previously approved these changes Apr 30, 2021
Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

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

Nice. Objective-C is pretty foreign to me, but overall looks good!

@Jag96
Copy link
Contributor Author

Jag96 commented Apr 30, 2021

Going to put this on WIP to include the improvements mentioned in #2597 (comment)

@Jag96 Jag96 changed the title Ensure Staging environment badge is shown for iOS TestFlight builds [WIP Testing] Ensure Staging environment badge is shown for iOS TestFlight builds Apr 30, 2021
@Jag96 Jag96 changed the title [WIP Testing] Ensure Staging environment badge is shown for iOS TestFlight builds Ensure Staging environment badge is shown for iOS TestFlight builds May 3, 2021
@Jag96 Jag96 changed the title Ensure Staging environment badge is shown for iOS TestFlight builds Ensure Staging environment badge is shown for beta builds on iOS and Android May 3, 2021
@Jag96
Copy link
Contributor Author

Jag96 commented May 3, 2021

Updated this to add an Android check and move the environment value into Onyx, this is ready for another review!

@francoisl
Copy link
Contributor

Looks like there's a conflict in src/libs/actions/SignInRedirect.js now

fetch(CONST.PLAY_STORE_URL)
.then(res => res.text())
.then((text) => {
const match = text.match(/<span[^>]+class="htlgb"[^>]*>([-\d.]+)<\/span>/);
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it could easily break if Google decides to change the name of the class. Can't think of anything better though, I did a quick search and it doesn't seem like they have an API to query an app's version number.
Maybe it's overkill but could we store the version number somewhere (tbd where) when we make a new release, and then make a new API command on expensify.com to retrieve it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was something I thought of doing as well since it is one of the only other options I found. I ultimately decided against it since that HTML hasn't been updated in >5 years, and even if it was updated it'd be easy to update the code. Also, having the version somewhere means we have to update expensify.com (or wherever we store that value) every time we deploy the app to production, which seemed like overkill since Google is already giving us that data on the play store page. If we think that's a better solution though, I can have a look at implementing that

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, good to know it hasn't changed in over 5 years. And yes, it should be easy to update if they change the structure of the play store page.

@Jag96 Jag96 dismissed stale reviews from francoisl and roryabraham via 137fcf2 May 14, 2021 18:36
@Jag96
Copy link
Contributor Author

Jag96 commented May 14, 2021

Updated to remove the unnecessary catch and boolean

@Jag96
Copy link
Contributor Author

Jag96 commented May 18, 2021

Updated to DRY the code a bit and address the review comments, added one question but otherwise this is good for another review!

@Jag96
Copy link
Contributor Author

Jag96 commented May 19, 2021

Thanks for the review @tgolen, updated again to resolve the last outstanding comment

@Jag96
Copy link
Contributor Author

Jag96 commented May 19, 2021

@tgolen @roryabraham Updated to add the ref forwarding, please let me know if there's anything I missed!

Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM 👍

Copy link
Contributor

@tgolen tgolen left a comment

Choose a reason for hiding this comment

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

Very cool, thanks for that!

@tgolen tgolen merged commit 31c5c5a into main May 19, 2021
@tgolen tgolen deleted the joe-mobile-stg-badge branch May 19, 2021 22:48
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

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.

STG badge doesn't appear on iOS/Android
5 participants