mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-04 08:25:03 -05:00
* turn off annoying gat background logging
This commit is contained in:
parent
a295f24645
commit
32b2d35e0c
@ -28,11 +28,14 @@ public class Analytics {
|
|||||||
|
|
||||||
private static boolean enabled = false;
|
private static boolean enabled = false;
|
||||||
|
|
||||||
|
|
||||||
public static synchronized JGoogleAnalyticsTracker getTracker() {
|
public static synchronized JGoogleAnalyticsTracker getTracker() {
|
||||||
if (tracker != null)
|
if (tracker != null)
|
||||||
return tracker;
|
return tracker;
|
||||||
|
|
||||||
|
// disable useless background logging
|
||||||
|
Logger.getLogger(JGoogleAnalyticsTracker.class.getName()).setLevel(Level.OFF);
|
||||||
|
|
||||||
// initialize tracker
|
// initialize tracker
|
||||||
visitorData = restoreVisitorData();
|
visitorData = restoreVisitorData();
|
||||||
tracker = new JGoogleAnalyticsTracker(getConfig(getApplicationProperty("analytics.WebPropertyID"), visitorData), V_4_7_2);
|
tracker = new JGoogleAnalyticsTracker(getConfig(getApplicationProperty("analytics.WebPropertyID"), visitorData), V_4_7_2);
|
||||||
@ -50,12 +53,12 @@ public class Analytics {
|
|||||||
return tracker;
|
return tracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void trackView(Class<?> view, String title) {
|
public static void trackView(Class<?> view, String title) {
|
||||||
trackView(view.getName().replace('.', '/'), title);
|
trackView(view.getName().replace('.', '/'), title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static synchronized void trackView(String view, String title) {
|
public static synchronized void trackView(String view, String title) {
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
return;
|
return;
|
||||||
@ -71,12 +74,12 @@ public class Analytics {
|
|||||||
currentView = view;
|
currentView = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void trackEvent(String category, String action, String label) {
|
public static void trackEvent(String category, String action, String label) {
|
||||||
trackEvent(category, action, label, null);
|
trackEvent(category, action, label, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static synchronized void trackEvent(String category, String action, String label, Integer value) {
|
public static synchronized void trackEvent(String category, String action, String label, Integer value) {
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
return;
|
return;
|
||||||
@ -84,7 +87,7 @@ public class Analytics {
|
|||||||
getTracker().trackEvent(normalize(category), normalize(action), normalize(label), value);
|
getTracker().trackEvent(normalize(category), normalize(action), normalize(label), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String normalize(String label) {
|
private static String normalize(String label) {
|
||||||
if (label == null)
|
if (label == null)
|
||||||
return null;
|
return null;
|
||||||
@ -93,17 +96,17 @@ public class Analytics {
|
|||||||
return label.replaceAll("[*()]", "").trim();
|
return label.replaceAll("[*()]", "").trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static synchronized void setEnabled(boolean b) {
|
public static synchronized void setEnabled(boolean b) {
|
||||||
enabled = b;
|
enabled = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getDeploymentMethod() {
|
private static String getDeploymentMethod() {
|
||||||
return getApplicationDeployment() == null ? "fatjar" : getApplicationDeployment();
|
return getApplicationDeployment() == null ? "fatjar" : getApplicationDeployment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static AnalyticsConfigData getConfig(String webPropertyID, VisitorData visitorData) {
|
private static AnalyticsConfigData getConfig(String webPropertyID, VisitorData visitorData) {
|
||||||
AnalyticsConfigData config = new AnalyticsConfigData(webPropertyID, visitorData);
|
AnalyticsConfigData config = new AnalyticsConfigData(webPropertyID, visitorData);
|
||||||
|
|
||||||
@ -130,7 +133,7 @@ public class Analytics {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getUserAgent() {
|
private static String getUserAgent() {
|
||||||
String wm = null;
|
String wm = null;
|
||||||
String os = 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"));
|
return String.format("%s/%s (%s; U; %s; JRE %s)", getApplicationName(), getApplicationVersion(), wm, os, System.getProperty("java.version"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getUserLanguage() {
|
private static String getUserLanguage() {
|
||||||
String language = System.getProperty("user.language");
|
String language = System.getProperty("user.language");
|
||||||
|
|
||||||
@ -175,7 +178,7 @@ public class Analytics {
|
|||||||
return language + "-" + region;
|
return language + "-" + region;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getScreenResolution(GraphicsDevice[] display) {
|
private static String getScreenResolution(GraphicsDevice[] display) {
|
||||||
int screenHeight = 0;
|
int screenHeight = 0;
|
||||||
int screenWidth = 0;
|
int screenWidth = 0;
|
||||||
@ -190,7 +193,7 @@ public class Analytics {
|
|||||||
return screenWidth + "x" + screenHeight;
|
return screenWidth + "x" + screenHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getColorDepth(GraphicsDevice[] display) {
|
private static String getColorDepth(GraphicsDevice[] display) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
@ -205,13 +208,13 @@ public class Analytics {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final String VISITOR_ID = "visitorId";
|
private static final String VISITOR_ID = "visitorId";
|
||||||
private static final String TIMESTAMP_FIRST = "timestampFirst";
|
private static final String TIMESTAMP_FIRST = "timestampFirst";
|
||||||
private static final String TIMESTAMP_LAST = "timestampLast";
|
private static final String TIMESTAMP_LAST = "timestampLast";
|
||||||
private static final String VISITS = "visits";
|
private static final String VISITS = "visits";
|
||||||
|
|
||||||
|
|
||||||
private synchronized static VisitorData restoreVisitorData() {
|
private synchronized static VisitorData restoreVisitorData() {
|
||||||
try {
|
try {
|
||||||
// try to restore visitor
|
// try to restore visitor
|
||||||
@ -228,7 +231,7 @@ public class Analytics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private synchronized static void storeVisitorData(VisitorData visitor) {
|
private synchronized static void storeVisitorData(VisitorData visitor) {
|
||||||
Map<String, String> data = getPersistentData();
|
Map<String, String> data = getPersistentData();
|
||||||
data.put(VISITOR_ID, String.valueOf(visitor.getVisitorId()));
|
data.put(VISITOR_ID, String.valueOf(visitor.getVisitorId()));
|
||||||
@ -237,12 +240,12 @@ public class Analytics {
|
|||||||
data.put(VISITS, String.valueOf(visitor.getVisits()));
|
data.put(VISITS, String.valueOf(visitor.getVisits()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static Map<String, String> getPersistentData() {
|
private static Map<String, String> getPersistentData() {
|
||||||
return Settings.forPackage(Analytics.class).node("analytics").asMap();
|
return Settings.forPackage(Analytics.class).node("analytics").asMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dummy constructor to prevent instantiation
|
* Dummy constructor to prevent instantiation
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user