addEvent(eventName, params);
addQueryStringValue("measurement_id", MEASUREMENT_ID);
addQueryStringValue("api_secret", API_SECRET);
+ addQueryStringValue("_geo", "1");
addJsonValue("client_id", CLIENT_ID);
+ addJsonValue("_geo", 1);
addJsonValues("events", Event.toObjectList(events));
StringBuilder urlSb = new StringBuilder();
urlSb.append(BASE_URL);
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;
*/
public static void initGoogleTracker()
{
+ initGoogleTracker(false);
+ }
+
+ public static void initGoogleTracker(boolean headless)
+ {
GoogleAnalytics4.setEnabled(true);
String appName = ChannelProperties.getProperty("app_name") + " Desktop";
} 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);
+ if (headless)
+ {
+ pathParts.add("headless");
+ }
+ path = ("/" + String.join("/", pathParts)).replace(' ', '+');
/*
}
*/
// 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);
+ String[] params;
+ if (headless)
+ {
+ params = new String[] { "page_location", path, "page_title",
+ APPLICATION_STARTED, "headless", "true" };
+ }
+ else
+ {
+ params = new String[] { "page_location", path, "page_title",
+ APPLICATION_STARTED };
+ }
+ ga4.sendAnalytics("page_view", params);
// 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);
+ ga4.sendAnalytics("application_launch", true, params);
}
private static final String APPLICATION_STARTED = "Application Started.";
// Run Commands from cli
cmds = new Commands(argparser, headlessArg);
boolean commandsSuccess = cmds.argsWereParsed();
+
if (commandsSuccess)
{
if (headlessArg)
}
else
{
+ // record usage stats if in headless mode
+ if (Cache.getDefault("USAGESTATS", false))
+ {
+ Cache.initGoogleTracker(headlessArg);
+ }
Jalview.exit("Successfully completed commands in headless mode",
0);
}