Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge #7805
Browse files Browse the repository at this point in the history
7805: mozilla-mobile/fenix#10261: PWA install fact r=NotWoods a=eliserichards

Add additional PWA Fact for mozilla-mobile/fenix#10261
  * An event ping when installing a PWA shortcut.
    * `ProgressiveWebAppFacts.Items.INSTALL_SHORTCUT`


Co-authored-by: Elise Richards <erichards@mozilla.com>
  • Loading branch information
MozLando and eliserichards committed Jul 21, 2020
2 parents c8bcd3a + 4ee28d7 commit 4fec235
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/feature/pwa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ This component emits the following [Facts](../../support/base/README.md#Facts):

| Action | Item | Extras | Description |
|--------|---------|----------------|------------------------------------|
| CLICK | install_shortcut | | The user installs a PWA shortcut. |
| CLICK | homescreen_icon_tap | | The user tapped the PWA icon on the homescreen. |
| INTERACTION | enter_background | `itemExtras` | The current system time when the app is backgrounded. |
| INTERACTION | enter_foreground | `itemExtras` | The current system time when the app is foregrounded. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ProgressiveWebAppFacts {
* Items that specify which portion of the [PwaFeature] was interacted with
*/
object Items {
const val INSTALL_SHORTCUT = "install_shortcut"
const val HOMESCREEN_ICON_TAP = "homescreen_icon_tap"
const val ENTER_BACKGROUND = "enter_background"
const val ENTER_FOREGROUND = "enter_foreground"
Expand Down Expand Up @@ -58,6 +59,12 @@ internal fun emitHomescreenIconTapFact() =
ProgressiveWebAppFacts.Items.HOMESCREEN_ICON_TAP
)

internal fun emitPwaInstallFact() =
emitPwaFact(
Action.CLICK,
ProgressiveWebAppFacts.Items.INSTALL_SHORTCUT
)

internal fun emitForegroundTimingFact(timingNs: Long) =
emitPwaFact(
Action.INTERACTION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class WebAppShortcutManager(
if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {
val manifest = session.installableManifest()
val shortcut = if (supportWebApps && manifest != null) {
emitPwaInstallFact()
buildWebAppShortcut(context, manifest)
} else {
buildBasicShortcut(context, session, overrideShortcutName)
Expand Down

0 comments on commit 4fec235

Please sign in to comment.