From 96355c16c55303f63cf1d60a605cc21bb90850b4 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Mon, 5 Jun 2023 11:30:39 +0100 Subject: [PATCH] JAL-4001 start of GA4 client class --- src/jalview/analytics/GoogleAnalytics4.java | 78 +++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/jalview/analytics/GoogleAnalytics4.java diff --git a/src/jalview/analytics/GoogleAnalytics4.java b/src/jalview/analytics/GoogleAnalytics4.java new file mode 100644 index 0000000..6b9f03a --- /dev/null +++ b/src/jalview/analytics/GoogleAnalytics4.java @@ -0,0 +1,78 @@ +package jalview.analytics; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Random; + +public class GoogleAnalytics4 { + private static final String JALVIEW_ID = "Jalview Desktop"; + private static final String SESSION_ID = new Random().toString(); + private static final String MEASUREMENT_ID = "G-6TMPHMXEQ0"; + private static final String BASE_URL = "https://www.google-analytics.com/mp/collect"; + + private List> queryStringValues; + private List> jsonValues; + private List> cookies; + + private void addToJson(String key, List values) { + } + + private void addToJson(String key, String value) { + } + + private void addToJson(String key, int value) { + } + + private void addToJson(String key, boolean value) { + } + + private void addToJson(String key, Object[] array) { + } + + private void addQueryStringValue(String key, String value) { + } + + private void reset() { + jsonValues = new ArrayList<>(); + queryStringValues = new ArrayList<>(); + cookies = new ArrayList<>(); + } + + private String buildJson() { + StringBuilder sb = new StringBuilder(); + int indent = 0; + sb.append("{"); + indent++; + + sb.append("}"); + return sb.toString(); + } + + private void addJsonObject(StringBuilder sb, int indent, String key, Object value) { + indent(sb, indent); + sb.append('"').append(key).append('"'); + sb.append(": "); + if (List.class.equals(value.getClass())) { + sb.append('\n'); + } + addJsonValue(sb, indent, value); + sb.append(",\n"); + } + + private void addJsonValue(StringBuilder sb, int indent, Object value) { + if (value == null) { + return; + } + Class c = value.getClass(); + if (String.class.equals(c)) { + } else if (Integer.class.equals(c)) { + } else if (Boolean.class.equals(c)) { + } + sb.append(value); + } + + private void indent(StringBuilder sb, int indent) { + sb.append(" ".repeat(indent)); + } +} -- 1.7.10.2