Skip to content

Commit

Permalink
For mozilla-mobile#21618: Integrate Nimbus with MR2 Home Page to enab…
Browse files Browse the repository at this point in the history
…le experimentation
  • Loading branch information
Amejia481 authored and mergify[bot] committed Oct 4, 2021
1 parent ebd3365 commit 2b363b9
Show file tree
Hide file tree
Showing 12 changed files with 236 additions and 227 deletions.
223 changes: 32 additions & 191 deletions app/src/debug/res/raw/initial_experiments.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,163 +4,56 @@
"appId": "org.mozilla.fenix",
"appName": "fenix",
"channel": "nightly",
"branches": [{
"slug": "control",
"ratio": 100,
"feature": {
"value": {},
"enabled": true,
"featureId": "nimbus-validation"
}
},
{
"slug": "fancy-settings",
"ratio": 0,
"feature": {
"value": {
"settings-title": "Fancy Settings"
},
"enabled": true,
"featureId": "nimbus-validation"
}
},
"branches": [
{
"slug": "smiley",
"slug": "no-mr2",
"ratio": 0,
"feature": {
"value": {
"settings-title-punctuation": "\uD83D\uDE03"
"sections-enabled": {
"topSites": true,
"recentExplorations": true,
"recentlySaved": false,
"jumpBackIn": false,
"pocket": false
}
},
"enabled": true,
"featureId": "nimbus-validation"
"featureId": "homescreen"
}
},
{
"slug": "bundled-text",
"ratio": 0,
"feature": {
"value": {
"settings-title": "preferences_category_general"
},
"enabled": true,
"featureId": "nimbus-validation"
}
}
],
"outcomes": [],
"arguments": {},
"probeSets": [],
"startDate": null,
"targeting": "true",
"featureIds": [
"nimbus-validation"
],
"application": "org.mozilla.firefox_beta",
"bucketConfig": {
"count": 0,
"start": 0,
"total": 10000,
"namespace": "nimbus-validation-2",
"randomizationUnit": "nimbus_id"
},
"schemaVersion": "1.5.0",
"userFacingName": "Nimbus Text Variables Validation",
"referenceBranch": "control",
"proposedDuration": 14,
"isEnrollmentPaused": false,
"proposedEnrollment": 7,
"userFacingDescription": "Demonstration experiment to make trivial visible changes to text in Settings",
"last_modified": 1621443780172
},
{
"slug": "feature-icon-variables-validation-android",
"appId": "org.mozilla.fenix",
"appName": "fenix",
"channel": "nightly",
"branches": [{
"slug": "control",
"slug": "full-mr2",
"ratio": 100,
"feature": {
"value": {},
"enabled": true,
"featureId": "nimbus-validation"
}
},
{
"slug": "edit-menu-icon",
"ratio": 0,
"feature": {
"value": {
"settings-title": "preferences_category_general",
"settings-icon": "ic_edit"
"sections-enabled": {
"topSites": true,
"recentExplorations": true,
"recentlySaved": true,
"jumpBackIn": true,
"pocket": true
}
},
"enabled": true,
"featureId": "nimbus-validation"
}
}
],
"outcomes": [],
"arguments": {},
"probeSets": [],
"startDate": null,
"targeting": "true",
"featureIds": [
"nimbus-validation"
],
"application": "org.mozilla.firefox_beta",
"bucketConfig": {
"count": 0,
"start": 0,
"total": 10000,
"namespace": "nimbus-validation-2",
"randomizationUnit": "nimbus_id"
},
"schemaVersion": "1.5.0",
"userFacingName": "Nimbus Icon Variables Validation",
"referenceBranch": "control",
"proposedDuration": 14,
"isEnrollmentPaused": false,
"proposedEnrollment": 7,
"userFacingDescription": "Demonstration experiment to make trivial visible changes to icons in Settings",
"last_modified": 1621443780172
},

