Skip to content

Commit

Permalink
For mozilla-mobile#5021: Adds telemetry for what's new button
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Sep 4, 2019
1 parent 56128b6 commit 0f71093
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ private val Event.wrapper: EventWrapper<*>?
is Event.PrivateBrowsingNotificationDeleteAndOpenTapped -> EventWrapper<NoExtraKeys>(
{ PrivateBrowsingMode.notificationDelete.record(it) }
)
is Event.WhatsNewTapped -> EventWrapper(
{ Events.whatsNewTapped.record(it) },
{ Events.whatsNewTappedKeys.valueOf(it) }
)

// Don't record other events in Glean:
is Event.AddBookmark -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ sealed class Event {
get() = hashMapOf(Events.appOpenedKeys.source to source.name)
}

data class WhatsNewTapped(val source: Source) : Event() {
enum class Source { ABOUT, HOME }
override val extras: Map<Events.whatsNewTappedKeys, String>?
get() = hashMapOf(Events.whatsNewTappedKeys.source to source.name)
}

data class CollectionSaveButtonPressed(val fromScreen: String) : Event() {
override val extras: Map<Collections.saveButtonKeys, String>?
get() = mapOf(Collections.saveButtonKeys.fromScreen to fromScreen)
Expand Down
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 @@ -58,6 +58,7 @@ import org.mozilla.fenix.collections.SaveCollectionStep
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.TabCollectionStorage
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.metrics
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.sessionsOfType
Expand Down Expand Up @@ -577,6 +578,7 @@ class HomeFragment : Fragment(), AccountObserver {
invokePendingDeleteJobs()
hideOnboardingIfNeeded()
WhatsNew.userViewedWhatsNew(context!!)
context!!.metrics.track(Event.WhatsNewTapped(Event.WhatsNewTapped.Source.HOME))
(activity as HomeActivity).openToBrowserAndLoad(
searchTermOrURL = SupportUtils.getSumoURLForTopic(
context!!,
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/org/mozilla/fenix/settings/AboutFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.metrics
import org.mozilla.fenix.whatsnew.WhatsNew
import org.mozilla.geckoview.BuildConfig as GeckoViewBuildConfig

Expand Down Expand Up @@ -77,6 +79,7 @@ class AboutFragment : Fragment() {
with(whats_new_button) {
text = getString(R.string.about_whats_new, getString(R.string.app_name))
setOnClickListener {
context.metrics.track(Event.WhatsNewTapped(Event.WhatsNewTapped.Source.ABOUT))
WhatsNew.userViewedWhatsNew(context!!)
(activity as HomeActivity).openToBrowserAndLoad(
searchTermOrURL = SupportUtils.getSumoURLForTopic(
Expand Down

0 comments on commit 0f71093

Please sign in to comment.