Added download elapsed time log

This commit is contained in:
crimean 2019-05-31 17:45:42 +03:00
parent ad0afbe188
commit a72727d93a
3 changed files with 20 additions and 2 deletions

View file

@ -34,6 +34,7 @@ public class AnalyticsHelper extends SQLiteOpenHelper {
private final static int DATA_PARCEL_SIZE = 500; // 500 events
private final static int SUBMIT_DATA_INTERVAL = 60 * 60 * 1000; // 1 hour
private final static String PARAM_OS = "os";
private final static String PARAM_START_DATE = "startDate";
private final static String PARAM_FINISH_DATE = "finishDate";
private final static String PARAM_FIRST_INSTALL_DAYS = "nd";
@ -153,6 +154,7 @@ public class AnalyticsHelper extends SQLiteOpenHelper {
}
Map<String, String> additionalData = new LinkedHashMap<String, String>();
additionalData.put(PARAM_OS, "android");
additionalData.put(PARAM_START_DATE, String.valueOf(d.startDate));
additionalData.put(PARAM_FINISH_DATE, String.valueOf(d.finishDate));
additionalData.put(PARAM_VERSION, Version.getFullVersion(ctx));

View file

@ -939,6 +939,16 @@ public class OsmandApplication extends MultiDexApplication {
}
}
public void logMapDownloadEvent(String event, IndexItem item, long time) {
try {
if (osmandSettings.SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.get()) {
analyticsHelper.addEvent("map_download_" + event + ": " + item.getFileName() + " in " + time + " msec");
}
} catch (Exception e) {
LOG.error(e);
}
}
public void restartApp(Context ctx) {
AlertDialog.Builder bld = new AlertDialog.Builder(ctx);
bld.setMessage(R.string.restart_is_required);

View file

@ -534,7 +534,6 @@ public class DownloadIndexesThread {
boolean result = downloadFile(item, filesToReindex, forceWifi);
success = result || success;
if (result) {
checkDownload(item);
if (DownloadActivityType.isCountedInDownloads(item)) {
downloads.set(downloads.get() + 1);
}
@ -664,8 +663,16 @@ public class DownloadIndexesThread {
LOG.error("Copy exception", e);
}
} else {
long start = System.currentTimeMillis();
app.logMapDownloadEvent("start", item);
res = downloadFileHelper.downloadFile(de, this, filesToReindex, this, forceWifi);
long time = System.currentTimeMillis() - start;
if (res) {
app.logMapDownloadEvent("done", item, time);
checkDownload(item);
} else {
app.logMapDownloadEvent("failed", item, time);
}
}
return res;
}
@ -678,7 +685,6 @@ public class DownloadIndexesThread {
}
private void checkDownload(IndexItem item) {
app.logMapDownloadEvent("done", item);
Map<String, String> params = new HashMap<>();
params.put("file_name", item.fileName);
params.put("file_size", item.size);