From f7719ccd866b51a205c5c5ec2c6df80a46c3d640 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 30 Oct 2011 10:36:40 +0000 Subject: [PATCH] * track scripting usage count --- source/net/sourceforge/filebot/Analytics.java | 17 +++++++++++++---- .../filebot/cli/ArgumentProcessor.java | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/source/net/sourceforge/filebot/Analytics.java b/source/net/sourceforge/filebot/Analytics.java index 877608c9..2370666c 100644 --- a/source/net/sourceforge/filebot/Analytics.java +++ b/source/net/sourceforge/filebot/Analytics.java @@ -26,10 +26,12 @@ public class Analytics { private static final String TIMESTAMP_LAST = "timestampLast"; private static final String VISITS = "visits"; - private static final String host = "filebot.sourceforge.net"; private static final VisitorData visitorData = restoreVisitorData(); private static final JGoogleAnalyticsTracker tracker = new JGoogleAnalyticsTracker(getConfig(getApplicationProperty("analytics.WebPropertyID"), visitorData), V_4_7_2); + private static final String host = "filebot.sourceforge.net"; + private static String currentView = null; + public static void trackView(Class view, String title) { trackView(view.getName().replace('.', '/'), title); @@ -40,8 +42,15 @@ public class Analytics { if (!tracker.isEnabled()) return; - // track application startup - tracker.trackPageViewFromSearch(view, title, host, getJavaVersionIdentifier(), getDeploymentMethod()); + if (currentView == null) { + // track application startup + tracker.trackPageViewFromSearch(view, title, host, getJavaVersionIdentifier(), getDeploymentMethod()); + } else { + // track application state change + tracker.trackPageViewFromReferrer(view, title, host, host, currentView); + } + + currentView = view; } @@ -211,7 +220,7 @@ public class Analytics { /** - * Dummy constructor to prevent instantiation. + * Dummy constructor to prevent instantiation */ private Analytics() { throw new UnsupportedOperationException(); diff --git a/source/net/sourceforge/filebot/cli/ArgumentProcessor.java b/source/net/sourceforge/filebot/cli/ArgumentProcessor.java index 6b2d1363..196f9a49 100644 --- a/source/net/sourceforge/filebot/cli/ArgumentProcessor.java +++ b/source/net/sourceforge/filebot/cli/ArgumentProcessor.java @@ -79,6 +79,7 @@ public class ArgumentProcessor { Bindings bindings = new SimpleBindings(); bindings.put("args", args.getFiles(false)); + Analytics.trackEvent("CLI", "ExecuteScript", args.getScriptLocation().getProtocol()); ScriptShell shell = new ScriptShell(cli, args, AccessController.getContext()); shell.evaluate(script, bindings); }