Skip to content

Commit

Permalink
Merge pull request #13698 from Expensify/andrew-play-store-beta
Browse files Browse the repository at this point in the history
Query GitHub API instead of Google Play Store to determine beta
  • Loading branch information
srikarparsi authored Dec 19, 2022
2 parents 7128d27 + 79ba41f commit 26db207
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"react-plaid-link": "3.3.2",
"react-web-config": "^1.0.0",
"save": "^2.4.0",
"semver": "^7.3.8",
"shim-keyboard-event-key": "^1.0.3",
"underscore": "^1.13.1",
"urbanairship-react-native": "^14.3.1"
Expand Down Expand Up @@ -184,7 +185,6 @@
"react-native-performance-flipper-reporter": "^2.0.0",
"react-native-svg-transformer": "^1.0.0",
"react-test-renderer": "18.1.0",
"semver": "^7.3.4",
"shellcheck": "^1.1.0",
"style-loader": "^2.0.0",
"time-analytics-webpack-plugin": "^0.1.17",
Expand Down
2 changes: 1 addition & 1 deletion src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ const CONST = {
TERMS_URL: `${USE_EXPENSIFY_URL}/terms`,
PRIVACY_URL: `${USE_EXPENSIFY_URL}/privacy`,
LICENSES_URL: `${USE_EXPENSIFY_URL}/licenses`,
PLAY_STORE_URL: `https://play.google.com/store/apps/details?id=${ANDROID_PACKAGE_NAME}&hl=en`,
GITHUB_RELEASE_URL: 'https://api.github.com/repos/expensify/app/releases/latest',
ADD_SECONDARY_LOGIN_URL: encodeURI('settings?param={"section":"account","openModal":"secondaryLogin"}'),
MANAGE_CARDS_URL: 'domain_companycards',
FEES_URL: `${USE_EXPENSIFY_URL}/fees`,
Expand Down
20 changes: 9 additions & 11 deletions src/libs/Environment/betaChecker/index.android.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import semver from 'semver';
import CONST from '../../../CONST';
import pkg from '../../../../package.json';

/**
* Check the Google Play store listing to see if the current build is a beta build or production build
* Check the GitHub releases to see if the current build is a beta build or production build
*
* @returns {Promise}
*/
function isBetaBuild() {
return new Promise((resolve) => {
fetch(CONST.PLAY_STORE_URL)
.then(res => res.text())
.then((text) => {
const productionVersionSearch = text.match(/\[\[\["\d+\.\d+\.\d+/);
if (!productionVersionSearch) {
fetch(CONST.GITHUB_RELEASE_URL)
.then(res => res.json())
.then((json) => {
const productionVersion = json.tag_name;
if (!productionVersion) {
resolve(false);
}

const productionVersion = productionVersionSearch[0].match(/\d+\.\d+\.\d+/);

// If we have a match for the production version regex and the current version is not the same
// as the production version, we are on a beta build
const isBeta = productionVersion && productionVersionSearch[0].trim() !== pkg.version;
// If the current version we are running is greater than the production version, we are on a beta version of Android
const isBeta = semver.gt(pkg.version, productionVersion);
resolve(isBeta);
})
.catch(() => {
Expand Down

0 comments on commit 26db207

Please sign in to comment.