From dc15acb6fdd00e6e7463cda8be6abba7490c098d Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Thu, 8 Jun 2023 17:37:13 +0100 Subject: [PATCH] JAL-4001 Only send defaultParams for application_launch event --- src/jalview/analytics/GoogleAnalytics4.java | 15 +++++++++++++-- src/jalview/bin/Cache.java | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) 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 { -- 1.7.10.2