feat(analytics): Integrate Datadog for RUM and Logging (#2578)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2025-08-01 16:54:46 -05:00 committed by GitHub
parent f5478b42c3
commit ab22a655c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 348 additions and 194 deletions

View file

@ -18,7 +18,6 @@
package com.geeksville.mesh
import com.geeksville.mesh.android.GeeksvilleApplication
import com.geeksville.mesh.android.Logging
import dagger.hilt.android.HiltAndroidApp
@HiltAndroidApp
@ -26,8 +25,5 @@ class MeshUtilApplication : GeeksvilleApplication() {
override fun onCreate() {
super.onCreate()
Logging.showLogs = BuildConfig.DEBUG
}
}
}

View file

@ -23,21 +23,24 @@ import android.content.SharedPreferences
import android.provider.Settings
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.edit
import com.geeksville.mesh.BuildConfig
import com.geeksville.mesh.analytics.AnalyticsProvider
import com.geeksville.mesh.model.DeviceHardware
import timber.log.Timber
open class GeeksvilleApplication : Application(), Logging {
open class GeeksvilleApplication :
Application(),
Logging {
companion object {
lateinit var analytics: AnalyticsProvider
}
/// Are we running inside the testlab?
// / Are we running inside the testlab?
val isInTestLab: Boolean
get() {
val testLabSetting =
Settings.System.getString(contentResolver, "firebase.test.lab") ?: null
if(testLabSetting != null)
info("Testlab is $testLabSetting")
val testLabSetting = Settings.System.getString(contentResolver, "firebase.test.lab") ?: null
if (testLabSetting != null) info("Testlab is $testLabSetting")
return "true" == testLabSetting
}
@ -48,9 +51,7 @@ open class GeeksvilleApplication : Application(), Logging {
var isAnalyticsAllowed: Boolean
get() = analyticsPrefs.getBoolean("allowed", true)
set(value) {
analyticsPrefs.edit {
putBoolean("allowed", value)
}
analyticsPrefs.edit { putBoolean("allowed", value) }
// Change the flag with the providers
analytics.setEnabled(value && !isInTestLab) // Never do analytics in the test lab
@ -64,10 +65,18 @@ open class GeeksvilleApplication : Application(), Logging {
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
}
val nopAnalytics = com.geeksville.mesh.analytics.NopAnalytics(this)
analytics = nopAnalytics
isAnalyticsAllowed = false
}
}
fun Context.isGooglePlayAvailable(): Boolean = false
fun Context.isGooglePlayAvailable(): Boolean = false
fun setAttributes(deviceVersion: String, deviceHardware: DeviceHardware) {
// No-op for F-Droid version
}