Skip to content

Commit

Permalink
Add debug logs for success/fail
Browse files Browse the repository at this point in the history
  • Loading branch information
WalshyDev committed Dec 25, 2023
1 parent 3a5e9dc commit 48fdd39
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ private void send(String id, double[] doubles, String[] blobs) {
if (!enabled) return;

JsonObject object = new JsonObject();
object.addProperty("index", id);
// Up to 1 index
JsonArray indexes = new JsonArray();
indexes.add(id);
object.add("indexes", indexes);

// Up to 20 doubles (including the version)
JsonArray doublesArray = new JsonArray();
doublesArray.add(VERSION);
if (doubles != null) {
Expand All @@ -86,6 +90,7 @@ private void send(String id, double[] doubles, String[] blobs) {
}
object.add("doubles", doublesArray);

// Up to 20 blobs
JsonArray blobsArray = new JsonArray();
if (blobs != null) {
for (String s : blobs) {
Expand All @@ -101,6 +106,14 @@ private void send(String id, double[] doubles, String[] blobs) {
client.sendAsync(HttpRequest.newBuilder()
.uri(URI.create(API_URL))
.POST(HttpRequest.BodyPublishers.ofString(object.toString()))
.build(), HttpResponse.BodyHandlers.discarding());
.build(),
HttpResponse.BodyHandlers.discarding()
).thenAcceptAsync((res) -> {
if (res.statusCode() == 200) {
Debug.log(TestCase.ANALYTICS, "Analytics data for " + id + " sent successfully");
} else {
Debug.log(TestCase.ANALYTICS, "Analytics data for " + id + " failed to send - " + res.statusCode());
}
});
}
}

0 comments on commit 48fdd39

Please sign in to comment.