Skip to content

Commit

Permalink
Add request retry and fix url encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
appupgrade-dev committed Feb 3, 2023
1 parent 9ca78e3 commit 7fd3062
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes will be documented in this file.

## [1.0.10] - 2023-02-03

* Fix url encoding for app name.
* Added request retry for failed requests.

## [1.0.9] - 2023-01-16

* Fix localization backward compatibility.
Expand Down
29 changes: 28 additions & 1 deletion package-lock.json

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

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "app-upgrade-react-native-sdk",
"version": "1.0.9",
"description": "app upgrade react-native sdk",
"version": "1.0.10",
"description": "Official App Upgrade react-native sdk",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand All @@ -17,7 +17,8 @@
},
"license": "MIT",
"dependencies": {
"axios": "^0.27.2"
"axios": "^0.27.2",
"axios-retry": "^3.4.0"
},
"peerDependencies": {
"react": ">=16.9.0",
Expand Down
12 changes: 11 additions & 1 deletion src/api.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import axios from "axios";
import axiosRetry from 'axios-retry';

async function checkVersionWithAppUpgrade(appInfo, xApiKey) {
try {
const appUpgradeBaseUrl = "https://appupgrade.dev";
const { appName, appVersion, platform, environment, appLanguage } = appInfo;

axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay, retryCondition: () => true });

const response = await axios.get(
`${appUpgradeBaseUrl}/api/v1/versions/check?app_name=${appName}&app_version=${appVersion}&platform=${platform}&environment=${environment}&app_language=${appLanguage}`,
`${appUpgradeBaseUrl}/api/v1/versions/check`,
{
headers: {
"x-api-key": xApiKey,
"sdk": "react-native" //Telemetry purposes
},
params: {
app_name: appName,
app_version: appVersion,
platform: platform,
environment: environment,
app_language: appLanguage,
},
validateStatus: function (status) {
return status >= 200 && status < 500; // default
},
Expand Down

0 comments on commit 7fd3062

Please sign in to comment.