From 4d14735935424949b2bb49d73b0b4c80fe8dd836 Mon Sep 17 00:00:00 2001 From: Sawyer Blatz Date: Tue, 6 Aug 2019 10:00:02 -0700 Subject: [PATCH] For #3060: Adds Leanplum attributes for fxa syncing --- .../org/mozilla/fenix/components/BackgroundServices.kt | 2 +- .../fenix/components/metrics/LeanplumMetricsService.kt | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt b/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt index 9f1c66a36..1a21a71ad 100644 --- a/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt +++ b/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt @@ -76,7 +76,7 @@ class BackgroundServices( } ) // If sync has been turned off on the server then disable syncing. - private val syncConfig = if (context.isInExperiment(Experiments.asFeatureSyncDisabled)) { + val syncConfig = if (context.isInExperiment(Experiments.asFeatureSyncDisabled)) { null } else { SyncConfig(setOf("history", "bookmarks"), syncPeriodInMinutes = 240L) // four hours diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt index 9c28b1ddd..1c65f8211 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt @@ -11,6 +11,7 @@ import com.leanplum.LeanplumActivityHelper import com.leanplum.annotations.Parser import com.leanplum.internal.LeanplumInternal import org.mozilla.fenix.BuildConfig +import org.mozilla.fenix.ext.components import org.mozilla.fenix.utils.Settings import java.util.UUID @@ -65,12 +66,17 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ LeanplumActivityHelper.enableLifecycleCallbacks(application) val installedApps = MozillaProductDetector.getInstalledMozillaProducts(application) + val backgroundServices = application.applicationContext.components.backgroundServices + val fxaLoggedIn = backgroundServices.accountManager.accountProfile() != null + val syncedItems = backgroundServices.syncConfig?.syncableStores?.isNotEmpty() ?: false Leanplum.start(application, hashMapOf( "default_browser" to (MozillaProductDetector.getMozillaBrowserDefault(application) ?: ""), "fennec_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.FIREFOX.productName), "focus_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.FOCUS.productName), - "klar_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.KLAR.productName) + "klar_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.KLAR.productName), + "fxa_logged_in" to fxaLoggedIn, + "fxa_synced_items" to syncedItems )) }