Skip to content

Commit

Permalink
Kotlin: Set required client_info fields first
Browse files Browse the repository at this point in the history
There's a chance that the app is killed at any point.
If that happens while setting core metrics, on next start a ping might
be sent, which is then missing data.

Some of this data is required; and if missing the pipeline rejects the
ping during validation. By moving these metrics first we increase the
chance for them to be set.

This is a very desperate attempt on mitigating missing data.
  • Loading branch information
badboy committed May 11, 2021
1 parent 305ff55 commit 55818bb
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions glean-core/android/src/main/java/mozilla/telemetry/glean/Glean.kt
Original file line number Diff line number Diff line change
Expand Up @@ -562,19 +562,8 @@ open class GleanInternalAPI internal constructor () {
// Please note that the following metrics must be set synchronously, so
// that they are guaranteed to be available with the first ping that is
// generated. We use an internal only API to do that.
// https://developer.android.com/reference/android/os/Build.VERSION
GleanInternalMetrics.androidSdkVersion.setSync(Build.VERSION.SDK_INT.toString())
GleanInternalMetrics.osVersion.setSync(Build.VERSION.RELEASE)
// https://developer.android.com/reference/android/os/Build
GleanInternalMetrics.deviceManufacturer.setSync(Build.MANUFACTURER)
GleanInternalMetrics.deviceModel.setSync(Build.MODEL)
GleanInternalMetrics.architecture.setSync(Build.SUPPORTED_ABIS[0])
GleanInternalMetrics.locale.setSync(getLocaleTag())

configuration.channel?.let {
GleanInternalMetrics.appChannel.setSync(it)
}

// Set required information first.
buildInfo?.let {
GleanInternalMetrics.appBuild.setSync(it.versionCode)
GleanInternalMetrics.appDisplayVersion.setSync(it.versionName)
Expand Down Expand Up @@ -604,6 +593,21 @@ open class GleanInternalAPI internal constructor () {
packageInfo.versionName?.let { it } ?: "Unknown"
)
}

GleanInternalMetrics.architecture.setSync(Build.SUPPORTED_ABIS[0])
GleanInternalMetrics.osVersion.setSync(Build.VERSION.RELEASE)

// Optional data is set last.

configuration.channel?.let {
GleanInternalMetrics.appChannel.setSync(it)
}
// https://developer.android.com/reference/android/os/Build.VERSION
GleanInternalMetrics.androidSdkVersion.setSync(Build.VERSION.SDK_INT.toString())
// https://developer.android.com/reference/android/os/Build
GleanInternalMetrics.deviceManufacturer.setSync(Build.MANUFACTURER)
GleanInternalMetrics.deviceModel.setSync(Build.MODEL)
GleanInternalMetrics.locale.setSync(getLocaleTag())
}

/**
Expand Down

0 comments on commit 55818bb

Please sign in to comment.