ci(release): refine promotion logic and enhance Datadog integration (#3322)

This commit is contained in:
James Rich 2025-10-03 21:03:33 -05:00 committed by GitHub
parent 51fa634e11
commit 28de377068
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 27 deletions

View file

@ -210,12 +210,6 @@ jobs:
echo "lane=production" >> $GITHUB_OUTPUT
fi
- name: Ensure internal track has version for promotion
if: "!contains(github.ref_name, '-internal') && needs.check-versioncode-google-play.outputs.exists != 'true'"
run: |
echo "::error::Cannot promote: versionCode ${{ needs.prepare-build-info.outputs.APP_VERSION_CODE }} not found on Google Play internal track. Run internal build first." >&2
exit 1
- name: Promote on Google Play
if: "steps.fastlane_lane.outputs.lane != '' && needs.check-versioncode-google-play.outputs.exists == 'true'"
env:

View file

@ -15,6 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import com.datadog.gradle.plugin.InstrumentationMode
import com.geeksville.mesh.buildlogic.GitVersionValueSource
import java.io.FileInputStream
import java.util.Properties
@ -256,3 +257,7 @@ dokka {
maxHeapSize = "6g"
}
}
datadog {
composeInstrumentation = InstrumentationMode.AUTO
}

View file

@ -21,7 +21,7 @@ import android.app.Application
import android.content.Context
import android.os.Bundle
import android.provider.Settings
import android.util.Log.WARN
import android.util.Log.DEBUG
import androidx.compose.runtime.Composable
import androidx.lifecycle.ProcessLifecycleOwner
import androidx.lifecycle.lifecycleScope
@ -76,11 +76,13 @@ constructor(
analyticsPrefs: AnalyticsPrefs,
) : PlatformAnalytics {
private val sampleRate = 10f // For Datadog remote sample rate
private val sampleRate =
100f.takeIf { BuildConfig.DEBUG } ?: 10f // For Datadog remote sample rate
private val isInTestLab: Boolean
get() {
val testLabSetting = Settings.System.getString(context.contentResolver, "firebase.test.lab")
val testLabSetting =
Settings.System.getString(context.contentResolver, "firebase.test.lab")
return "true" == testLabSetting
}
@ -92,20 +94,16 @@ constructor(
init {
initDatadog(context as Application, analyticsPrefs)
initCrashlytics(context, analyticsPrefs)
Timber.plant(Timber.DebugTree()) // Always plant DebugTree
if (isPlatformServicesAvailable) {
val datadogLogger =
Logger.Builder()
.setService(SERVICE_NAME)
.setNetworkInfoEnabled(true)
.setRemoteSampleRate(sampleRate)
.setBundleWithTraceEnabled(true)
.setBundleWithRumEnabled(true)
.build()
Timber.plant(DatadogTree(datadogLogger))
Timber.plant(CrashlyticsTree())
}
val datadogLogger =
Logger.Builder()
.setService(SERVICE_NAME)
.setNetworkInfoEnabled(true)
.setRemoteSampleRate(sampleRate)
.setBundleWithTraceEnabled(true)
.setBundleWithRumEnabled(true)
.build()
Timber.plant(DatadogTree(datadogLogger), CrashlyticsTree())
// Initial consent state
updateAnalyticsConsent(analyticsPrefs.analyticsAllowed)
@ -130,7 +128,7 @@ constructor(
// Initialize with PENDING, consent will be updated via updateAnalyticsConsent
Datadog.initialize(application, configuration, TrackingConsent.PENDING)
Datadog.setUserInfo(analyticsPrefs.installId)
Datadog.setVerbosity(WARN)
Datadog.setVerbosity(DEBUG)
val rumConfiguration =
RumConfiguration.Builder(BuildConfig.datadogApplicationId)
@ -189,7 +187,8 @@ constructor(
override fun setDeviceAttributes(firmwareVersion: String, model: String) {
if (!Datadog.isInitialized() || !GlobalRumMonitor.isRegistered()) return
GlobalRumMonitor.get().addAttribute("firmware_version", firmwareVersion.extractSemanticVersion())
GlobalRumMonitor.get()
.addAttribute("firmware_version", firmwareVersion.extractSemanticVersion())
GlobalRumMonitor.get().addAttribute("device_hardware", model)
}
@ -244,7 +243,8 @@ constructor(
private fun String.extractSemanticVersion(): String {
val regex = "^(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?".toRegex()
val matchResult = regex.find(this)
return matchResult?.groupValues?.drop(1)?.filter { it.isNotEmpty() }?.joinToString(".") ?: this
return matchResult?.groupValues?.drop(1)?.filter { it.isNotEmpty() }?.joinToString(".")
?: this
}
override fun track(event: String, vararg properties: DataPair) {
@ -253,10 +253,16 @@ constructor(
when (it.value) {
is Double -> bundle.putDouble(it.name, it.value)
is Int ->
bundle.putLong(it.name, it.value.toLong()) // Firebase expects Long for integer values in bundles
bundle.putLong(
it.name,
it.value.toLong()
) // Firebase expects Long for integer values in bundles
is Long -> bundle.putLong(it.name, it.value)
is Float -> bundle.putDouble(it.name, it.value.toDouble())
is String -> bundle.putString(it.name, it.value as String?) // Explicitly handle String
is String -> bundle.putString(
it.name,
it.value as String?
) // Explicitly handle String
else -> bundle.putString(it.name, it.value.toString()) // Fallback for other types
}
Timber.tag(TAG).d("Analytics: track $event (${it.name} : ${it.value})")