diff --git a/package-lock.json b/package-lock.json index fc4d72399a98..a8f8b908a725 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,6 +85,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" @@ -153,7 +154,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", @@ -37759,9 +37759,9 @@ } }, "node_modules/semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -71508,9 +71508,9 @@ } }, "semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "requires": { "lru-cache": "^6.0.0" } diff --git a/package.json b/package.json index 42dcedf62cd5..2d1bcc9a84e4 100644 --- a/package.json +++ b/package.json @@ -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" @@ -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", diff --git a/src/CONST.js b/src/CONST.js index 2a347d6c024b..58df088ffc19 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -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`, diff --git a/src/libs/Environment/betaChecker/index.android.js b/src/libs/Environment/betaChecker/index.android.js index b647ac5fc667..3b38f37bcb52 100644 --- a/src/libs/Environment/betaChecker/index.android.js +++ b/src/libs/Environment/betaChecker/index.android.js @@ -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(() => {