mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/22192 add telemetry for studies
This commit is contained in:
parent
2f4da44511
commit
d201f02bfb
@ -1413,6 +1413,35 @@ customize_home:
|
|||||||
expires: "2022-09-20"
|
expires: "2022-09-20"
|
||||||
|
|
||||||
preferences:
|
preferences:
|
||||||
|
studies_enabled:
|
||||||
|
type: boolean
|
||||||
|
description: >
|
||||||
|
A metric indicating whether or not the user has studies enabled
|
||||||
|
default: true
|
||||||
|
send_in_pings:
|
||||||
|
- metrics
|
||||||
|
bugs:
|
||||||
|
- https://github.com/mozilla-mobile/fenix/issues/22192
|
||||||
|
data_reviews:
|
||||||
|
- https://github.com/mozilla-mobile/fenix/pull/22193
|
||||||
|
data_sensitivity:
|
||||||
|
- interaction
|
||||||
|
notification_emails:
|
||||||
|
- android-probes@mozilla.com
|
||||||
|
expires: "2022-11-01"
|
||||||
|
studies_preference_enabled:
|
||||||
|
type: event
|
||||||
|
description: >
|
||||||
|
An event indicating whether or not the user has studies enabled.
|
||||||
|
bugs:
|
||||||
|
- https://github.com/mozilla-mobile/fenix/issues/22192
|
||||||
|
data_reviews:
|
||||||
|
- https://github.com/mozilla-mobile/fenix/pull/22193
|
||||||
|
data_sensitivity:
|
||||||
|
- interaction
|
||||||
|
notification_emails:
|
||||||
|
- android-probes@mozilla.com
|
||||||
|
expires: "2022-11-01"
|
||||||
search_suggestions_enabled:
|
search_suggestions_enabled:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: |
|
description: |
|
||||||
|
@ -652,6 +652,7 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
|
|||||||
with(Preferences) {
|
with(Preferences) {
|
||||||
searchSuggestionsEnabled.set(settings.shouldShowSearchSuggestions)
|
searchSuggestionsEnabled.set(settings.shouldShowSearchSuggestions)
|
||||||
remoteDebuggingEnabled.set(settings.isRemoteDebuggingEnabled)
|
remoteDebuggingEnabled.set(settings.isRemoteDebuggingEnabled)
|
||||||
|
studiesEnabled.set(settings.isExperimentationEnabled)
|
||||||
telemetryEnabled.set(settings.isTelemetryEnabled)
|
telemetryEnabled.set(settings.isTelemetryEnabled)
|
||||||
browsingHistorySuggestion.set(settings.shouldShowHistorySuggestions)
|
browsingHistorySuggestion.set(settings.shouldShowHistorySuggestions)
|
||||||
bookmarksSuggestion.set(settings.shouldShowBookmarkSuggestions)
|
bookmarksSuggestion.set(settings.shouldShowBookmarkSuggestions)
|
||||||
|
@ -162,6 +162,7 @@ sealed class Event {
|
|||||||
}
|
}
|
||||||
object FennecToFenixMigrated : Event()
|
object FennecToFenixMigrated : Event()
|
||||||
object AddonsOpenInSettings : Event()
|
object AddonsOpenInSettings : Event()
|
||||||
|
object StudiesSettings : Event()
|
||||||
object VoiceSearchTapped : Event()
|
object VoiceSearchTapped : Event()
|
||||||
object SearchWidgetInstalled : Event()
|
object SearchWidgetInstalled : Event()
|
||||||
object OnboardingAutoSignIn : Event()
|
object OnboardingAutoSignIn : Event()
|
||||||
|
@ -524,6 +524,9 @@ private val Event.wrapper: EventWrapper<*>?
|
|||||||
is Event.AddonsOpenInSettings -> EventWrapper<NoExtraKeys>(
|
is Event.AddonsOpenInSettings -> EventWrapper<NoExtraKeys>(
|
||||||
{ Addons.openAddonsInSettings.record(it) }
|
{ Addons.openAddonsInSettings.record(it) }
|
||||||
)
|
)
|
||||||
|
is Event.StudiesSettings -> EventWrapper<NoExtraKeys>(
|
||||||
|
{ Preferences.studiesPreferenceEnabled.record(it) }
|
||||||
|
)
|
||||||
is Event.AddonsOpenInToolbarMenu -> EventWrapper(
|
is Event.AddonsOpenInToolbarMenu -> EventWrapper(
|
||||||
{ Addons.openAddonInToolbarMenu.record(it) },
|
{ Addons.openAddonInToolbarMenu.record(it) },
|
||||||
{ Addons.openAddonInToolbarMenuKeys.valueOf(it) }
|
{ Addons.openAddonInToolbarMenuKeys.valueOf(it) }
|
||||||
|
@ -12,6 +12,7 @@ import androidx.fragment.app.Fragment
|
|||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.databinding.SettingsStudiesBinding
|
import org.mozilla.fenix.databinding.SettingsStudiesBinding
|
||||||
|
import org.mozilla.fenix.ext.metrics
|
||||||
import org.mozilla.fenix.ext.requireComponents
|
import org.mozilla.fenix.ext.requireComponents
|
||||||
import org.mozilla.fenix.ext.settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
@ -39,7 +40,8 @@ class StudiesFragment : Fragment() {
|
|||||||
interactor,
|
interactor,
|
||||||
requireContext().settings(),
|
requireContext().settings(),
|
||||||
experiments,
|
experiments,
|
||||||
::isAttached
|
::isAttached,
|
||||||
|
requireContext().metrics
|
||||||
).bind()
|
).bind()
|
||||||
|
|
||||||
return binding.root
|
return binding.root
|
||||||
|
@ -24,6 +24,8 @@ import mozilla.components.service.nimbus.NimbusApi
|
|||||||
import mozilla.components.support.base.log.logger.Logger
|
import mozilla.components.support.base.log.logger.Logger
|
||||||
import org.mozilla.experiments.nimbus.internal.EnrolledExperiment
|
import org.mozilla.experiments.nimbus.internal.EnrolledExperiment
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.components.metrics.Event
|
||||||
|
import org.mozilla.fenix.components.metrics.MetricController
|
||||||
import org.mozilla.fenix.databinding.SettingsStudiesBinding
|
import org.mozilla.fenix.databinding.SettingsStudiesBinding
|
||||||
import org.mozilla.fenix.ext.getPreferenceKey
|
import org.mozilla.fenix.ext.getPreferenceKey
|
||||||
import org.mozilla.fenix.ext.settings
|
import org.mozilla.fenix.ext.settings
|
||||||
@ -40,7 +42,8 @@ class StudiesView(
|
|||||||
private val interactor: StudiesInteractor,
|
private val interactor: StudiesInteractor,
|
||||||
private val settings: Settings,
|
private val settings: Settings,
|
||||||
private val experiments: NimbusApi,
|
private val experiments: NimbusApi,
|
||||||
private val isAttached: () -> Boolean
|
private val isAttached: () -> Boolean,
|
||||||
|
private val metrics: MetricController
|
||||||
) : StudiesAdapterDelegate {
|
) : StudiesAdapterDelegate {
|
||||||
private val logger = Logger("StudiesView")
|
private val logger = Logger("StudiesView")
|
||||||
|
|
||||||
@ -53,6 +56,7 @@ class StudiesView(
|
|||||||
provideStudiesSwitch().isChecked = settings.isExperimentationEnabled
|
provideStudiesSwitch().isChecked = settings.isExperimentationEnabled
|
||||||
provideStudiesSwitch().setOnClickListener {
|
provideStudiesSwitch().setOnClickListener {
|
||||||
val isChecked = provideStudiesSwitch().isChecked
|
val isChecked = provideStudiesSwitch().isChecked
|
||||||
|
metrics.track(Event.StudiesSettings)
|
||||||
provideStudiesTitle().text = getSwitchCheckedTitle()
|
provideStudiesTitle().text = getSwitchCheckedTitle()
|
||||||
val builder = AlertDialog.Builder(context)
|
val builder = AlertDialog.Builder(context)
|
||||||
.setPositiveButton(
|
.setPositiveButton(
|
||||||
|
@ -108,6 +108,7 @@ class FenixApplicationTest {
|
|||||||
every { settings.shouldUseTrackingProtection } returns true
|
every { settings.shouldUseTrackingProtection } returns true
|
||||||
every { settings.isRemoteDebuggingEnabled } returns true
|
every { settings.isRemoteDebuggingEnabled } returns true
|
||||||
every { settings.isTelemetryEnabled } returns true
|
every { settings.isTelemetryEnabled } returns true
|
||||||
|
every { settings.isExperimentationEnabled } returns true
|
||||||
every { settings.shouldShowHistorySuggestions } returns true
|
every { settings.shouldShowHistorySuggestions } returns true
|
||||||
every { settings.shouldShowBookmarkSuggestions } returns true
|
every { settings.shouldShowBookmarkSuggestions } returns true
|
||||||
every { settings.shouldShowClipboardSuggestions } returns true
|
every { settings.shouldShowClipboardSuggestions } returns true
|
||||||
@ -154,6 +155,7 @@ class FenixApplicationTest {
|
|||||||
assertEquals(true, Preferences.searchSuggestionsEnabled.testGetValue())
|
assertEquals(true, Preferences.searchSuggestionsEnabled.testGetValue())
|
||||||
assertEquals(true, Preferences.remoteDebuggingEnabled.testGetValue())
|
assertEquals(true, Preferences.remoteDebuggingEnabled.testGetValue())
|
||||||
assertEquals(true, Preferences.telemetryEnabled.testGetValue())
|
assertEquals(true, Preferences.telemetryEnabled.testGetValue())
|
||||||
|
assertEquals(true, Preferences.studiesEnabled.testGetValue())
|
||||||
assertEquals(true, Preferences.browsingHistorySuggestion.testGetValue())
|
assertEquals(true, Preferences.browsingHistorySuggestion.testGetValue())
|
||||||
assertEquals(true, Preferences.bookmarksSuggestion.testGetValue())
|
assertEquals(true, Preferences.bookmarksSuggestion.testGetValue())
|
||||||
assertEquals(true, Preferences.clipboardSuggestionsEnabled.testGetValue())
|
assertEquals(true, Preferences.clipboardSuggestionsEnabled.testGetValue())
|
||||||
|
@ -18,6 +18,7 @@ import io.mockk.verify
|
|||||||
import kotlinx.coroutines.test.TestCoroutineDispatcher
|
import kotlinx.coroutines.test.TestCoroutineDispatcher
|
||||||
import kotlinx.coroutines.test.TestCoroutineScope
|
import kotlinx.coroutines.test.TestCoroutineScope
|
||||||
import mozilla.components.service.nimbus.NimbusApi
|
import mozilla.components.service.nimbus.NimbusApi
|
||||||
|
import mozilla.components.support.test.mock
|
||||||
import mozilla.components.support.test.robolectric.testContext
|
import mozilla.components.support.test.robolectric.testContext
|
||||||
import mozilla.components.support.test.rule.MainCoroutineRule
|
import mozilla.components.support.test.rule.MainCoroutineRule
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
@ -26,15 +27,12 @@ import org.junit.Rule
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mozilla.experiments.nimbus.internal.EnrolledExperiment
|
import org.mozilla.experiments.nimbus.internal.EnrolledExperiment
|
||||||
import org.mozilla.fenix.HomeActivity
|
|
||||||
import org.mozilla.fenix.databinding.SettingsStudiesBinding
|
import org.mozilla.fenix.databinding.SettingsStudiesBinding
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.utils.Settings
|
||||||
|
|
||||||
@RunWith(FenixRobolectricTestRunner::class)
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
class StudiesViewTest {
|
class StudiesViewTest {
|
||||||
@RelaxedMockK
|
|
||||||
private lateinit var activity: HomeActivity
|
|
||||||
|
|
||||||
@RelaxedMockK
|
@RelaxedMockK
|
||||||
private lateinit var experiments: NimbusApi
|
private lateinit var experiments: NimbusApi
|
||||||
@ -65,8 +63,10 @@ class StudiesViewTest {
|
|||||||
binding,
|
binding,
|
||||||
interactor,
|
interactor,
|
||||||
settings,
|
settings,
|
||||||
experiments
|
experiments,
|
||||||
) { true }
|
isAttached = { true },
|
||||||
|
metrics = mock()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user