From 36d9a009257d57c5ef8677ff2c3656fd4c1ca4ec Mon Sep 17 00:00:00 2001 From: Sawyer Blatz Date: Mon, 23 Mar 2020 14:27:28 -0700 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/9256: Attempts to fix installation ping not being sent (https://github.com/mozilla-mobile/fenix/pull/9331) --- .../fenix/components/metrics/AdjustMetricsService.kt | 4 +++- .../mozilla/fenix/components/metrics/InstallationPing.kt | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/AdjustMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/AdjustMetricsService.kt index 7bff20dedb..e8dcd5b500 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/AdjustMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/AdjustMetricsService.kt @@ -37,6 +37,8 @@ class AdjustMetricsService(private val application: Application) : MetricsServic true ) + val installationPing = InstallationPing(application) + config.setOnAttributionChangedListener { if (!it.network.isNullOrEmpty()) { application.applicationContext.settings().adjustNetwork = @@ -55,7 +57,7 @@ class AdjustMetricsService(private val application: Application) : MetricsServic it.campaign } - InstallationPing(application).checkAndSend() + installationPing.checkAndSend() } config.setLogLevel(LogLevel.SUPRESS) diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/InstallationPing.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/InstallationPing.kt index 384b086f86..4196d3621a 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/InstallationPing.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/InstallationPing.kt @@ -71,14 +71,17 @@ class InstallationPing(private val context: Context) { } /** - * Check that required metrics are not empty before attempting to send ping. + * Check that at least one of the metrics values is set before sending the ping. + * Note: it is normal for many of these values to not be set as campaigns do not always + * utilize every attribute! * */ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) internal fun checkMetricsNotEmpty(): Boolean = listOf( + context.settings().adjustCampaignId, context.settings().adjustAdGroup, context.settings().adjustCreative, context.settings().adjustNetwork - ).all { it.isNotEmpty() } + ).any { it.isNotEmpty() } /** * Trigger sending the `installation` ping if it wasn't sent already.