From 7f2fffff9499545aff4f6189455b21ce1fa50501 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Mon, 5 Jun 2023 20:26:42 +0100 Subject: [PATCH] JAL-4001 debugging statements --- src/jalview/analytics/GoogleAnalytics4.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/jalview/analytics/GoogleAnalytics4.java b/src/jalview/analytics/GoogleAnalytics4.java index bf6f3f3..3997543 100644 --- a/src/jalview/analytics/GoogleAnalytics4.java +++ b/src/jalview/analytics/GoogleAnalytics4.java @@ -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); -- 1.7.10.2