Merge pull request #466 from Philoul/meallink_VWU_v2

New uel.log
This commit is contained in:
Milos Kozak 2021-04-10 18:23:40 +02:00 committed by GitHub
commit ebf0781f47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 131 additions and 46 deletions

View file

@ -32,6 +32,8 @@ import info.nightscout.androidaps.activities.PreferencesActivity
import info.nightscout.androidaps.activities.ProfileHelperActivity
import info.nightscout.androidaps.activities.SingleFragmentActivity
import info.nightscout.androidaps.activities.StatsActivity
import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.databinding.ActivityMainBinding
import info.nightscout.androidaps.events.EventAppExit
import info.nightscout.androidaps.events.EventPreferenceChange
@ -41,6 +43,7 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
@ -87,6 +90,7 @@ class MainActivity : NoSplashAppCompatActivity() {
@Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var signatureVerifierPlugin: SignatureVerifierPlugin
@Inject lateinit var config: Config
@Inject lateinit var uel: UserEntryLogger
private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle
private var pluginPreferencesMenuItem: MenuItem? = null
@ -316,6 +320,7 @@ class MainActivity : NoSplashAppCompatActivity() {
R.id.nav_exit -> {
aapsLogger.debug(LTag.CORE, "Exiting")
uel.log(Action.EXIT_AAPS, Sources.Aaps)
rxBus.send(EventAppExit())
finish()
System.runFinalization()

View file

@ -11,6 +11,7 @@ import dagger.android.AndroidInjector
import dagger.android.DaggerApplication
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.transactions.InsertIfNewByTimestampTherapyEventTransaction
import info.nightscout.androidaps.database.transactions.VersionChangeTransaction
import info.nightscout.androidaps.db.CompatDBHelper
@ -20,6 +21,7 @@ import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
@ -54,6 +56,7 @@ class MainApp : DaggerApplication() {
@Inject lateinit var repository: AppRepository
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var staticInjector: StaticInjector// TODO avoid , here fake only to initialize
@Inject lateinit var uel: UserEntryLogger
override fun onCreate() {
super.onCreate()
@ -85,6 +88,7 @@ class MainApp : DaggerApplication() {
configBuilderPlugin.initialize()
keepAliveManager.setAlarm(this)
doMigrations()
uel.log(UserEntry.Action.START_AAPS, UserEntry.Sources.Aaps)
}
private fun doMigrations() {

View file

@ -378,6 +378,8 @@ open class LoopPlugin @Inject constructor(
// mId allows you to update the notification later on.
mNotificationManager.notify(Constants.notificationID, builder.build())
uel.log(Action.CAREPORTAL, Sources.Loop,
ValueWithUnit.StringResource(info.nightscout.androidaps.core.R.string.carbsreq, listOf(ValueWithUnit.Gram(resultAfterConstraints.carbsReq), ValueWithUnit.Minute(resultAfterConstraints.carbsReqWithin))))
rxBus.send(EventNewOpenLoopNotification())
//only send to wear if Native notifications are turned off

View file

@ -29,6 +29,8 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.extensions.directionToIcon
import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.extensions.valueToUnitsString
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import io.reactivex.disposables.CompositeDisposable
@ -47,6 +49,7 @@ class BGSourceFragment : DaggerFragment() {
@Inject lateinit var repository: AppRepository
@Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var uel: UserEntryLogger
@Inject lateinit var activePlugin: ActivePluginProvider
private val disposable = CompositeDisposable()
private val millsToThePast = T.hours(12).msecs()
@ -131,8 +134,18 @@ class BGSourceFragment : DaggerFragment() {
activity?.let { activity ->
val text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + "\n" + glucoseValue.valueToUnitsString(profileFunction.getUnits())
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
//uel.log(Action.BG_REMOVED, XXXValueWithUnit.Timestamp(glucoseValue.timestamp))
uel.log(Action.BG_REMOVED, Sources.BG,
val source = when((activePlugin.activeBgSource as PluginBase).pluginDescription.pluginName) {
R.string.dexcom_app_patched -> Sources.Dexcom
R.string.eversense -> Sources.Eversense
R.string.Glimp -> Sources.Glimp
R.string.MM640g -> Sources.MM640g
R.string.nsclientbg -> Sources.NSClientSource
R.string.poctech -> Sources.PocTech
R.string.tomato -> Sources.Tomato
R.string.xdrip -> Sources.Xdrip
else -> Sources.Unknown
}
uel.log(Action.BG_REMOVED, source,
ValueWithUnit.Timestamp(glucoseValue.timestamp))
disposable += repository.runTransaction(InvalidateGlucoseValueTransaction(glucoseValue.id)).subscribe()
})

View file

@ -14,6 +14,9 @@ import info.nightscout.androidaps.activities.RequestDexcomPermissionActivity
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.GlucoseValue
import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.transactions.CgmSourceTransaction
import info.nightscout.androidaps.interfaces.BgSourceInterface
import info.nightscout.androidaps.interfaces.PluginBase
@ -21,6 +24,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.receivers.DataWorker
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.T
@ -83,6 +87,7 @@ class DexcomPlugin @Inject constructor(
@Inject lateinit var dataWorker: DataWorker
@Inject lateinit var broadcastToXDrip: XDripBroadcast
@Inject lateinit var repository: AppRepository
@Inject lateinit var uel: UserEntryLogger
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
@ -150,8 +155,20 @@ class DexcomPlugin @Inject constructor(
broadcastToXDrip(it)
aapsLogger.debug(LTag.DATABASE, "Updated bg $it")
}
result.sensorInsertionsInserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted sensor insertion $it") }
result.calibrationsInserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted calibration $it") }
result.sensorInsertionsInserted.forEach {
uel.log(Action.CAREPORTAL,
Sources.BG,
ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.TherapyEventType(it.type))
aapsLogger.debug(LTag.DATABASE, "Inserted sensor insertion $it")
}
result.calibrationsInserted.forEach {
uel.log(Action.CAREPORTAL,
Sources.BG,
ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.TherapyEventType(it.type))
aapsLogger.debug(LTag.DATABASE, "Inserted calibration $it")
}
}
} catch (e: Exception) {
aapsLogger.error("Error while processing intent from Dexcom App", e)

View file

@ -94,6 +94,8 @@ class Translator @Inject internal constructor(
Action.OTP_RESET -> resourceHelper.gs(R.string.uel_otp_reset)
Action.EXPORT_CSV -> resourceHelper.gs(R.string.uel_export_csv)
Action.STOP_SMS -> resourceHelper.gs(R.string.uel_stop_sms)
Action.START_AAPS -> resourceHelper.gs(R.string.uel_start_aaps)
Action.EXIT_AAPS -> resourceHelper.gs(R.string.uel_exit_aaps)
Action.UNKNOWN -> resourceHelper.gs(R.string.unknown)
}
@ -233,6 +235,14 @@ class Translator @Inject internal constructor(
Sources.Announcement -> TODO()
Sources.Actions -> TODO()
Sources.BG -> TODO()
Sources.Dexcom -> TODO()
Sources.Eversense -> TODO()
Sources.Glimp -> TODO()
Sources.MM640g -> TODO()
Sources.NSClientSource -> TODO()
Sources.PocTech -> TODO()
Sources.Tomato -> TODO()
Sources.Xdrip -> TODO()
Sources.LocalProfile -> TODO()
Sources.Maintenance -> TODO()
Sources.NSProfile -> TODO()
@ -255,6 +265,7 @@ class Translator @Inject internal constructor(
Sources.ConfigBuilder -> TODO()
Sources.Overview -> TODO()
Sources.Stats -> TODO()
Sources.Aaps -> TODO()
*/
Sources.Automation -> resourceHelper.gs(R.string.automation)
Sources.Loop -> resourceHelper.gs(R.string.loop)

View file

@ -79,6 +79,8 @@ class UserEntryMapper {
STOP_SMS (UserEntry.Action.STOP_SMS),
FOOD (UserEntry.Action.FOOD),
EXPORT_CSV (UserEntry.Action.EXPORT_CSV),
START_AAPS (UserEntry.Action.START_AAPS),
EXIT_AAPS (UserEntry.Action.EXIT_AAPS),
UNKNOWN (UserEntry.Action.UNKNOWN)
;
}
@ -106,6 +108,14 @@ class UserEntryMapper {
Actions (UserEntry.Sources.Actions),
Automation (UserEntry.Sources.Automation),
BG (UserEntry.Sources.BG),
Dexcom (UserEntry.Sources.Dexcom),
Eversense (UserEntry.Sources.Eversense),
Glimp (UserEntry.Sources.Glimp),
MM640g (UserEntry.Sources.MM640g),
NSClientSource (UserEntry.Sources.BG),
PocTech (UserEntry.Sources.PocTech),
Tomato (UserEntry.Sources.Tomato),
Xdrip (UserEntry.Sources.Xdrip),
LocalProfile (UserEntry.Sources.LocalProfile),
Loop (UserEntry.Sources.Loop),
Maintenance (UserEntry.Sources.Maintenance),
@ -133,6 +143,7 @@ class UserEntryMapper {
ConfigBuilder (UserEntry.Sources.ConfigBuilder),
Overview (UserEntry.Sources.Overview),
Stats (UserEntry.Sources.Stats),
Aaps (UserEntry.Sources.Aaps),
Unknown(UserEntry.Sources.Unknown)
;
}

View file

@ -61,6 +61,14 @@ class UserEntryPresentationHelper @Inject constructor(
Sources.Actions -> R.drawable.ic_action
Sources.Automation -> R.drawable.ic_automation
Sources.BG -> R.drawable.ic_generic_cgm
Sources.Dexcom -> R.drawable.ic_dexcom_g6
Sources.Eversense -> R.drawable.ic_eversense
Sources.Glimp -> R.drawable.ic_glimp
Sources.MM640g -> R.drawable.ic_generic_cgm
Sources.NSClientSource -> R.drawable.ic_nsclient_bg
Sources.PocTech -> R.drawable.ic_poctech
Sources.Tomato -> R.drawable.ic_sensor
Sources.Xdrip -> R.drawable.ic_blooddrop_48
Sources.LocalProfile -> R.drawable.ic_local_profile
Sources.Loop -> R.drawable.ic_loop_closed_white
Sources.Maintenance -> R.drawable.ic_maintenance
@ -86,8 +94,9 @@ class UserEntryPresentationHelper @Inject constructor(
Sources.Wear -> R.drawable.ic_watch
Sources.Food -> R.drawable.ic_food
Sources.Stats -> R.drawable.ic_cp_stats
Sources.ConfigBuilder -> R.drawable.ic_generic_icon
Sources.Overview -> R.drawable.ic_generic_icon
Sources.ConfigBuilder -> R.drawable.ic_cogs
Sources.Overview -> R.drawable.ic_notif_aaps
Sources.Aaps -> R.drawable.ic_notif_aaps
Sources.Unknown -> R.drawable.ic_generic_icon
}

View file

@ -481,6 +481,8 @@
<string name="uel_otp_reset">OTP RESET</string>
<string name="uel_stop_sms">STOP SMS</string>
<string name="uel_export_csv">EXPORT USER ENTRIES</string>
<string name="uel_start_aaps">START AAPS</string>
<string name="uel_exit_aaps">EXIT AAPS</string>
<string name="uel_unknown">UNKNOWN</string>
<string name="ue_formated_string">Formated string</string>
<string name="ue_source">Source</string>

View file

@ -94,6 +94,8 @@ data class UserEntry(
STOP_SMS (ColorGroup.Aaps),
FOOD (ColorGroup.CarbTreatment),
EXPORT_CSV (ColorGroup.Aaps),
START_AAPS (ColorGroup.Aaps),
EXIT_AAPS (ColorGroup.Aaps),
UNKNOWN (ColorGroup.Aaps)
;
@ -125,6 +127,14 @@ data class UserEntry(
Actions, //From Actions plugin
Automation, //From Automation plugin
BG, //From BG plugin => Add One Source per BG Source for Calibration or Sensor Change
Dexcom,
Eversense,
Glimp,
MM640g,
NSClientSource,
PocTech,
Tomato,
Xdrip,
LocalProfile, //From LocalProfile plugin
Loop, //From Loop plugin
Maintenance, //From Maintenance plugin
@ -152,6 +162,7 @@ data class UserEntry(
ConfigBuilder, //From ConfigBuilder Plugin
Overview, //From OverViewPlugin
Stats, //From Stat Activity
Aaps, // MainApp
Unknown //if necessary
;