Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue mozilla-mobile#19956: Add telemetry for tab view setting changes
Browse files Browse the repository at this point in the history
This differs from `tab_view_setting` which tells us what the user's tab
setting is at startup. It does not tell us if the user explicitly
changed it instead of just using the default (which was recently
changed in mozilla-mobile#19809).
jonalmeida committed Jul 9, 2021

Verified

This commit was signed with the committer’s verified signature.
jonalmeida Jonathan Almeida
1 parent ff9aa36 commit a58a6f7
Showing 5 changed files with 51 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
@@ -480,6 +480,28 @@ events:
notification_emails:
- android-probes@mozilla.com
expires: "2021-12-10"
- fenix-core@mozilla.com
expires: "2021-05-10"
tab_view_changed:
type: event
description: |
Indicates that the user has changed their tab view
settings, either from the default or by personal
preference.
extra_keys:
type:
description: |
A string containing the name of the tab view the user tapped.
These items include: list or grid.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/19956
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/19959#issuecomment-859227308
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2022-05-10"

onboarding:
fxa_auto_signin:
Original file line number Diff line number Diff line change
@@ -628,6 +628,13 @@ sealed class Event {
get() = mapOf(Autoplay.settingChangedKeys.autoplaySetting to setting.toString().toLowerCase(Locale.ROOT))
}

data class TabViewSettingChanged(val type: Type) : Event() {
enum class Type { LIST, GRID }

override val extras: Map<Events.tabViewChangedKeys, String>?
get() = mapOf(Events.tabViewChangedKeys.type to type.toString().toLowerCase(Locale.ROOT))
}

sealed class Search

internal open val extras: Map<*, String>?
Original file line number Diff line number Diff line change
@@ -837,6 +837,10 @@ private val Event.wrapper: EventWrapper<*>?
is Event.HomeScreenDisplayed -> EventWrapper<NoExtraKeys>(
{ HomeScreen.homeScreenDisplayed.record(it) }
)
is Event.TabViewSettingChanged -> EventWrapper(
{ Events.tabViewChanged.record(it) },
{ Events.tabViewChangedKeys.valueOf(it) }
)

is Event.BrowserToolbarHomeButtonClicked -> EventWrapper<NoExtraKeys>(
{ Events.browserToolbarHomeTapped.record(it) }
Original file line number Diff line number Diff line change
@@ -32,6 +32,9 @@ open class RadioButtonPreference @JvmOverloads constructor(
private var defaultValue: Boolean = false
private var clickListener: (() -> Unit)? = null

val isChecked: Boolean
get() = radioButton?.isChecked == true

init {
layoutResource = R.layout.preference_widget_radiobutton

Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ import android.view.View
import androidx.preference.PreferenceFragmentCompat
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.metrics.Event.TabViewSettingChanged
import org.mozilla.fenix.components.metrics.Event.TabViewSettingChanged.Type
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.showToolbar
import org.mozilla.fenix.utils.view.addToRadioGroup
@@ -60,6 +62,9 @@ class TabsSettingsFragment : PreferenceFragmentCompat() {
startOnHomeRadioAlways = requirePreference(R.string.pref_key_start_on_home_always)
startOnHomeRadioNever = requirePreference(R.string.pref_key_start_on_home_never)

listRadioButton.onClickListener(::sendTabViewTelemetry)
gridRadioButton.onClickListener(::sendTabViewTelemetry)

setupRadioGroups()
}

@@ -82,4 +87,14 @@ class TabsSettingsFragment : PreferenceFragmentCompat() {
startOnHomeRadioNever
)
}

private fun sendTabViewTelemetry() {
val metrics = requireContext().components.analytics.metrics

if (listRadioButton.isChecked && !gridRadioButton.isChecked) {
metrics.track(TabViewSettingChanged(Type.LIST))
} else {
metrics.track(TabViewSettingChanged(Type.GRID))
}
}
}

0 comments on commit a58a6f7

Please sign in to comment.