mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
it seems that GA cannot parse custom User-Agent, so send OS and Java version as custom dimensions
This commit is contained in:
parent
9959155b46
commit
d2aa614736
@ -24,12 +24,14 @@ public class GoogleAnalytics {
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||
conn.setRequestProperty("User-Agent", "Java/" + System.getProperty("java.version") + "-" + System.getProperty("os.name") + "-" + System.getProperty("os.version") + "-" + System.getProperty("os.arch"));
|
||||
conn.setDoOutput(true);
|
||||
OutputStream os = conn.getOutputStream();
|
||||
String contentParam = "exception".equals(type) ? "exd" : "cd";
|
||||
String payload = "v=1&t=" + type + "&tid=" + Version.GA_ID + "&cid=" + config.getUUID() + "&an=ipscan&av=" + Version.getVersion() + "&" +
|
||||
contentParam + "=" + URLEncoder.encode(content, "UTF-8") + "&ul=" + config.getLocale();
|
||||
String payload = "v=1&t=" + type + "&tid=" + Version.GA_ID + "&cid=" + config.getUUID() + "&an=ipscan&av=" + Version.getVersion() +
|
||||
"&" + contentParam + "=" + URLEncoder.encode(content, "UTF-8") +
|
||||
"&ul=" + config.getLocale() +
|
||||
"&cd1=" + URLEncoder.encode(System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch"), "UTF-8") +
|
||||
"&cd2=" + URLEncoder.encode("Java " + System.getProperty("java.version"), "UTF-8");
|
||||
os.write(payload.getBytes());
|
||||
os.close();
|
||||
conn.getContent();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user