From: Ben Soares Date: Thu, 8 Jun 2023 16:37:13 +0000 (+0100) Subject: JAL-4001 Only send defaultParams for application_launch event X-Git-Tag: Release_2_11_4_0~267 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=dc15acb6fdd00e6e7463cda8be6abba7490c098d;p=jalview.git JAL-4001 Only send defaultParams for application_launch event --- diff --git a/src/jalview/analytics/GoogleAnalytics4.java b/src/jalview/analytics/GoogleAnalytics4.java index f7dd779..031cfc2 100644 --- a/src/jalview/analytics/GoogleAnalytics4.java +++ b/src/jalview/analytics/GoogleAnalytics4.java @@ -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 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) diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 75166da..85bde58 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -990,7 +990,7 @@ public class Cache // This will send a new "application_launch" event with parameters // including the old-style "path", the channel name and version - ga4.sendAnalytics("application_launch", "page_location", path); + ga4.sendAnalytics("application_launch", true, "page_location", path); } else {