From 32b2d35e0cc90e413f071cbdec0f3064b2e79660 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 9 Apr 2012 13:38:23 +0000 Subject: [PATCH] * turn off annoying gat background logging --- source/net/sourceforge/filebot/Analytics.java | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/source/net/sourceforge/filebot/Analytics.java b/source/net/sourceforge/filebot/Analytics.java index 7722b107..34ffe7d5 100644 --- a/source/net/sourceforge/filebot/Analytics.java +++ b/source/net/sourceforge/filebot/Analytics.java @@ -28,11 +28,14 @@ public class Analytics { private static boolean enabled = false; - + public static synchronized JGoogleAnalyticsTracker getTracker() { if (tracker != null) return tracker; + // disable useless background logging + Logger.getLogger(JGoogleAnalyticsTracker.class.getName()).setLevel(Level.OFF); + // initialize tracker visitorData = restoreVisitorData(); tracker = new JGoogleAnalyticsTracker(getConfig(getApplicationProperty("analytics.WebPropertyID"), visitorData), V_4_7_2); @@ -50,12 +53,12 @@ public class Analytics { return tracker; } - + public static void trackView(Class view, String title) { trackView(view.getName().replace('.', '/'), title); } - + public static synchronized void trackView(String view, String title) { if (!enabled) return; @@ -71,12 +74,12 @@ public class Analytics { currentView = view; } - + public static void trackEvent(String category, String action, String label) { trackEvent(category, action, label, null); } - + public static synchronized void trackEvent(String category, String action, String label, Integer value) { if (!enabled) return; @@ -84,7 +87,7 @@ public class Analytics { getTracker().trackEvent(normalize(category), normalize(action), normalize(label), value); } - + private static String normalize(String label) { if (label == null) return null; @@ -93,17 +96,17 @@ public class Analytics { return label.replaceAll("[*()]", "").trim(); } - + public static synchronized void setEnabled(boolean b) { enabled = b; } - + private static String getDeploymentMethod() { return getApplicationDeployment() == null ? "fatjar" : getApplicationDeployment(); } - + private static AnalyticsConfigData getConfig(String webPropertyID, VisitorData visitorData) { AnalyticsConfigData config = new AnalyticsConfigData(webPropertyID, visitorData); @@ -130,7 +133,7 @@ public class Analytics { return config; } - + private static String getUserAgent() { String wm = null; String os = null; @@ -159,7 +162,7 @@ public class Analytics { return String.format("%s/%s (%s; U; %s; JRE %s)", getApplicationName(), getApplicationVersion(), wm, os, System.getProperty("java.version")); } - + private static String getUserLanguage() { String language = System.getProperty("user.language"); @@ -175,7 +178,7 @@ public class Analytics { return language + "-" + region; } - + private static String getScreenResolution(GraphicsDevice[] display) { int screenHeight = 0; int screenWidth = 0; @@ -190,7 +193,7 @@ public class Analytics { return screenWidth + "x" + screenHeight; } - + private static String getColorDepth(GraphicsDevice[] display) { StringBuilder sb = new StringBuilder(); @@ -205,13 +208,13 @@ public class Analytics { return sb.toString(); } - + private static final String VISITOR_ID = "visitorId"; private static final String TIMESTAMP_FIRST = "timestampFirst"; private static final String TIMESTAMP_LAST = "timestampLast"; private static final String VISITS = "visits"; - + private synchronized static VisitorData restoreVisitorData() { try { // try to restore visitor @@ -228,7 +231,7 @@ public class Analytics { } } - + private synchronized static void storeVisitorData(VisitorData visitor) { Map data = getPersistentData(); data.put(VISITOR_ID, String.valueOf(visitor.getVisitorId())); @@ -237,12 +240,12 @@ public class Analytics { data.put(VISITS, String.valueOf(visitor.getVisits())); } - + private static Map getPersistentData() { return Settings.forPackage(Analytics.class).node("analytics").asMap(); } - + /** * Dummy constructor to prevent instantiation */