Skip to content

Commit

Permalink
fix: add status code check to response handlers (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyang1520 authored Feb 8, 2023
1 parent 19f6f5d commit af9f4f1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/main/java/com/amplitude/api/AmplitudeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2271,7 +2271,7 @@ protected void makeEventUploadPostRequest(Call.Factory client, String events, fi
try {
Response response = client.newCall(request).execute();
String stringResponse = response.body().string();
if (response.code() == 200 || stringResponse.equals("success")) {
if (response.code() == 200) {
uploadSuccess = true;
logThread.post(new Runnable() {
@Override
Expand All @@ -2293,14 +2293,11 @@ public void run() {
}
}
});
} else if (stringResponse.equals("invalid_api_key")) {
} else if (response.code() == 400 && stringResponse.equals("invalid_api_key")) {
logger.e(TAG, "Invalid API key, make sure your API key is correct in initialize()");
} else if (stringResponse.equals("bad_checksum")) {
} else if (response.code() == 400 && stringResponse.equals("bad_checksum")) {
logger.w(TAG,
"Bad checksum, post request was mangled in transit, will attempt to reupload later");
} else if (stringResponse.equals("request_db_write_failed")) {
logger.w(TAG,
"Couldn't write to request database on server, will attempt to reupload later");
} else if (response.code() == 413) {

// If blocked by one massive event, drop it
Expand Down

0 comments on commit af9f4f1

Please sign in to comment.