JAL-4001 Only send defaultParams for application_launch event
[jalview.git] / src / jalview / analytics / GoogleAnalytics4.java
index f7dd779..031cfc2 100644 (file)
@@ -91,6 +91,11 @@ public class GoogleAnalytics4
     ENABLED = b;
   }
 
+  public void sendAnalytics(String eventName, String... paramsStrings)
+  {
+    sendAnalytics(eventName, false, paramsStrings);
+  }
+
   /**
    * The simplest way to send an analytic event.
    * 
@@ -98,13 +103,16 @@ public class GoogleAnalytics4
    *          The event name. To emulate a webpage view use "page_view" and set
    *          a "page_location" parameter. See
    *          https://developers.google.com/analytics/devguides/collection/ga4/events?client_type=gtag
+   * @param sendDefaultParams
+   *          Flag whether to add the default params about the application.
    * @param paramsStrings
    *          Optional multiple Strings in key, value pairs (there should be an
    *          even number of paramsStrings) to be set as parameters of the
    *          event. To emulate a webpage view use "page_location" as the URL in
    *          a "page_view" event.
    */
-  public void sendAnalytics(String eventName, String... paramsStrings)
+  public void sendAnalytics(String eventName, boolean sendDefaultParams,
+          String... paramsStrings)
   {
     // clear out old lists
     this.resetLists();
@@ -117,7 +125,10 @@ public class GoogleAnalytics4
     Map<String, String> params = new HashMap<>();
 
     // add these to all events from this application instance
-    params.putAll(defaultParams);
+    if (sendDefaultParams)
+    {
+      params.putAll(defaultParams);
+    }
 
     // add (and overwrite with) the passed in params
     if (paramsStrings != null && paramsStrings.length > 0)