diff --git a/app/metrics.yaml b/app/metrics.yaml index 8f6afce09103..7d79fc1b8608 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -3140,42 +3140,31 @@ progressive_web_app: bugs: - https://github.com/mozilla-mobile/fenix/issues/10261 data_reviews: - - https://github.com/mozilla-mobile/fenix/issues/10261 - notification_emails: - - fenix-core@mozilla.com - - erichards@mozilla.com - expires: "2020-09-01" - install_menu_tap: - type: event - description: | - bugs: - - https://github.com/mozilla-mobile/fenix/issues/10261 - data_reviews: - - https://github.com/mozilla-mobile/fenix/issues/10261 + - https://github.com/mozilla-mobile/fenix/pull/11859 notification_emails: - fenix-core@mozilla.com - erichards@mozilla.com - expires: "2020-09-01" - add_to_homescreen_tap: + expires: "2020-10-01" + install_tap: type: event description: | - A user taps the add to homescreen icon for a PWA + A user installs a PWA. Could be a shortcut or added to homescreen. bugs: - https://github.com/mozilla-mobile/fenix/issues/10261 data_reviews: - - https://github.com/mozilla-mobile/fenix/issues/10261 + - https://github.com/mozilla-mobile/fenix/pull/11859 notification_emails: - fenix-core@mozilla.com - erichards@mozilla.com - expires: "2020-09-01" + expires: "2020-10-01" foreground: type: event description: | - A user brings the PWA into the foreground. + An intent receiver activity is foregrounded for PWA. extra_keys: duration: description: | - The current time in ms when the PWA was brought to the foreground. + The current time in ms when the intent was foregrounded. bugs: - https://github.com/mozilla-mobile/fenix/issues/10261 data_reviews: @@ -3187,11 +3176,11 @@ progressive_web_app: background: type: event description: | - A user puts the PWA into the background. + An intent receiver activity is backgrounded for PWA. extra_keys: duration: description: | - The current time in ms when the PWA was put into the background. + The current time in ms when the intent was backgrounded. bugs: - https://github.com/mozilla-mobile/fenix/issues/10261 data_reviews: diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt index f8aaaba3f045..70d5d27c9b2d 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt @@ -654,11 +654,8 @@ private val Event.wrapper: EventWrapper<*>? is Event.ProgressiveWebAppOpenFromHomescreenTap -> EventWrapper( { ProgressiveWebApp.homescreenTap.record(it) } ) - is Event.ProgressiveWebAppInstallMenuTap -> EventWrapper( - { ProgressiveWebApp.installMenuTap.record(it) } - ) - is Event.ProgressiveWebAppAddToHomescreenTap -> EventWrapper( - { ProgressiveWebApp.addToHomescreenTap.record(it) } + is Event.ProgressiveWebAppInstallAsShortcut -> EventWrapper( + { ProgressiveWebApp.installTap.record(it) } ) is Event.ProgressiveWebAppForeground -> EventWrapper( { ProgressiveWebApp.foreground.record(it) }, diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt index 4bb8a1811b16..3e97f2ebac79 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt @@ -205,8 +205,7 @@ sealed class Event { object TabsTrayCloseAllTabsPressed : Event() object ProgressiveWebAppOpenFromHomescreenTap : Event() - object ProgressiveWebAppInstallMenuTap : Event() - object ProgressiveWebAppAddToHomescreenTap : Event() + object ProgressiveWebAppInstallAsShortcut : Event() // Interaction events with extras @@ -603,6 +602,9 @@ private fun Fact.toEvent(): Event? = when (Pair(component, item)) { Component.FEATURE_PWA to ProgressiveWebAppFacts.Items.HOMESCREEN_ICON_TAP -> { Event.ProgressiveWebAppOpenFromHomescreenTap } + Component.FEATURE_PWA to ProgressiveWebAppFacts.Items.INSTALL_SHORTCUT -> { + Event.ProgressiveWebAppInstallAsShortcut + } Component.FEATURE_PWA to ProgressiveWebAppFacts.Items.ENTER_BACKGROUND -> { metadata?.get(ProgressiveWebAppFacts.MetadataKeys.BACKGROUND_TIME)?.let { duration -> require(duration is Long) { "Expected duration to be a Long" } diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarController.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarController.kt index 84a0be44d49e..048670b357f0 100644 --- a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarController.kt +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarController.kt @@ -207,28 +207,12 @@ class DefaultBrowserToolbarController( .show() } } - ToolbarMenu.Item.AddToHomeScreen -> { + ToolbarMenu.Item.AddToHomeScreen, ToolbarMenu.Item.InstallToHomeScreen -> { activity.settings().installPwaOpened = true MainScope().launch { with(activity.components.useCases.webAppUseCases) { if (isInstallable()) { addToHomescreen() - activity.metrics.track(Event.ProgressiveWebAppAddToHomescreenTap) - } else { - val directions = - BrowserFragmentDirections.actionBrowserFragmentToCreateShortcutFragment() - navController.navigateSafe(R.id.browserFragment, directions) - } - } - } - } - ToolbarMenu.Item.InstallToHomeScreen -> { - activity.settings().installPwaOpened = true - MainScope().launch { - with(activity.components.useCases.webAppUseCases) { - if (isInstallable()) { - addToHomescreen() - activity.metrics.track(Event.ProgressiveWebAppInstallMenuTap) } else { val directions = BrowserFragmentDirections.actionBrowserFragmentToCreateShortcutFragment() diff --git a/app/src/main/java/org/mozilla/fenix/shortcut/PwaOnboardingDialogFragment.kt b/app/src/main/java/org/mozilla/fenix/shortcut/PwaOnboardingDialogFragment.kt index 4859511c5f12..05d8520e3e16 100644 --- a/app/src/main/java/org/mozilla/fenix/shortcut/PwaOnboardingDialogFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/shortcut/PwaOnboardingDialogFragment.kt @@ -13,8 +13,6 @@ import androidx.lifecycle.lifecycleScope import kotlinx.android.synthetic.main.fragment_create_shortcut.* import kotlinx.coroutines.launch import org.mozilla.fenix.R -import org.mozilla.fenix.components.metrics.Event -import org.mozilla.fenix.ext.metrics import org.mozilla.fenix.ext.requireComponents /** @@ -40,7 +38,6 @@ class PwaOnboardingDialogFragment : DialogFragment() { add_button.setOnClickListener { viewLifecycleOwner.lifecycleScope.launch { components.useCases.webAppUseCases.addToHomescreen() - requireContext().metrics.track(Event.ProgressiveWebAppAddToHomescreenTap) }.invokeOnCompletion { dismiss() } diff --git a/docs/metrics.md b/docs/metrics.md index c0469c32192d..0f308147534e 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -152,11 +152,10 @@ The following metrics are added to the ping: | private_browsing_shortcut.pinned_shortcut_priv |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the pinned private shortcut in Android home screen, opening up a new private search. |[1](https://github.com/mozilla-mobile/fenix/pull/5194)||2020-10-01 | | private_browsing_shortcut.static_shortcut_priv |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the long-press shortcut "Open new private tab", opening up a new private search. |[1](https://github.com/mozilla-mobile/fenix/pull/5194)||2020-10-01 | | private_browsing_shortcut.static_shortcut_tab |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the long-press shortcut "Open new tab", opening up a new search. |[1](https://github.com/mozilla-mobile/fenix/pull/5194)||2020-10-01 | -| progressive_web_app.add_to_homescreen_tap |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user taps the add to homescreen icon for a PWA |[1](https://github.com/mozilla-mobile/fenix/issues/10261)||2020-09-01 | -| progressive_web_app.background |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user puts the PWA into the background. |[1](https://github.com/mozilla-mobile/fenix/pull/11859)|
  • duration: The current time in ms when the PWA was put into the background.
