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

Commit

Permalink
For #11580 - Tracks text selection context menu usage
Browse files Browse the repository at this point in the history
Tracks Copy, Search, Select All and Share items from the text selection context menu. Uses AC's DefaultSelectionActionDelegate to achieve this.
  • Loading branch information
codrut.topliceanu committed Dec 10, 2020
1 parent 9d5ec47 commit 18f57a2
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 1 deletion.
67 changes: 67 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4065,3 +4065,70 @@ tabs:
notification_emails:
- fenix-core@mozilla.com
expires: "2021-08-01"

contextual_menu:
long_press_tapped:
type: boolean
description: |
Text selection contextual menu option tapped.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11580
data_reviews:
- TODO
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2021-06-01"
copy_tapped:
type: event
description: |
The context menu's 'copy' option was used.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11580
data_reviews:
- TODO
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2021-06-01"
search_tapped:
type: event
description: |
The context menu's 'search' option was used.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11580
data_reviews:
- TODO
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2021-06-01"
select_all_tapped:
type: event
description: |
The context menu's 'select all' option was used.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11580
data_reviews:
- TODO
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2021-06-01"
share_tapped:
type: event
description: |
The context menu's 'share' option was used.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11580
data_reviews:
- TODO
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2021-06-01"
27 changes: 26 additions & 1 deletion app/src/main/java/org/mozilla/fenix/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,21 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
components.appStartupTelemetry.onHomeActivityOnNewIntent(intent.toSafeIntent())
}

/**
* Used to track text selection context menu option use. See #11580.
* */
private fun trackContextMenuOption(clickedOption: String) {
components.analytics.metrics.track(Event.ContextMenuLongPressTapped)
when (clickedOption) {
CONTEXT_MENU_COPY -> components.analytics.metrics.track(Event.ContextMenuCopyTapped)
CONTEXT_MENU_SEARCH, CONTEXT_MENU_SEARCH_PRIVATELY -> components.analytics.metrics.track(
Event.ContextMenuSearchTapped
)
CONTEXT_MENU_SELECT_ALL -> components.analytics.metrics.track(Event.ContextMenuSelectAllTapped)
CONTEXT_MENU_SHARE -> components.analytics.metrics.track(Event.ContextMenuShareTapped)
}
}

/**
* Overrides view inflation to inject a custom [EngineView] from [components].
*/
Expand All @@ -460,7 +475,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
shareTextClicked = { share(it) },
emailTextClicked = { email(it) },
callTextClicked = { call(it) },
actionSorter = ::actionSorter
actionSorter = ::actionSorter,
trackContextMenuOption = ::trackContextMenuOption
)
}.asView()
else -> super.onCreateView(parent, name, context, attrs)
Expand Down Expand Up @@ -849,6 +865,15 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
const val EXTRA_OPENED_FROM_NOTIFICATION = "notification_open"
const val START_IN_RECENTS_SCREEN = "start_in_recents_screen"

/**
* Text selection long press context items to be tracked.
* */
const val CONTEXT_MENU_COPY = "org.mozilla.geckoview.COPY"
const val CONTEXT_MENU_SEARCH = "CUSTOM_CONTEXT_MENU_SEARCH"
const val CONTEXT_MENU_SEARCH_PRIVATELY = "CUSTOM_CONTEXT_MENU_SEARCH_PRIVATELY"
const val CONTEXT_MENU_SELECT_ALL = "org.mozilla.geckoview.SELECT_ALL"
const val CONTEXT_MENU_SHARE = "CUSTOM_CONTEXT_MENU_SHARE"

