diff --git a/app/metrics.yaml b/app/metrics.yaml index aee2119aad6a..de15a101869b 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -4260,3 +4260,44 @@ tabs: notification_emails: - fenix-core@mozilla.com expires: "2021-08-01" + +banner_open_in_app: + displayed: + type: event + description: | + Open in App banner was shown. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/16828 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/17049 + data_sensitivity: + - interaction + notification_emails: + - fenix-core@mozilla.com + expires: "2021-06-01" + dismissed: + type: event + description: | + User tapped 'dismiss' on Open in App banner. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/16828 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/17049 + data_sensitivity: + - interaction + notification_emails: + - fenix-core@mozilla.com + expires: "2021-06-01" + go_to_settings: + type: event + description: | + User tapped 'go to settings' on Open in App banner. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/16828 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/17049 + data_sensitivity: + - interaction + notification_emails: + - fenix-core@mozilla.com + expires: "2021-06-01" diff --git a/app/src/main/java/org/mozilla/fenix/browser/OpenInAppOnboardingObserver.kt b/app/src/main/java/org/mozilla/fenix/browser/OpenInAppOnboardingObserver.kt index 0abb13a5d0d9..14a2b146e300 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/OpenInAppOnboardingObserver.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/OpenInAppOnboardingObserver.kt @@ -12,6 +12,11 @@ import mozilla.components.browser.session.Session import mozilla.components.feature.app.links.AppLinksUseCases import mozilla.components.support.ktx.kotlin.tryGetHostFromUrl import org.mozilla.fenix.R +import org.mozilla.fenix.R.id +import org.mozilla.fenix.R.string +import org.mozilla.fenix.components.metrics.Event +import org.mozilla.fenix.components.metrics.Event.BannerOpenInAppGoToSettings +import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.nav import org.mozilla.fenix.utils.Settings @@ -28,6 +33,7 @@ class OpenInAppOnboardingObserver( @VisibleForTesting internal var sessionDomainForDisplayedBanner: String? = null + @VisibleForTesting internal var infoBanner: InfoBanner? = null @@ -52,17 +58,27 @@ class OpenInAppOnboardingObserver( message = context.getString(R.string.open_in_app_cfr_info_message), dismissText = context.getString(R.string.open_in_app_cfr_negative_button_text), actionText = context.getString(R.string.open_in_app_cfr_positive_button_text), - container = container - ) { - val directions = BrowserFragmentDirections.actionBrowserFragmentToSettingsFragment( - preferenceToScrollTo = context.getString(R.string.pref_key_open_links_in_external_app) - ) - navController.nav(R.id.browserFragment, directions) - } + container = container, + dismissAction = ::dismissAction, + actionToPerform = ::actionToPerform + ) + context.components.analytics.metrics.track(Event.BannerOpenInAppDisplayed) infoBanner?.showBanner() sessionDomainForDisplayedBanner = session.url.tryGetHostFromUrl() settings.shouldShowOpenInAppBanner = false } } + + private fun dismissAction() { + context.components.analytics.metrics.track(Event.BannerOpenInAppDismissed) + } + + private fun actionToPerform() { + val directions = BrowserFragmentDirections.actionBrowserFragmentToSettingsFragment( + preferenceToScrollTo = context.getString(string.pref_key_open_links_in_external_app) + ) + context.components.analytics.metrics.track(BannerOpenInAppGoToSettings) + navController.nav(id.browserFragment, directions) + } } diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt index cc00144b0a02..5059028b9330 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt @@ -195,6 +195,10 @@ sealed class Event { object RecentlyClosedTabsOpened : Event() + object BannerOpenInAppDisplayed : Event() + object BannerOpenInAppDismissed : Event() + object BannerOpenInAppGoToSettings : Event() + // Interaction events with extras data class TopSiteSwipeCarousel(val page: Int) : Event() { 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 19c5bd0c0ccb..3e1d2b475642 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 @@ -17,6 +17,7 @@ import org.mozilla.fenix.GleanMetrics.AboutPage import org.mozilla.fenix.GleanMetrics.Addons import org.mozilla.fenix.GleanMetrics.AppTheme import org.mozilla.fenix.GleanMetrics.Autoplay +import org.mozilla.fenix.GleanMetrics.BannerOpenInApp import org.mozilla.fenix.GleanMetrics.BookmarksManagement import org.mozilla.fenix.GleanMetrics.BrowserSearch import org.mozilla.fenix.GleanMetrics.Collections @@ -701,6 +702,16 @@ private val Event.wrapper: EventWrapper<*>? { Tabs.settingOpened.record(it) } ) + is Event.BannerOpenInAppDisplayed -> EventWrapper( + { BannerOpenInApp.displayed.record(it) } + ) + is Event.BannerOpenInAppDismissed -> EventWrapper( + { BannerOpenInApp.dismissed.record(it) } + ) + is Event.BannerOpenInAppGoToSettings -> EventWrapper( + { BannerOpenInApp.goToSettings.record(it) } + ) + // Don't record other events in Glean: is Event.AddBookmark -> null is Event.OpenedBookmark -> null diff --git a/docs/metrics.md b/docs/metrics.md index e54034a39b54..f25d837b3595 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -55,6 +55,9 @@ The following metrics are added to the ping: | app_theme.dark_theme_selected |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user selected Dark Theme |[1](https://github.com/mozilla-mobile/fenix/pull/7968), [2](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)|
  • source: The source from where dark theme was selected. The source can be 'SETTINGS' or 'ONBOARDING'
|2021-04-01 |2 | | autoplay.setting_changed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user changed their autoplay setting to either block_cellular, block_audio, or block_all. |[1](https://github.com/mozilla-mobile/fenix/pull/13041#issuecomment-665777411)|
  • autoplay_setting: The new setting for autoplay: block_cellular, block_audio, or block_all.
|2021-02-01 |2 | | autoplay.visited_setting |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user visited the autoplay settings screen |[1](https://github.com/mozilla-mobile/fenix/pull/13041#issuecomment-665777411)||2021-02-01 |2 | +| banner_open_in_app.dismissed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |User tapped 'dismiss' on Open in App banner. |[1](https://github.com/mozilla-mobile/fenix/pull/17049)||2021-06-01 |2 | +| banner_open_in_app.displayed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Open in App banner was shown. |[1](https://github.com/mozilla-mobile/fenix/pull/17049)||2021-06-01 |2 | +| banner_open_in_app.go_to_settings |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |User tapped 'go to settings' on Open in App banner. |[1](https://github.com/mozilla-mobile/fenix/pull/17049)||2021-06-01 |2 | | bookmarks_management.copied |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user copied a bookmark. |[1](https://github.com/mozilla-mobile/fenix/pull/1708), [2](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 | | bookmarks_management.edited |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user edited the title and/or URL of an existing bookmark. |[1](https://github.com/mozilla-mobile/fenix/pull/1708), [2](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 | | bookmarks_management.folder_add |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user added a new bookmark folder. |[1](https://github.com/mozilla-mobile/fenix/pull/1708), [2](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 |