For #976: Adds telemetry for library
parent
ba790c5dd3
commit
c334c77bbe
|
@ -679,4 +679,42 @@ qr_scanner:
|
||||||
- https://github.com/mozilla-mobile/fenix/pull/2524#issuecomment-492739967
|
- https://github.com/mozilla-mobile/fenix/pull/2524#issuecomment-492739967
|
||||||
notification_emails:
|
notification_emails:
|
||||||
- fenix-core@mozilla.com
|
- fenix-core@mozilla.com
|
||||||
|
expires: "2020-03-01"
|
||||||
|
|
||||||
|
library:
|
||||||
|
opened:
|
||||||
|
type: event
|
||||||
|
description: >
|
||||||
|
A user opened the library
|
||||||
|
bugs:
|
||||||
|
- 976
|
||||||
|
data_reviews:
|
||||||
|
- https://github.com/mozilla-mobile/fenix/pull/2538#issuecomment-492830242
|
||||||
|
notification_emails:
|
||||||
|
- fenix-core@mozilla.com
|
||||||
|
expires: "2020-03-01"
|
||||||
|
closed:
|
||||||
|
type: event
|
||||||
|
description: >
|
||||||
|
A user closed the library
|
||||||
|
bugs:
|
||||||
|
- 976
|
||||||
|
data_reviews:
|
||||||
|
- https://github.com/mozilla-mobile/fenix/pull/2538#issuecomment-492830242
|
||||||
|
notification_emails:
|
||||||
|
- fenix-core@mozilla.com
|
||||||
|
expires: "2020-03-01"
|
||||||
|
selected_item:
|
||||||
|
type: event
|
||||||
|
description: >
|
||||||
|
A user selected a library item
|
||||||
|
extra_keys:
|
||||||
|
item:
|
||||||
|
description: "The library item the user selected"
|
||||||
|
bugs:
|
||||||
|
- 976
|
||||||
|
data_reviews:
|
||||||
|
- https://github.com/mozilla-mobile/fenix/pull/2538#issuecomment-492830242
|
||||||
|
notification_emails:
|
||||||
|
- fenix-core@mozilla.com
|
||||||
expires: "2020-03-01"
|
expires: "2020-03-01"
|
|
@ -24,6 +24,7 @@ import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.mozilla.fenix.GleanMetrics.QrScanner
|
import org.mozilla.fenix.GleanMetrics.QrScanner
|
||||||
|
import org.mozilla.fenix.GleanMetrics.Library
|
||||||
|
|
||||||
private class EventWrapper<T : Enum<T>>(
|
private class EventWrapper<T : Enum<T>>(
|
||||||
private val recorder: ((Map<T, String>?) -> Unit),
|
private val recorder: ((Map<T, String>?) -> Unit),
|
||||||
|
@ -172,6 +173,16 @@ private val Event.wrapper
|
||||||
is Event.QRScannerNavigationDenied -> EventWrapper<NoExtraKeys>(
|
is Event.QRScannerNavigationDenied -> EventWrapper<NoExtraKeys>(
|
||||||
{ QrScanner.navigationDenied.record(it) }
|
{ QrScanner.navigationDenied.record(it) }
|
||||||
)
|
)
|
||||||
|
is Event.LibraryOpened -> EventWrapper<NoExtraKeys>(
|
||||||
|
{ Library.opened.record(it) }
|
||||||
|
)
|
||||||
|
is Event.LibraryClosed -> EventWrapper<NoExtraKeys>(
|
||||||
|
{ Library.closed.record(it) }
|
||||||
|
)
|
||||||
|
is Event.LibrarySelectedItem -> EventWrapper(
|
||||||
|
{ Library.selectedItem },
|
||||||
|
{ Library.selectedItemKeys.valueOf(it) }
|
||||||
|
)
|
||||||
|
|
||||||
// Don't track other events with Glean
|
// Don't track other events with Glean
|
||||||
else -> null
|
else -> null
|
||||||
|
|
|
@ -78,6 +78,8 @@ sealed class Event {
|
||||||
object QRScannerPromptDisplayed : Event()
|
object QRScannerPromptDisplayed : Event()
|
||||||
object QRScannerNavigationAllowed : Event()
|
object QRScannerNavigationAllowed : Event()
|
||||||
object QRScannerNavigationDenied : Event()
|
object QRScannerNavigationDenied : Event()
|
||||||
|
object LibraryOpened : Event()
|
||||||
|
object LibraryClosed : Event()
|
||||||
|
|
||||||
data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() {
|
data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() {
|
||||||
private val switchPreferenceTelemetryAllowList = listOf(
|
private val switchPreferenceTelemetryAllowList = listOf(
|
||||||
|
@ -103,6 +105,11 @@ sealed class Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interaction Events
|
// Interaction Events
|
||||||
|
data class LibrarySelectedItem(val item: String) : Event() {
|
||||||
|
override val extras: Map<String, String>?
|
||||||
|
get() = mapOf("source" to item)
|
||||||
|
}
|
||||||
|
|
||||||
data class SearchBarTapped(val source: Source) : Event() {
|
data class SearchBarTapped(val source: Source) : Event() {
|
||||||
enum class Source { HOME, BROWSER }
|
enum class Source { HOME, BROWSER }
|
||||||
override val extras: Map<String, String>?
|
override val extras: Map<String, String>?
|
||||||
|
|
|
@ -20,8 +20,9 @@ import androidx.navigation.Navigation
|
||||||
import kotlinx.android.synthetic.main.fragment_library.*
|
import kotlinx.android.synthetic.main.fragment_library.*
|
||||||
import mozilla.appservices.places.BookmarkRoot
|
import mozilla.appservices.places.BookmarkRoot
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.components.metrics.Event
|
||||||
import org.mozilla.fenix.ext.getColorFromAttr
|
import org.mozilla.fenix.ext.getColorFromAttr
|
||||||
import org.mozilla.fenix.library.bookmarks.BookmarkFragmentArgs
|
import org.mozilla.fenix.ext.requireComponents
|
||||||
|
|
||||||
class LibraryFragment : Fragment() {
|
class LibraryFragment : Fragment() {
|
||||||
|
|
||||||
|
@ -49,19 +50,21 @@ class LibraryFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
libraryHistory.setOnClickListener(
|
libraryHistory.setOnClickListener {
|
||||||
Navigation.createNavigateOnClickListener(
|
requireComponents.analytics.metrics
|
||||||
LibraryFragmentDirections.actionLibraryFragmentToHistoryFragment().actionId,
|
.track(Event.LibrarySelectedItem(view.context.getString(R.string.library_history)))
|
||||||
null
|
Navigation.findNavController(view)
|
||||||
)
|
.navigate(LibraryFragmentDirections.actionLibraryFragmentToHistoryFragment())
|
||||||
)
|
}
|
||||||
|
|
||||||
libraryBookmarks.setOnClickListener(
|
libraryBookmarks.setOnClickListener {
|
||||||
Navigation.createNavigateOnClickListener(
|
requireComponents.analytics.metrics
|
||||||
LibraryFragmentDirections.actionLibraryFragmentToBookmarksFragment(BookmarkRoot.Mobile.id).actionId,
|
.track(Event.LibrarySelectedItem(view.context.getString(R.string.library_bookmarks)))
|
||||||
BookmarkFragmentArgs(BookmarkRoot.Mobile.id).toBundle()
|
Navigation.findNavController(view)
|
||||||
)
|
.navigate(LibraryFragmentDirections.actionLibraryFragmentToBookmarksFragment(BookmarkRoot.Mobile.id))
|
||||||
)
|
}
|
||||||
|
|
||||||
|
requireComponents.analytics.metrics.track(Event.LibraryOpened)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
|
@ -78,6 +81,11 @@ class LibraryFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
requireComponents.analytics.metrics.track(Event.LibraryClosed)
|
||||||
|
}
|
||||||
|
|
||||||
private fun setToolbarColor() {
|
private fun setToolbarColor() {
|
||||||
val toolbar = (activity as AppCompatActivity).findViewById<Toolbar>(R.id.navigationToolbar)
|
val toolbar = (activity as AppCompatActivity).findViewById<Toolbar>(R.id.navigationToolbar)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue