Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

For #969: Adds more telemetry for collections #4358

Merged
merged 4 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1051,4 +1051,43 @@ collections:
- https://github.com/mozilla-mobile/fenix/pull/3935
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
expires: "2020-03-01"
add_tab_button:
type: event
description: >
A user tapped the "add tab" button in the three dot menu of collections
bugs:
- 969
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/4358
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
long_press:
type: event
description: >
A user long pressed on a tab, triggering the collection creation screen
bugs:
- 969
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/4358
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
save_button:
type: event
description: >
A user pressed the "save to collection" button on either the home or browser screen, triggering the
collection creation screen to open (tab_select_opened)
bugs:
- 969
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/4358
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
extra_keys:
from_screen:
description: >
A string representing the screen from which the user pressed the save button.
Either `browser` or `home`
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,16 @@ private val Event.wrapper
is Event.CollectionTabSelectOpened -> EventWrapper<NoExtraKeys>(
{ Collections.tabSelectOpened.record(it) }
)
is Event.CollectionTabLongPressed -> EventWrapper<NoExtraKeys>(
{ Collections.longPress.record(it) }
)
is Event.CollectionSaveButtonPressed -> EventWrapper(
{ Collections.saveButton.record(it) },
{ Collections.saveButtonKeys.valueOf(it) }
)
is Event.CollectionAddTabPressed -> EventWrapper<NoExtraKeys>(
{ Collections.addTabButton.record(it) }
)

// Don't track other events with Glean
else -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ sealed class Event {
object CollectionShared : Event()
object CollectionRemoved : Event()
object CollectionTabSelectOpened : Event()
object CollectionTabLongPressed : Event()
object CollectionAddTabPressed : Event()

data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() {
private val switchPreferenceTelemetryAllowList = listOf(
Expand All @@ -131,6 +133,11 @@ sealed class Event {
}

// Interaction Events
data class CollectionSaveButtonPressed(val fromScreen: String) : Event() {
override val extras: Map<String, String>?
get() = mapOf("from_screen" to fromScreen)
}

data class CollectionSaved(val tabsOpenCount: Int, val tabsSelectedCount: Int) : Event() {
override val extras: Map<String, String>?
get() = mapOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class DefaultBrowserToolbarController(
BrowsingModeManager.Mode.Normal
}
ToolbarMenu.Item.SaveToCollection -> {
context.components.analytics.metrics
.track(Event.CollectionSaveButtonPressed(TELEMETRY_BROWSER_IDENITIFIER))
currentSession.let {
val tab = it.toTab(context)
viewModel.tabs = listOf(tab)
Expand Down Expand Up @@ -184,4 +186,8 @@ class DefaultBrowserToolbarController(

context.components.analytics.metrics.track(Event.BrowserMenuItemTapped(eventItem))
}

companion object {
private const val TELEMETRY_BROWSER_IDENITIFIER = "browser"
}
}
2 changes: 2 additions & 0 deletions app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ class HomeFragment : Fragment(), AccountObserver {
createDeleteCollectionPrompt(action.collection)
}
is CollectionAction.AddTab -> {
requireComponents.analytics.metrics.track(Event.CollectionAddTabPressed)
showCollectionCreationFragment(
selectedTabCollection = action.collection,
step = SaveCollectionStep.SelectTabs
Expand Down Expand Up @@ -841,6 +842,7 @@ class HomeFragment : Fragment(), AccountObserver {
private const val FADE_ANIM_DURATION = 150L
private const val ANIM_SNACKBAR_DELAY = 100L
private const val ACCESSIBILITY_FOCUS_DELAY = 2000L
private const val TELEMETRY_HOME_IDENITIFIER = "home"
private const val SHARED_TRANSITION_MS = 200L
private const val TAB_ITEM_TRANSITION_NAME = "tab_item"
private const val toolbarPaddingDp = 12f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import androidx.recyclerview.widget.RecyclerView
import io.reactivex.Observer
import kotlinx.android.synthetic.main.save_tab_group_button.view.*
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.home.sessioncontrol.SessionControlAction
import org.mozilla.fenix.home.sessioncontrol.TabAction
import org.mozilla.fenix.home.sessioncontrol.onNext
Expand All @@ -20,11 +22,15 @@ class SaveTabGroupViewHolder(

init {
view.save_tab_group_button.setOnClickListener {
view.context.components.analytics.metrics
.track(Event.CollectionSaveButtonPressed(TELEMETRY_HOME_IDENITIFIER))

actionEmitter.onNext(TabAction.SaveTabGroup(selectedTabSessionId = null))
}
}

companion object {
const val TELEMETRY_HOME_IDENITIFIER = "home"
const val LAYOUT_ID = R.layout.save_tab_group_button
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import mozilla.components.browser.menu.BrowserMenuBuilder
import mozilla.components.browser.menu.item.SimpleBrowserMenuItem
import mozilla.components.support.ktx.android.util.dpToFloat
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.increaseTapArea
import org.mozilla.fenix.ext.loadIntoView
Expand Down Expand Up @@ -48,6 +49,7 @@ class TabViewHolder(
}

item_tab.setOnLongClickListener {
view.context.components.analytics.metrics.track(Event.CollectionTabLongPressed)
actionEmitter.onNext(TabAction.SaveTabGroup(tab?.sessionId!!))
true
}
Expand Down
26 changes: 26 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,32 @@ tabs_selected: The number of tabs added to the collection
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>add_tab_button</td>
<td>event</td>
<td> A user tapped the "add tab" button in the three dot menu of collections</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4358">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>long_press</td>
<td>event</td>
<td> A user long pressed on a tab, triggering the collection creation screen</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4358">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>save_button</td>
<td>event</td>
<td>A user pressed the "save to collection" button on either the home or browser screen, triggering the
collection creation screen to open (tab_select_opened)</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3935">link</a></td>
<td>from_screen: A string representing the screen from which the user pressed the save button. Either `browser` or `home`
</td>
<td>2020-03-01</td>
</tr>
</table>
</pre>

Expand Down