// PWA must have been used within last 30 days to be considered "recently used" for the
// telemetry purposes.
const val PWA_RECENTLY_USED_THRESHOLD = DateUtils.DAY_IN_MILLIS * 30L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ sealed class Event {

object TabSettingsOpened : Event()

object ContextMenuLongPressTapped : Event()
object ContextMenuCopyTapped : Event()
object ContextMenuSearchTapped : Event()
object ContextMenuSelectAllTapped : Event()
object ContextMenuShareTapped : 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 @@ -22,6 +22,7 @@ import org.mozilla.fenix.GleanMetrics.BrowserSearch
import org.mozilla.fenix.GleanMetrics.Collections
import org.mozilla.fenix.GleanMetrics.ContextMenu
import org.mozilla.fenix.GleanMetrics.ContextualHintTrackingProtection
import org.mozilla.fenix.GleanMetrics.ContextualMenu
import org.mozilla.fenix.GleanMetrics.CrashReporter
import org.mozilla.fenix.GleanMetrics.CustomTab
import org.mozilla.fenix.GleanMetrics.DownloadNotification
Expand Down Expand Up @@ -669,6 +670,21 @@ private val Event.wrapper: EventWrapper<*>?
Event.TabSettingsOpened -> EventWrapper<NoExtraKeys>(
{ Tabs.settingOpened.record(it) }
)
Event.ContextMenuLongPressTapped -> EventWrapper<NoExtraKeys>(
{ ContextualMenu.longPressTapped.set(true) }
)
Event.ContextMenuCopyTapped -> EventWrapper<NoExtraKeys>(
{ ContextualMenu.copyTapped.record(it) }
)
Event.ContextMenuSearchTapped -> EventWrapper<NoExtraKeys>(
{ ContextualMenu.searchTapped.record(it) }
)
Event.ContextMenuSelectAllTapped -> EventWrapper<NoExtraKeys>(
{ ContextualMenu.selectAllTapped.record(it) }
)
Event.ContextMenuShareTapped -> EventWrapper<NoExtraKeys>(
{ ContextualMenu.shareTapped.record(it) }
)

// Don't record other events in Glean:
is Event.AddBookmark -> null
Expand Down
5 changes: 5 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ The following metrics are added to the ping:
| contextual_hint.tracking_protection.display |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The enhanced tracking protection contextual hint was displayed. |[1](https://github.com/mozilla-mobile/fenix/pull/11923), [2](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 |
| contextual_hint.tracking_protection.inside_tap |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The user tapped inside of the etp contextual hint (which brings up the etp panel for this site). |[1](https://github.com/mozilla-mobile/fenix/pull/11923), [2](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 |
| contextual_hint.tracking_protection.outside_tap |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The user tapped outside of the etp contextual hint (which has no effect). |[1](https://github.com/mozilla-mobile/fenix/pull/11923), [2](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 |
| contextual_menu.copy_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The context menu's 'copy' option was used. |[1](TODO)||2021-06-01 |2 |
| contextual_menu.search_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The context menu's 'search' option was used. |[1](TODO)||2021-06-01 |2 |
| contextual_menu.select_all_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The context menu's 'select all' option was used. |[1](TODO)||2021-06-01 |2 |
| contextual_menu.share_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The context menu's 'share' option was used. |[1](TODO)||2021-06-01 |2 |
| crash_reporter.closed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The crash reporter was closed |[1](https://github.com/mozilla-mobile/fenix/pull/1214#issue-264756708), [2](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)|<ul><li>crash_submitted: A boolean that tells us whether or not the user submitted a crash report </li></ul>|2021-04-01 |2 |
| crash_reporter.opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The crash reporter was displayed |[1](https://github.com/mozilla-mobile/fenix/pull/1214#issue-264756708), [2](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 |
| custom_tab.action_button |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the action button provided by the launching app |[1](https://github.com/mozilla-mobile/fenix/pull/1697), [2](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 |
Expand Down Expand Up @@ -261,6 +265,7 @@ The following metrics are added to the ping:
| browser.search.ad_clicks |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Records clicks of adverts on SERP pages. The key format is ‘<provider-name>’. |[1](https://github.com/mozilla-mobile/fenix/pull/10112), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 |
| browser.search.in_content |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Records the type of interaction a user has on SERP pages. |[1](https://github.com/mozilla-mobile/fenix/pull/10167), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 |
| browser.search.with_ads |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Records counts of SERP pages with adverts displayed. The key format is ‘<provider-name>’. |[1](https://github.com/mozilla-mobile/fenix/pull/10112), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 |
| contextual_menu.long_press_tapped |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Text selection contextual menu option tapped. |[1](TODO)||2021-06-01 |2 |
| events.total_uri_count |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |A counter of URIs visited by the user in the current session, including page reloads. This does not include background page requests and URIs from embedded pages or private browsing but may be incremented without user interaction by website scripts that programmatically redirect to a new location. |[1](https://github.com/mozilla-mobile/fenix/pull/1785), [2](https://github.com/mozilla-mobile/fenix/pull/8314), [3](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 |
| metrics.adjust_ad_group |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string containing the Adjust ad group ID from which the user installed Fenix. This will not send on the first session the user runs. If the install is organic, this will be empty. |[1](https://github.com/mozilla-mobile/fenix/pull/9253), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 |
| metrics.adjust_campaign |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string containing the Adjust campaign ID from which the user installed Fenix. This will not send on the first session the user runs. If the install is organic, this will be empty. |[1](https://github.com/mozilla-mobile/fenix/pull/5579), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |1 |
Expand Down

0 comments on commit 18f57a2

Please sign in to comment.