Add Device / Platform / App info to EventLogging

This commit is contained in:
YuviPanda 2013-02-20 19:22:23 +05:30
parent 1a860c6729
commit a89e2c8214
3 changed files with 21 additions and 2 deletions

View file

@ -58,8 +58,8 @@ public class CommonsApplication extends Application {
public static final String IMAGE_URL_BASE = "https://upload.wikimedia.org/wikipedia/test"; public static final String IMAGE_URL_BASE = "https://upload.wikimedia.org/wikipedia/test";
public static final String EVENTLOG_URL = "https://bits.wikimedia.org/event.gif"; public static final String EVENTLOG_URL = "https://bits.wikimedia.org/event.gif";
public static final Object[] EVENT_UPLOAD_ATTEMPT = {"MobileAppUploadAttempts", 5241449L}; public static final Object[] EVENT_UPLOAD_ATTEMPT = {"MobileAppUploadAttempts", 5257716L};
public static final Object[] EVENT_LOGIN_ATTEMPT = {"MobileAppLoginAttempts", 5254859L}; public static final Object[] EVENT_LOGIN_ATTEMPT = {"MobileAppLoginAttempts", 5257721L};
public static final String DEFAULT_EDIT_SUMMARY = "Uploaded using Android Commons app"; public static final String DEFAULT_EDIT_SUMMARY = "Uploaded using Android Commons app";

View file

@ -1,6 +1,8 @@
package org.wikimedia.commons; package org.wikimedia.commons;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.text.TextUtils;
import de.akquinet.android.androlog.Log; import de.akquinet.android.androlog.Log;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -43,6 +45,15 @@ public class EventLog {
} }
} }
private static final String DEVICE;
static {
if (Build.MODEL.startsWith(Build.MANUFACTURER)) {
DEVICE = Utils.capitalize(Build.MODEL);
} else {
DEVICE = Utils.capitalize(Build.MANUFACTURER) + " " + Build.MODEL;
}
}
public static class LogBuilder { public static class LogBuilder {
private JSONObject data; private JSONObject data;
private long rev; private long rev;
@ -69,6 +80,9 @@ public class EventLog {
fullData.put("schema", schema); fullData.put("schema", schema);
fullData.put("revision", rev); fullData.put("revision", rev);
fullData.put("wiki", "commonswiki"); fullData.put("wiki", "commonswiki");
data.put("device", DEVICE);
data.put("platform", "Android/" + Build.VERSION.RELEASE);
data.put("appversion", "Android/" + CommonsApplication.APPLICATION_VERSION);
fullData.put("event", data); fullData.put("event", data);
return new URL(CommonsApplication.EVENTLOG_URL + "?" + Utils.urlEncode(fullData.toString()) + ";"); return new URL(CommonsApplication.EVENTLOG_URL + "?" + Utils.urlEncode(fullData.toString()) + ";");
} catch (MalformedURLException e) { } catch (MalformedURLException e) {

View file

@ -121,4 +121,9 @@ public class Utils {
return thumbUrl + ".png"; return thumbUrl + ".png";
} }
} }
public static String capitalize(String string) {
return string.substring(0,1).toUpperCase() + string.substring(1);
}
} }