Move logging of app start to Fabric class.

This commit is contained in:
Johannes Mockenhaupt 2018-07-10 17:55:50 +02:00
parent ccaf68d043
commit 09a1d23bc8
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 18 additions and 12 deletions

View file

@ -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) {

View file

@ -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);