Merge branch 'hardcode'
[jalview.git] / src / jalview / bin / Cache.java
index 4e73b82..5741908 100755 (executable)
@@ -53,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;
@@ -129,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>
@@ -955,16 +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()
   {
-    initGoogleTracker(false);
-  }
-
-  public static void initGoogleTracker(boolean headless)
-  {
-    GoogleAnalytics4.setEnabled(true);
+    Plausible.setEnabled(true);
 
     String appName = ChannelProperties.getProperty("app_name") + " Desktop";
     String version = Cache.getProperty("VERSION") + "_"
@@ -983,39 +978,18 @@ public class Cache
     pathParts.add(appName);
     pathParts.add(version);
     pathParts.add(APPLICATION_STARTED);
-    if (headless)
-    {
-      pathParts.add("headless");
-    }
     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.
-    String[] params;
-    if (headless)
-    {
-      params = new String[] { "page_location",
-          GoogleAnalytics4.APPLICATION_BASE_URL + path, "page_title",
-          APPLICATION_STARTED, "headless", "true" };
-    }
-    else
-    {
-      params = new String[] { "page_location", path, "page_title",
-          APPLICATION_STARTED };
-    }
-    ga4.sendAnalytics("page_view", params);
+    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, params);
+    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