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

Commit

Permalink
Track events for add to homescreen and install.
Browse files Browse the repository at this point in the history
  • Loading branch information
Elise Richards committed Jun 23, 2020
1 parent d97af28 commit 328ece5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 1 addition & 2 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2707,8 +2707,7 @@ progressive.web.app:
install_menu_tap:
type: event
description: |
A user opens the install PWA menu
bugs:
T bugs:
- https://github.com/mozilla-mobile/fenix/issues/10261
data_reviews:
- https://github.com/mozilla-mobile/fenix/issues/10261
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.mozilla.fenix.GleanMetrics.ErrorPage
import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.Logins
import org.mozilla.fenix.GleanMetrics.PerfAwesomebar
import org.mozilla.fenix.GleanMetrics.ProgressiveWebApp
import org.mozilla.fenix.GleanMetrics.SearchShortcuts
import org.mozilla.fenix.GleanMetrics.Tip
import org.mozilla.fenix.GleanMetrics.ToolbarSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ import org.mozilla.fenix.components.TopSiteStorage
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.getRootView
import org.mozilla.fenix.ext.metrics
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.navigateSafe
import org.mozilla.fenix.ext.sessionsOfType
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.settings.deletebrowsingdata.deleteAndQuit
import org.mozilla.fenix.utils.Do
import kotlin.coroutines.coroutineContext

/**
* An interface that handles the view manipulation of the BrowserToolbar, triggered by the Interactor
Expand Down Expand Up @@ -162,7 +164,10 @@ class DefaultBrowserToolbarController(
val settings = activity.settings()
lowPrioHighlightItems.forEach {
when (it) {
ToolbarMenu.Item.AddToHomeScreen -> settings.installPwaOpened = true
ToolbarMenu.Item.AddToHomeScreen -> {
settings.installPwaOpened = true
activity.metrics.track(Event.ProgressiveWebAppInstallMenuTap)
}
ToolbarMenu.Item.OpenInApp -> settings.openInAppOpened = true
}
}
Expand Down Expand Up @@ -222,6 +227,7 @@ class DefaultBrowserToolbarController(
with(activity.components.useCases.webAppUseCases) {
if (isInstallable()) {
addToHomescreen()
activity.metrics.track(Event.ProgressiveWebAppAddToHomescreenTap)
} else {
val directions =
BrowserFragmentDirections.actionBrowserFragmentToCreateShortcutFragment()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ class FirstTimePwaFragment : DialogFragment() {
add_button.setOnClickListener {
viewLifecycleOwner.lifecycleScope.launch {
components.useCases.webAppUseCases.addToHomescreen()
}.invokeOnCompletion {
requireContext().metrics.track(Event.AddonsOpenInSettings)
dismiss()
}
}.invokeOnCompletion { dismiss() }
}
}
}

0 comments on commit 328ece5

Please sign in to comment.