For #3060: Adds Leanplum attributes for fxa syncing

This commit is contained in:
Sawyer Blatz 2019-08-06 10:00:02 -07:00 committed by Jeff Boek
parent 9d65e665e5
commit 4d14735935
2 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -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
))
}