{
"slug": "feature-text-variables-validation-ios",
"appId": "org.mozilla.ios.Fennec",
"appName": "firefox_ios",
"channel": "nightly",
"branches": [{
"slug": "control",
"ratio": 100,
"feature": {
"value": {},
"enabled": true,
"featureId": "nimbus-validation"
"featureId": "homescreen"
}
},
{
"slug": "a1",
"slug": "distraction-free",
"ratio": 0,
"feature": {
"value": {
"settings-title": "Menu/Menu.OpenSettingsAction.Title",
"settings-title-punctuation": ""
"sections-enabled": {
"topSites": true,
"recentExplorations": false,
"recentlySaved": false,
"jumpBackIn": false,
"pocket": false
}
},
"enabled": true,
"featureId": "nimbus-validation"
}
},
{
"slug": "a2",
"ratio": 0,
"feature": {
"value": {
"settings-title": "Settings.General.SectionName",
"settings-title-punctuation": "!"
},
"enabled": true,
"featureId": "nimbus-validation"
"featureId": "homescreen"
}
}
],
Expand All @@ -170,61 +63,9 @@
"startDate": null,
"targeting": "true",
"featureIds": [
"nimbus-validation"
"homescreen"
],
"application": "org.mozilla.ios.Fennec",
"bucketConfig": {
"count": 0,
"start": 0,
"total": 10000,
"namespace": "nimbus-validation-2",
"randomizationUnit": "nimbus_id"
},
"schemaVersion": "1.5.0",
"userFacingName": "Nimbus Text Variables Validation",
"referenceBranch": "control",
"proposedDuration": 14,
"isEnrollmentPaused": false,
"proposedEnrollment": 7,
"userFacingDescription": "Demonstration experiment to make trivial visible changes to text in Settings",
"last_modified": 1621443780172
},
{
"slug": "feature-icon-variables-validation-ios",
"appId": "org.mozilla.ios.Fennec",
"appName": "firefox_ios",
"channel": "nightly",
"branches": [{
"slug": "control",
"ratio": 100,
"feature": {
"value": {},
"enabled": true,
"featureId": "nimbus-validation"
}
},
{
"slug": "treatment",
"ratio": 0,
"feature": {
"value": {
"settings-title": "Fancy Settings",
"settings-icon": "menu-ViewMobile"
},
"enabled": true,
"featureId": "nimbus-validation"
}
}
],
"outcomes": [],
"arguments": {},
"probeSets": [],
"startDate": null,
"targeting": "true",
"featureIds": [
"nimbus-validation"
],
"application": "org.mozilla.ios.Fennec",
"application": "org.mozilla.firefox_beta",
"bucketConfig": {
"count": 0,
"start": 0,
Expand All @@ -233,12 +74,12 @@
"randomizationUnit": "nimbus_id"
},
"schemaVersion": "1.5.0",
"userFacingName": "Nimbus Icon Variables Validation",
"userFacingName": "Home screen sections test",
"referenceBranch": "control",
"proposedDuration": 14,
"isEnrollmentPaused": false,
"proposedEnrollment": 7,
"userFacingDescription": "Demonstration experiment to make trivial visible changes to icons in Settings",
"userFacingDescription": "Experiment to test the home screen configurations",
"last_modified": 1621443780172
}
]
Expand Down
16 changes: 9 additions & 7 deletions app/src/main/java/org/mozilla/fenix/FeatureFlags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object FeatureFlags {
/**
* Enables the Home button in the browser toolbar to navigate back to the home screen.
*/
val showHomeButtonFeature = Config.channel.isNightlyOrDebug
val showHomeButtonFeature = Config.channel.isNightlyOrDebug || Config.channel.isBeta

/**
* Enables the Start On Home feature in the settings page.
Expand All @@ -41,17 +41,17 @@ object FeatureFlags {
/**
* Enables the "recent" tabs feature in the home screen.
*/
val showRecentTabsFeature = Config.channel.isNightlyOrDebug
val showRecentTabsFeature = Config.channel.isNightlyOrDebug || Config.channel.isBeta

/**
* Enables UI features based on history metadata.
*/
val historyMetadataUIFeature = Config.channel.isNightlyOrDebug
val historyMetadataUIFeature = Config.channel.isNightlyOrDebug || Config.channel.isBeta

/**
* Enables the recently saved bookmarks feature in the home screen.
*/
val recentBookmarksFeature = Config.channel.isNightlyOrDebug
val recentBookmarksFeature = Config.channel.isNightlyOrDebug || Config.channel.isBeta

/**
* Identifies and separates the tabs list with a secondary section containing least used tabs.
Expand All @@ -66,7 +66,7 @@ object FeatureFlags {
/**
* Enables customizing the home screen
*/
val customizeHome = Config.channel.isNightlyOrDebug
val customizeHome = Config.channel.isNightlyOrDebug || Config.channel.isBeta

/**
* Identifies and separates the tabs list with a group containing search term tabs.
Expand All @@ -82,7 +82,9 @@ object FeatureFlags {
* Show Pocket recommended stories on home.
*/
fun isPocketRecommendationsFeatureEnabled(context: Context): Boolean {
return Config.channel.isNightlyOrDebug &&
"en-US" == LocaleManager.getCurrentLocale(context)?.toLanguageTag() ?: getSystemDefault().toLanguageTag()
return Config.channel.isBeta || (
Config.channel.isNightlyOrDebug && "en-US" == LocaleManager.getCurrentLocale(context)
?.toLanguageTag() ?: getSystemDefault().toLanguageTag()
)
}
}
21 changes: 16 additions & 5 deletions app/src/main/java/org/mozilla/fenix/FenixApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ import mozilla.components.feature.autofill.AutofillUseCases
import mozilla.components.feature.search.ext.buildSearchUrl
import mozilla.components.feature.search.ext.waitForSelectedOrDefaultSearchEngine
import mozilla.components.service.fxa.manager.SyncEnginesStorage
import org.mozilla.experiments.nimbus.NimbusInterface
import org.mozilla.experiments.nimbus.internal.EnrolledExperiment
import org.mozilla.fenix.GleanMetrics.Addons
import org.mozilla.fenix.GleanMetrics.AndroidAutofill
import org.mozilla.fenix.GleanMetrics.CustomizeHome
Expand Down Expand Up @@ -690,11 +692,20 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
}
)
}
CustomizeHome.jumpBackIn.set(settings.showRecentTabsFeature)
CustomizeHome.recentlySaved.set(settings.showRecentBookmarksFeature)
CustomizeHome.mostVisitedSites.set(settings.showTopFrecentSites)
CustomizeHome.recentlyVisited.set(settings.historyMetadataUIFeature)
CustomizeHome.pocket.set(settings.pocketRecommendations)
reportHomeScreenMetrics(settings)
}

