Merge branch 'hardcode'
[jalview.git] / src / jalview / bin / Cache.java
index 8015cd5..5741908 100755 (executable)
@@ -43,6 +43,7 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
@@ -52,7 +53,7 @@ import java.util.TreeSet;
 import javax.swing.LookAndFeel;
 import javax.swing.UIManager;
 
-import jalview.analytics.GoogleAnalytics4;
+import jalview.analytics.Plausible;
 import jalview.datamodel.PDBEntry;
 import jalview.gui.Preferences;
 import jalview.gui.UserDefinedColours;
@@ -128,7 +129,7 @@ import jalview.ws.sifts.SiftsSettings;
  * service</li>
  * <li>QUESTIONNAIRE last questionnaire:responder id string from questionnaire
  * service</li>
- * <li>USAGESTATS (false - user prompted) Enable google analytics tracker for
+ * <li>USAGESTATS (false - user prompted) Enable analytics tracker for
  * collecting usage statistics</li>
  * <li>SHOW_OVERVIEW boolean for overview window display</li>
  * <li>ANTI_ALIAS boolean for smooth fonts</li>
@@ -954,11 +955,11 @@ public class Cache
   }
 
   /**
-   * Initialise the google tracker if it is not done already.
+   * Initialise the tracker if it is not done already.
    */
-  public static void initGoogleTracker()
+  public static void initAnalytics()
   {
-    GoogleAnalytics4.setEnabled(true);
+    Plausible.setEnabled(true);
 
     String appName = ChannelProperties.getProperty("app_name") + " Desktop";
     String version = Cache.getProperty("VERSION") + "_"
@@ -973,25 +974,22 @@ public class Cache
     } catch (UnsupportedEncodingException e)
     {
     */
-    path = ("/" + String.join("/", appName, version, APPLICATION_STARTED))
-            .replace(' ', '+');
+    List<String> pathParts = new ArrayList<>();
+    pathParts.add(appName);
+    pathParts.add(version);
+    pathParts.add(APPLICATION_STARTED);
+    path = ("/" + String.join("/", pathParts)).replace(' ', '+');
     /*
     }
     */
-    GoogleAnalytics4 ga4 = GoogleAnalytics4.getInstance();
-
-    // This will add a page_view similar to the old UA analytics.
-    // We probably want to get rid of this once the application_launch event
-    // is being processed properly.
-    ga4.sendAnalytics("page_view", "page_location", path, "page_title",
-            APPLICATION_STARTED);
+    Plausible plausible = Plausible.getInstance();
 
     // This will send a new "application_launch" event with parameters
     // including the old-style "path", the channel name and version
-    ga4.sendAnalytics("application_launch", true, "page_location", path);
+    plausible.sendEvent("application_launch", path, true);
   }
 
-  private static final String APPLICATION_STARTED = "Application Started.";
+  private static final String APPLICATION_STARTED = "Application Started";
 
   /**
    * get the user's default colour if available