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

Commit

Permalink
For #969: Adds more telemetry for collections
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Aug 5, 2019
1 parent 5edc9d0 commit 7036eab
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 10 deletions.
13 changes: 12 additions & 1 deletion app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1090,4 +1090,15 @@ collections:
from_screen:
description: >
A string representing the screen from which the user pressed the save button.
Either `browser` or `home`
Currently one of: browserMenu, homeMenu or home
rename_button:
type: event
description: >
A user tapped the "rename collection" button in the three dot menu
bugs:
- 969
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/TODO
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ private val Event.wrapper
is Event.CollectionAddTabPressed -> EventWrapper<NoExtraKeys>(
{ Collections.addTabButton.record(it) }
)
is Event.CollectionRenamePressed -> EventWrapper<NoExtraKeys>(
{ Collections.renameButton.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 @@ -110,6 +110,7 @@ sealed class Event {
object CollectionTabSelectOpened : Event()
object CollectionTabLongPressed : Event()
object CollectionAddTabPressed : Event()
object CollectionRenamePressed : Event()

data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() {
private val switchPreferenceTelemetryAllowList = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class DefaultBrowserToolbarController(
}
ToolbarMenu.Item.SaveToCollection -> {
context.components.analytics.metrics
.track(Event.CollectionSaveButtonPressed(TELEMETRY_BROWSER_IDENITIFIER))
.track(Event.CollectionSaveButtonPressed(TELEMETRY_BROWSER_IDENTIFIER))
currentSession.let {
val tab = it.toTab(context)
viewModel.tabs = listOf(tab)
Expand Down Expand Up @@ -188,6 +188,6 @@ class DefaultBrowserToolbarController(
}

companion object {
private const val TELEMETRY_BROWSER_IDENITIFIER = "browser"
private const val TELEMETRY_BROWSER_IDENTIFIER = "browserMenu"
}
}
1 change: 1 addition & 0 deletions app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ class HomeFragment : Fragment(), AccountObserver {
selectedTabCollection = action.collection,
step = SaveCollectionStep.RenameCollection
)
requireComponents.analytics.metrics.track(Event.CollectionRenamePressed)
}
is CollectionAction.OpenTab -> {
invokePendingDeleteJobs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class SaveTabGroupViewHolder(
init {
view.save_tab_group_button.setOnClickListener {
view.context.components.analytics.metrics
.track(Event.CollectionSaveButtonPressed(TELEMETRY_HOME_IDENITIFIER))
.track(Event.CollectionSaveButtonPressed(TELEMETRY_HOME_IDENTIFIER))

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

companion object {
const val TELEMETRY_HOME_IDENITIFIER = "home"
const val TELEMETRY_HOME_IDENTIFIER = "home"
const val LAYOUT_ID = R.layout.save_tab_group_button
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import mozilla.components.browser.menu.BrowserMenu
import mozilla.components.browser.menu.BrowserMenuBuilder
import mozilla.components.browser.menu.item.SimpleBrowserMenuItem
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 @@ -29,11 +31,11 @@ class TabHeaderViewHolder(
when (it) {
is TabHeaderMenu.Item.Share -> actionEmitter.onNext(TabAction.ShareTabs)
is TabHeaderMenu.Item.CloseAll -> actionEmitter.onNext(TabAction.CloseAll(isPrivate))
is TabHeaderMenu.Item.SaveToCollection -> actionEmitter.onNext(
TabAction.SaveTabGroup(
null
)
)
is TabHeaderMenu.Item.SaveToCollection -> {
actionEmitter.onNext(TabAction.SaveTabGroup(null))
view.context.components.analytics.metrics
.track(Event.CollectionSaveButtonPressed(TELEMETRY_HOME_MENU_IDENITIFIER))
}
}
}

Expand Down Expand Up @@ -99,6 +101,7 @@ class TabHeaderViewHolder(
}

companion object {
const val TELEMETRY_HOME_MENU_IDENITIFIER = "homeMenu"
const val LAYOUT_ID = R.layout.tab_header
}
}

0 comments on commit 7036eab

Please sign in to comment.