Skip to content

Commit

Permalink
For mozilla-mobile#16828 - Adds telemetry for open in app banner
Browse files Browse the repository at this point in the history
Specifically: Banner displayed, Dismiss action, Go to Settings action.
  • Loading branch information
codrut.topliceanu committed Dec 16, 2020
1 parent 9c15267 commit 030fc02
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 7 deletions.
41 changes: 41 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -28,6 +33,7 @@ class OpenInAppOnboardingObserver(

@VisibleForTesting
internal var sessionDomainForDisplayedBanner: String? = null

@VisibleForTesting
internal var infoBanner: InfoBanner? = null

Expand All @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -701,6 +702,16 @@ private val Event.wrapper: EventWrapper<*>?
{ Tabs.settingOpened.record(it) }
)

is Event.BannerOpenInAppDisplayed -> EventWrapper<NoExtraKeys>(
{ BannerOpenInApp.displayed.record(it) }
)
is Event.BannerOpenInAppDismissed -> EventWrapper<NoExtraKeys>(
{ BannerOpenInApp.dismissed.record(it) }
)
is Event.BannerOpenInAppGoToSettings -> EventWrapper<NoExtraKeys>(
{ BannerOpenInApp.goToSettings.record(it) }
)

// Don't record other events in Glean:
is Event.AddBookmark -> null
is Event.OpenedBookmark -> null
Expand Down
3 changes: 3 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)|<ul><li>source: The source from where dark theme was selected. The source can be 'SETTINGS' or 'ONBOARDING' </li></ul>|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)|<ul><li>autoplay_setting: The new setting for autoplay: block_cellular, block_audio, or block_all. </li></ul>|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 |
Expand Down

0 comments on commit 030fc02

Please sign in to comment.