mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
report java version and os to google analytics when checking for a new version of ipscan - github.io doesn't provide any logging
This commit is contained in:
parent
fc690f2b9c
commit
d5fc959426
@ -32,6 +32,8 @@ public class Version {
|
||||
public static final String DOWNLOAD_URL = WEBSITE + "/download/";
|
||||
|
||||
public static final String LATEST_VERSION_URL = WEBSITE + "/ipscan/IPSCAN.VERSION";
|
||||
|
||||
public static final String GA_ID = "UA-10776159-2";
|
||||
|
||||
private static String version;
|
||||
private static String buildDate;
|
||||
|
||||
@ -12,6 +12,7 @@ import net.azib.ipscan.gui.AboutDialog;
|
||||
import net.azib.ipscan.gui.GettingStartedDialog;
|
||||
import net.azib.ipscan.gui.InfoDialog;
|
||||
import net.azib.ipscan.gui.StatusBar;
|
||||
import net.azib.ipscan.util.GoogleAnalytics;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
@ -111,7 +112,10 @@ public class HelpMenuActions {
|
||||
|
||||
public void check() {
|
||||
statusBar.setStatusText(Labels.getLabel("state.retrievingVersion"));
|
||||
|
||||
|
||||
new GoogleAnalytics().asyncReport(Version.getVersion() + " jvm " + System.getProperty("java.runtime.version") + " " +
|
||||
System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch"));
|
||||
|
||||
Runnable checkVersionCode = new Runnable() {
|
||||
public void run() {
|
||||
BufferedReader reader = null;
|
||||
|
||||
44
src/net/azib/ipscan/util/GoogleAnalytics.java
Normal file
44
src/net/azib/ipscan/util/GoogleAnalytics.java
Normal file
@ -0,0 +1,44 @@
|
||||
package net.azib.ipscan.util;
|
||||
|
||||
import net.azib.ipscan.config.Config;
|
||||
import net.azib.ipscan.config.Version;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
public class GoogleAnalytics {
|
||||
public void report(String screen) {
|
||||
try {
|
||||
URL url = new URL("https://www.google-analytics.com/collect");
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||
conn.setDoOutput(true);
|
||||
OutputStream os = conn.getOutputStream();
|
||||
String payload = "v=1&t=screenview&tid=" + Version.GA_ID + "&cid=" + UUID.randomUUID() + "&an=ipscan&cd=" + URLEncoder.encode(screen, "UTF-8") + "&ul=" + Config.getConfig().getLocale();
|
||||
os.write(payload.getBytes());
|
||||
os.close();
|
||||
conn.getContent();
|
||||
conn.disconnect();
|
||||
}
|
||||
catch (IOException e) {
|
||||
Logger.getLogger(getClass().getName()).log(WARNING, "Failed to report", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void asyncReport(final String screen) {
|
||||
new Thread() {
|
||||
@Override public void run() {
|
||||
report(screen);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user