diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java
index 24631b10c8..dbb6ddee8b 100644
--- a/app/src/main/java/info/nightscout/androidaps/MainApp.java
+++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java
@@ -194,18 +194,8 @@ public class MainApp extends Application {
MainApp.getConfigBuilder().initialize();
}
- NSUpload.uploadAppStart();
- if (Config.NSCLIENT)
- FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-NSClient"));
- else if (Config.G5UPLOADER)
- FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-G5Uploader"));
- else if (Config.PUMPCONTROL)
- FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-PumpControl"));
- else if (MainApp.getConstraintChecker().isClosedLoopAllowed().value())
- FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-ClosedLoop"));
- else
- FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-OpenLoop"));
+ NSUpload.uploadAppStart();
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
if (pump != null) {
diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java
index af46321901..d574b08f40 100644
--- a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java
+++ b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java
@@ -1,9 +1,5 @@
package info.nightscout.androidaps.receivers;
-/**
- * Created by mike on 07.07.2016.
- */
-
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
@@ -11,6 +7,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
+import info.nightscout.utils.FabricPrivacy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -25,6 +22,10 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.queue.commands.Command;
import info.nightscout.utils.LocalAlertUtils;
+
+/**
+ * Created by mike on 07.07.2016.
+ */
public class KeepAliveReceiver extends BroadcastReceiver {
private static Logger log = LoggerFactory.getLogger(KeepAliveReceiver.class);
public static final long STATUS_UPDATE_FREQUENCY = 15 * 60 * 1000L;
@@ -45,6 +46,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
LocalAlertUtils.shortenSnoozeInterval();
LocalAlertUtils.checkStaleBGAlert();
checkPump();
+ FabricPrivacy.uploadDailyStats();
log.debug("KeepAlive received");
wl.release();
diff --git a/app/src/main/java/info/nightscout/utils/FabricPrivacy.java b/app/src/main/java/info/nightscout/utils/FabricPrivacy.java
index bd117ed5c3..ad498fa4f7 100644
--- a/app/src/main/java/info/nightscout/utils/FabricPrivacy.java
+++ b/app/src/main/java/info/nightscout/utils/FabricPrivacy.java
@@ -3,6 +3,13 @@ package info.nightscout.utils;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
+import info.nightscout.androidaps.BuildConfig;
+import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.interfaces.PluginBase;
+
+import java.util.Date;
/**
* Created by jamorham on 21/02/2018.
@@ -80,4 +87,51 @@ public class FabricPrivacy {
}
}
+ public static void uploadDailyStats() {
+ if (!fabricEnabled()) return;
+
+ long lastUploadDay = SP.getLong(MainApp.gs(R.string.key_plugin_stats_report_timestamp), 0L);
+
+ Date date = new Date();
+ date.setHours(0);
+ date.setMinutes(0);
+ date.setSeconds(0);
+ long today = date.getTime() - date.getTime() % 1000;
+
+ 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");
+ pluginStats.putCustomAttribute("version", BuildConfig.VERSION);
+ for (PluginBase plugin : MainApp.getPluginsList()) {
+ if (plugin.isEnabled(plugin.getType()) && !plugin.pluginDescription.alwaysEnabled) {
+ pluginStats.putCustomAttribute(plugin.getClass().getSimpleName(), "enabled");
+ }
+ }
+
+ 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);
+ }
+
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0550c33339..79cc57d62c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1164,6 +1164,7 @@
Stored settings found
Attention: If you activate and connect to a hardware pump, AndroidAPS will copy the basal settings from the profile to the pump, overwriting the existing basal rate stored on the pump. Make sure you have the correct basal setting in AndroidAPS. If you are not sure or don\'t want to overwrite the basal settings on your pump, press cancel and repeat switching to the pump at a later time.
Generated eCarbs with amount: %1$dg, duration: %2$dh, delay: %3$dm
+ key_plugin_stats_report_timestamp
- %d day