@VisibleForTesting
internal fun reportHomeScreenMetrics(settings: Settings) {
components.analytics.experiments.register(object : NimbusInterface.Observer {
override fun onUpdatesApplied(updated: List<EnrolledExperiment>) {
CustomizeHome.jumpBackIn.set(settings.showRecentTabsFeature)
CustomizeHome.recentlySaved.set(settings.showRecentBookmarksFeature)
CustomizeHome.mostVisitedSites.set(settings.showTopFrecentSites)
CustomizeHome.recentlyVisited.set(settings.historyMetadataUIFeature)
CustomizeHome.pocket.set(settings.showPocketRecommendationsFeature)
}
})
}

protected fun recordOnInit() {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/mozilla/fenix/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {

components.core.requestInterceptor.setNavigationController(navHost.navController)

if (settings().pocketRecommendations) {
if (settings().showPocketRecommendationsFeature) {
components.core.pocketStoriesService.startPeriodicStoriesRefresh()
}

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/org/mozilla/fenix/components/Analytics.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.mozilla.fenix.ReleaseChannel
import org.mozilla.fenix.components.metrics.AdjustMetricsService
import org.mozilla.fenix.components.metrics.GleanMetricsService
import org.mozilla.fenix.components.metrics.MetricController
import org.mozilla.fenix.experiments.NimbusFeatures
import org.mozilla.fenix.experiments.createNimbus
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.perf.lazyMonitored
Expand Down Expand Up @@ -103,6 +104,10 @@ class Analytics(
val experiments: NimbusApi by lazyMonitored {
createNimbus(context, BuildConfig.NIMBUS_ENDPOINT)
}

val features: NimbusFeatures by lazyMonitored {
NimbusFeatures(context)
}
}

fun isSentryEnabled() = !BuildConfig.SENTRY_TOKEN.isNullOrEmpty()
Expand Down

0 comments on commit 2b363b9

Please sign in to comment.