diff --git a/CHANGELOG.md b/CHANGELOG.md index 93aa9d7fb1..cebc96653f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ [Full changelog](https://github.com/mozilla/glean/compare/v66.1.0...main) +* Kotlin + * BUGFIX: For `lateinit` metrics, check that the metric was instantiated before recording on it ([#3309](https://github.com/mozilla/glean/pull/3309)) + # v66.1.0 (2025-11-03) [Full changelog](https://github.com/mozilla/glean/compare/v66.0.1...v66.1.0) diff --git a/glean-core/android/src/main/java/mozilla/telemetry/glean/private/BooleanMetricType.kt b/glean-core/android/src/main/java/mozilla/telemetry/glean/private/BooleanMetricType.kt index 2c07973cae..b2642f0d44 100644 --- a/glean-core/android/src/main/java/mozilla/telemetry/glean/private/BooleanMetricType.kt +++ b/glean-core/android/src/main/java/mozilla/telemetry/glean/private/BooleanMetricType.kt @@ -37,7 +37,9 @@ class BooleanMetricType { */ fun set(value: Boolean) { Dispatchers.Delayed.launch { - inner.set(value) + if (this::inner.isInitialized) { + inner.set(value) + } } } diff --git a/glean-core/android/src/main/java/mozilla/telemetry/glean/private/CounterMetricType.kt b/glean-core/android/src/main/java/mozilla/telemetry/glean/private/CounterMetricType.kt index fee038c709..3c6237f12b 100644 --- a/glean-core/android/src/main/java/mozilla/telemetry/glean/private/CounterMetricType.kt +++ b/glean-core/android/src/main/java/mozilla/telemetry/glean/private/CounterMetricType.kt @@ -38,7 +38,9 @@ class CounterMetricType { */ fun add(amount: Int = 1) { Dispatchers.Delayed.launch { - inner.add(amount) + if (this::inner.isInitialized) { + inner.add(amount) + } } } diff --git a/glean-core/android/src/main/java/mozilla/telemetry/glean/private/QuantityMetricType.kt b/glean-core/android/src/main/java/mozilla/telemetry/glean/private/QuantityMetricType.kt index f05a8ee7a2..7ed057ca57 100644 --- a/glean-core/android/src/main/java/mozilla/telemetry/glean/private/QuantityMetricType.kt +++ b/glean-core/android/src/main/java/mozilla/telemetry/glean/private/QuantityMetricType.kt @@ -37,7 +37,9 @@ class QuantityMetricType { */ fun set(value: Long) { Dispatchers.Delayed.launch { - inner.set(value) + if (this::inner.isInitialized) { + inner.set(value) + } } } diff --git a/glean-core/android/src/main/java/mozilla/telemetry/glean/private/StringMetricType.kt b/glean-core/android/src/main/java/mozilla/telemetry/glean/private/StringMetricType.kt index 8fbc887f32..de1a3aee99 100644 --- a/glean-core/android/src/main/java/mozilla/telemetry/glean/private/StringMetricType.kt +++ b/glean-core/android/src/main/java/mozilla/telemetry/glean/private/StringMetricType.kt @@ -38,7 +38,9 @@ class StringMetricType { */ fun set(value: String) { Dispatchers.Delayed.launch { - inner.set(value) + if (this::inner.isInitialized) { + inner.set(value) + } } }