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

Commit

Permalink
Move install event to AC and collect facts
Browse files Browse the repository at this point in the history
  • Loading branch information
Elise Richards committed Jul 21, 2020
1 parent 4901e82 commit 520d7eb
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 53 deletions.
31 changes: 10 additions & 21 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,11 +654,8 @@ private val Event.wrapper: EventWrapper<*>?
is Event.ProgressiveWebAppOpenFromHomescreenTap -> EventWrapper<NoExtraKeys>(
{ ProgressiveWebApp.homescreenTap.record(it) }
)
is Event.ProgressiveWebAppInstallMenuTap -> EventWrapper<NoExtraKeys>(
{ ProgressiveWebApp.installMenuTap.record(it) }
)
is Event.ProgressiveWebAppAddToHomescreenTap -> EventWrapper<NoExtraKeys>(
{ ProgressiveWebApp.addToHomescreenTap.record(it) }
is Event.ProgressiveWebAppInstallAsShortcut -> EventWrapper<NoExtraKeys>(
{ ProgressiveWebApp.installTap.record(it) }
)
is Event.ProgressiveWebAppForeground -> EventWrapper(
{ ProgressiveWebApp.foreground.record(it) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand All @@ -40,7 +38,6 @@ class PwaOnboardingDialogFragment : DialogFragment() {
add_button.setOnClickListener {
viewLifecycleOwner.lifecycleScope.launch {
components.useCases.webAppUseCases.addToHomescreen()
requireContext().metrics.track(Event.ProgressiveWebAppAddToHomescreenTap)
}.invokeOnCompletion {
dismiss()
}
Expand Down
9 changes: 4 additions & 5 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)|<ul><li>duration: The current time in ms when the PWA was put into the background. </li></ul>|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)|<ul><li>duration: The current time in ms when the PWA was brought to the foreground. </li></ul>|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)|<ul><li>duration: The current time in ms when the intent was backgrounded. </li></ul>|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)|<ul><li>duration: The current time in ms when the intent was foregrounded. </li></ul>|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 |
Expand Down

0 comments on commit 520d7eb

Please sign in to comment.