|2020-10-01 | -| progressive_web_app.foreground |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user brings the PWA into the foreground. |[1](https://github.com/mozilla-mobile/fenix/pull/11859)|
  • duration: The current time in ms when the PWA was brought to the foreground.
|2020-10-01 | -| progressive_web_app.homescreen_tap |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user taps on PWA homescreen icon |[1](https://github.com/mozilla-mobile/fenix/issues/10261)||2020-09-01 | -| progressive_web_app.install_menu_tap |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) | |[1](https://github.com/mozilla-mobile/fenix/issues/10261)||2020-09-01 | +| progressive_web_app.background |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |An intent receiver activity is backgrounded for PWA. |[1](https://github.com/mozilla-mobile/fenix/pull/11859)|
  • duration: The current time in ms when the intent was backgrounded.
|2020-10-01 | +| progressive_web_app.foreground |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |An intent receiver activity is foregrounded for PWA. |[1](https://github.com/mozilla-mobile/fenix/pull/11859)|
  • duration: The current time in ms when the intent was foregrounded.
|2020-10-01 | +| progressive_web_app.homescreen_tap |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user taps on PWA homescreen icon |[1](https://github.com/mozilla-mobile/fenix/pull/11859)||2020-10-01 | +| progressive_web_app.install_tap |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user installs a PWA. Could be a shortcut or added to homescreen. |[1](https://github.com/mozilla-mobile/fenix/pull/11859)||2020-10-01 | | qr_scanner.navigation_allowed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped "allow" on the prompt, directing the user to the website scanned |[1](https://github.com/mozilla-mobile/fenix/pull/2524#issuecomment-492739967)||2020-10-01 | | qr_scanner.navigation_denied |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped "deny" on the prompt, putting the user back to the scanning view |[1](https://github.com/mozilla-mobile/fenix/pull/2524#issuecomment-492739967)||2020-10-01 | | qr_scanner.opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened the QR scanner |[1](https://github.com/mozilla-mobile/fenix/pull/2524#issuecomment-492739967)||2020-10-01 |