From 09a1d23bc89bd4cf5f9ebe7cb2bfdc94fdd3211a Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Tue, 10 Jul 2018 17:55:50 +0200 Subject: [PATCH] Move logging of app start to Fabric class. --- .../info/nightscout/androidaps/MainApp.java | 13 ++----------- .../info/nightscout/utils/FabricPrivacy.java | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 24631b10c8..4ec1655848 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -194,18 +194,9 @@ 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(); + FabricPrivacy.logAppStart(); final PumpInterface pump = ConfigBuilderPlugin.getActivePump(); if (pump != null) { diff --git a/app/src/main/java/info/nightscout/utils/FabricPrivacy.java b/app/src/main/java/info/nightscout/utils/FabricPrivacy.java index 2cbc2d9daa..5064b881dc 100644 --- a/app/src/main/java/info/nightscout/utils/FabricPrivacy.java +++ b/app/src/main/java/info/nightscout/utils/FabricPrivacy.java @@ -4,6 +4,7 @@ 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; @@ -86,8 +87,22 @@ public class FabricPrivacy { } } + public static void logAppStart() { + 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 (!FabricPrivacy.fabricEnabled()) return; + if (!fabricEnabled()) return; long lastUploadDay = SP.getLong(MainApp.gs(R.string.key_plugin_stats_report_timestamp), 0L);