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 82f9a0a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Rust
* Don't return a result from `submit_ping`. The boolean return value indicates whether a ping was submitted ([#1613](https://github.com/mozilla/glean/pull/1613))
* **Breaking Change**: Glean now schedules "metrics" pings, accepting a new Configuration parameter. ([#1599](https://github.com/mozilla/glean/pull/1599))
* Android
* Set required fields for `client_info` before optional ones ([#1633](https://github.com/mozilla/glean/pull/1633))

# v37.0.0 (2021-04-30)

Expand Down
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 82f9a0a

Please sign in to comment.