JAL-4001 Added more params for application_launch
authorBen Soares <b.soares@dundee.ac.uk>
Wed, 7 Jun 2023 14:37:22 +0000 (15:37 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Wed, 7 Jun 2023 14:37:22 +0000 (15:37 +0100)
src/jalview/analytics/GoogleAnalytics4.java

index 16f7654..5ae9c12 100644 (file)
@@ -49,15 +49,36 @@ public class GoogleAnalytics4
 
   private static GoogleAnalytics4 instance = null;
 
-  private static final String appName;
-
-  private static final String version;
+  private static final Map<String, String> defaultParams;
 
   static
   {
-    appName = ChannelProperties.getProperty("app_name") + " Desktop";
-    version = Cache.getProperty("VERSION") + "_"
-            + Cache.getDefault("BUILD_DATE", "unknown");
+    defaultParams = new HashMap<>();
+    defaultParams.put("app_name",
+            ChannelProperties.getProperty("app_name") + " Desktop");
+    defaultParams.put("version", Cache.getProperty("VERSION"));
+    defaultParams.put("build_date",
+            Cache.getDefault("BUILD_DATE", "unknown"));
+    defaultParams.put("java_version", System.getProperty("java.version"));
+    String val = System.getProperty("sys.install4jVersion");
+    if (val != null)
+    {
+      defaultParams.put("install4j_version", val);
+    }
+    val = System.getProperty("installer_template_version");
+    if (val != null)
+    {
+      defaultParams.put("install4j_template_version", val);
+    }
+    val = System.getProperty("launcher_version");
+    if (val != null)
+    {
+      defaultParams.put("launcher_version", val);
+    }
+    defaultParams.put("java_arch",
+            System.getProperty("os.arch") + " "
+                    + System.getProperty("os.name") + " "
+                    + System.getProperty("os.version"));
   }
 
   private GoogleAnalytics4()
@@ -83,10 +104,9 @@ public class GoogleAnalytics4
     Map<String, String> params = new HashMap<>();
 
     // add these to all events from this application instance
-    params.put("app_name", appName);
-    params.put("version", version);
+    params.putAll(defaultParams);
 
-    // can be overwritten by passed in params
+    // add (and overwrite with) the passed in params
     if (paramsStrings != null && paramsStrings.length > 0)
     {
       if (paramsStrings.length % 2 != 0)