App icon indicating copy to clipboard operation
App copied to clipboard

STG badge doesn't appear on iOS/Android

Open Jag96 opened this issue 5 years ago • 10 comments

iOS/Android - STG badge doesn't appear

from https://github.com/Expensify/Expensify.cash/pull/2506#issuecomment-827836039

Expected Result

An STG badge appears on the sign-in screen icon, and in the main app next to Chats and Settings (after login)

Actual Result

STG badge doesn't appear

Action performed

  1. Install test build 1.0.32-0
  2. Open sign-in screen
  3. Login
  4. Observe chat screen
  5. Open settings

Platform

Issue confirmed in:

iOS ✔️ Android ✔️

Notes/Images/Video

Jag96 avatar Apr 27 '21 19:04 Jag96

Maybe you are on an old build but I see it on latest code and dev app.

parasharrajat avatar Apr 27 '21 19:04 parasharrajat

@parasharrajat on the latest TestFlight the staging badges aren't showing up, it looks like the reason is the beta lane is using the production environment file here: https://github.com/Expensify/Expensify.cash/blob/main/fastlane/Fastfile#L30

The dev badge is the default if no ENVIRONMENT value is set in your .env file, so if you're running on dev it makes sense that it'd be working there

Jag96 avatar Apr 27 '21 19:04 Jag96

Ah yes this was an oversight in the badge PR. Unfortunately, it's not as simple as just changing the environment for the beta build to .env.staging. Because we use deliver for our production deploys, we're not actually doing a new build - just sending the existing beta build to the app stores for production. @AndrewGable, how should we go about fixing this?

roryabraham avatar Apr 27 '21 19:04 roryabraham

So we cannot determine this programmatically? I think ideally we keep the deploy process the same.

AndrewGable avatar Apr 27 '21 19:04 AndrewGable

We're currently getting the environment value from the config, outside of that I don't see a way to differentiate staging from production. If the next production build is the same build as the current staging build, I'm not sure how we could solve this programmatically without updating the build somehow, unless you mean something different?

Jag96 avatar Apr 27 '21 19:04 Jag96

It looks like there are a few ways for checking if iOS is on a TestFlight vs production (see https://github.com/react-native-device-info/react-native-device-info/issues/228), but I don't see any clean ways to do this for Google Play outside of querying the Play Store, checking the version, and comparing it to the current version. Going to look into both of these options, but open to other suggestions.

Jag96 avatar Apr 28 '21 22:04 Jag96

I agree that if there were a way to programmatically differentiate staging v.s. production without a separate environment that would be better, because it eliminates the risk that the prod environment can be misconfigured without our noticing on staging.

roryabraham avatar Apr 28 '21 23:04 roryabraham

I've created a PR to handle showing the STG badge on iOS, but for Android, there aren't any clean ways that I found to handle this. The most common way to check on Android involves making an API call and fetching the text from the play-store listing and searching for the Current Version value. While this does allow us to get the version, this results in a few side effects:

  • We need to block the App to wait for the API call to finish, which can take time on a slow network
  • ~We are using the user's data on production to make that API call, which is checking for something that is really only useful for QA~

Because of those two points, unless there is another way to handle this I don't think it's worth adding the badge on Android. Open to suggestions!

Jag96 avatar Apr 30 '21 03:04 Jag96

We need to block the App to wait for the API call to finish

Not sure why we would need to do this, why not just default to a no-badge (production) value, then when the API call finishes, save the result in Onyx. On next startup, just look for the environment value in Onyx.

We are using the user's data on production to make that API call

Are you referring to the user's monthly data plan? I don't think http API request on App startup is really something we should be too concerned over.

That said, this feature is a nice-to-have, so if you think it's not worth fixing for the Android beta build that's fine with me.

roryabraham avatar Apr 30 '21 20:04 roryabraham

Not sure why we would need to do this, why not just default to a no-badge (production) value, then when the API call finishes, save the result in Onyx. On next startup, just look for the environment value in Onyx.

This is a good approach I didn't think of, the only problem I'm having with this is that after the user signs out we clear onyx, so the environment value gets cleared. I can fix this by saving the previous environment value in onyx, and resetting the value after each clear, but for any new calls to Onyx.clear() we'll have to add this. The default is production though, so I think this is fine, going to update the PR and also add the Android fetch code to see how it performs.

Jag96 avatar Apr 30 '21 23:04 Jag96