Log app usage type daily.

This commit is contained in:
Johannes Mockenhaupt 2018-07-11 20:19:42 +02:00
parent 09a1d23bc8
commit 6302769652
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
3 changed files with 34 additions and 25 deletions

View file

@ -196,7 +196,6 @@ public class MainApp extends Application {
} }
NSUpload.uploadAppStart(); NSUpload.uploadAppStart();
FabricPrivacy.logAppStart();
final PumpInterface pump = ConfigBuilderPlugin.getActivePump(); final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
if (pump != null) { if (pump != null) {

View file

@ -46,7 +46,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
LocalAlertUtils.shortenSnoozeInterval(); LocalAlertUtils.shortenSnoozeInterval();
LocalAlertUtils.checkStaleBGAlert(); LocalAlertUtils.checkStaleBGAlert();
checkPump(); checkPump();
FabricPrivacy.reportPluginStats(); FabricPrivacy.uploadDailyStats();
log.debug("KeepAlive received"); log.debug("KeepAlive received");
wl.release(); wl.release();

View file

@ -87,21 +87,7 @@ public class FabricPrivacy {
} }
} }
public static void logAppStart() { public static void uploadDailyStats() {
if (Config.NSCLIENT)
getInstance().logCustom(new CustomEvent("AppStart-NSClient"));
else if (Config.G5UPLOADER)
getInstance().logCustom(new CustomEvent("AppStart-G5Uploader"));
else if (Config.PUMPCONTROL)
getInstance().logCustom(new CustomEvent("AppStart-PumpControl"));
else if (MainApp.getConstraintChecker().isClosedLoopAllowed().value())
getInstance().logCustom(new CustomEvent("AppStart-ClosedLoop"));
else
getInstance().logCustom(new CustomEvent("AppStart-OpenLoop"));
}
public static void reportPluginStats() {
if (!fabricEnabled()) return; if (!fabricEnabled()) return;
long lastUploadDay = SP.getLong(MainApp.gs(R.string.key_plugin_stats_report_timestamp), 0L); long lastUploadDay = SP.getLong(MainApp.gs(R.string.key_plugin_stats_report_timestamp), 0L);
@ -113,6 +99,14 @@ public class FabricPrivacy {
long today = date.getTime() - date.getTime() % 1000; long today = date.getTime() - date.getTime() % 1000;
if (today > lastUploadDay) { if (today > lastUploadDay) {
uploadAppUsageType();
uploadPluginStats();
SP.putLong(MainApp.gs(R.string.key_plugin_stats_report_timestamp), today);
}
}
private static void uploadPluginStats() {
CustomEvent pluginStats = new CustomEvent("PluginStats"); CustomEvent pluginStats = new CustomEvent("PluginStats");
pluginStats.putCustomAttribute("version", BuildConfig.VERSION); pluginStats.putCustomAttribute("version", BuildConfig.VERSION);
for (PluginBase plugin : MainApp.getPluginsList()) { for (PluginBase plugin : MainApp.getPluginsList()) {
@ -120,8 +114,24 @@ public class FabricPrivacy {
pluginStats.putCustomAttribute(plugin.getName(), "enabled"); pluginStats.putCustomAttribute(plugin.getName(), "enabled");
} }
} }
FabricPrivacy.getInstance().logCustom(pluginStats);
SP.putLong(MainApp.gs(R.string.key_plugin_stats_report_timestamp), today); getInstance().logCustom(pluginStats);
} }
private static void uploadAppUsageType() {
CustomEvent type = new CustomEvent("AppUsageType");
if (Config.NSCLIENT)
type.putCustomAttribute("type", "NSClient");
else if (Config.G5UPLOADER)
type.putCustomAttribute("type", "G5Uploader");
else if (Config.PUMPCONTROL)
type.putCustomAttribute("type", "PumpControl");
else if (MainApp.getConstraintChecker().isClosedLoopAllowed().value())
type.putCustomAttribute("type", "ClosedLoop");
else
type.putCustomAttribute("type", "OpenLoop");
getInstance().logCustom(type);
} }
} }