JAL-4001 debugging statements
authorBen Soares <b.soares@dundee.ac.uk>
Mon, 5 Jun 2023 19:26:42 +0000 (20:26 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Mon, 5 Jun 2023 19:26:42 +0000 (20:26 +0100)
src/jalview/analytics/GoogleAnalytics4.java

index bf6f3f3..3997543 100644 (file)
@@ -74,19 +74,24 @@ public class GoogleAnalytics4
     addJsonValue("client_id", CLIENT_ID);
     addJsonValues("events", Event.toObjectList(events));
     // addJsonValue("events", )
-    StringBuilder sb = new StringBuilder();
-    sb.append(BASE_URL);
-    sb.append('?');
-    sb.append(buildQueryString());
+    StringBuilder urlSb = new StringBuilder();
+    urlSb.append(BASE_URL);
+    urlSb.append('?');
+    urlSb.append(buildQueryString());
     try
     {
-      URL url = new URL(sb.toString());
+      URL url = new URL(urlSb.toString());
       URLConnection urlConnection = url.openConnection();
       HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
       httpURLConnection.setRequestMethod("POST");
       httpURLConnection.setDoOutput(true);
 
-      byte[] jsonBytes = buildJson().getBytes(StandardCharsets.UTF_8);
+      String jsonString = buildJson();
+
+      Console.debug("##### HTTP Request is: '" + urlSb.toString() + "'");
+      Console.debug("##### POSTed JSON is:\n" + jsonString);
+
+      byte[] jsonBytes = jsonString.getBytes(StandardCharsets.UTF_8);
       int jsonLength = jsonBytes.length;
 
       httpURLConnection.setFixedLengthStreamingMode(jsonLength);