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

Commit

Permalink
Closes #977: Adds telemetry for custom tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Apr 17, 2019
1 parent cb7ad32 commit 92cfa3d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
37 changes: 36 additions & 1 deletion app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,39 @@ search.default_engine:
- https://github.com/mozilla-mobile/fenix/issues/1607
notification_emails:
- fenix-core@mozilla.com
expires: "2019-09-01"
expires: "2019-09-01"

custom_tab:
closed:
type: event
description: >
A user closed the custom tab
bugs:
- 977
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1697
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
action_button:
type: event
description: >
A user pressed the action button provided by the launching app
bugs:
- 977
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1697
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
menu:
type: event
description: >
A user opened the custom tabs menu
bugs:
- 977
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1697
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.mozilla.fenix.GleanMetrics.FindInPage
import org.mozilla.fenix.GleanMetrics.ContextMenu
import org.mozilla.fenix.GleanMetrics.QuickActionSheet
import org.mozilla.fenix.GleanMetrics.Metrics
import org.mozilla.fenix.GleanMetrics.CustomTab
import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine
import org.mozilla.fenix.ext.components

Expand Down Expand Up @@ -106,6 +107,15 @@ private val Event.wrapper
is Event.QuickActionSheetReadTapped -> EventWrapper<NoExtraKeys>(
{ QuickActionSheet.readTapped.record(it) }
)
is Event.CustomTabsMenuOpened -> EventWrapper<NoExtraKeys>(
{ CustomTab.menu.record(it) }
)
is Event.CustomTabsActionTapped -> EventWrapper<NoExtraKeys>(
{ CustomTab.actionButton.record(it) }
)
is Event.CustomTabsClosed -> EventWrapper<NoExtraKeys>(
{ CustomTab.closed.record(it) }
)

// Don't track other events with Glean
else -> null
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ sealed class Event {
object QuickActionSheetBookmarkTapped : Event()
object QuickActionSheetDownloadTapped : Event()
object QuickActionSheetReadTapped : Event()
object CustomTabsClosed : Event()
object CustomTabsActionTapped : Event()
object CustomTabsMenuOpened : Event()

// Interaction Events
data class SearchBarTapped(val source: Source) : Event() {
Expand Down Expand Up @@ -168,6 +171,7 @@ sealed class Event {
get() = null
}

@Suppress("ComplexMethod")
private fun Fact.toEvent(): Event? = when (Pair(component, item)) {
Pair(Component.FEATURE_FINDINPAGE, "previous") -> Event.FindInPagePrevious
Pair(Component.FEATURE_FINDINPAGE, "next") -> Event.FindInPageNext
Expand All @@ -177,6 +181,12 @@ private fun Fact.toEvent(): Event? = when (Pair(component, item)) {
metadata?.get("item")?.let { Event.ContextMenuItemTapped.create(it.toString()) }
}

Pair(Component.FEATURE_TOOLBAR, "menu") -> {
metadata?.get("customTab")?.let { Event.CustomTabsMenuOpened }
}
Pair(Component.FEATURE_CUSTOMTABS, "close") -> Event.CustomTabsClosed
Pair(Component.FEATURE_CUSTOMTABS, "action_button") -> Event.CustomTabsActionTapped

else -> null
}

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ object Deps {
const val espresso_contrib = "com.android.support.test.espresso:espresso-contrib:${Versions.espresso_version}"
const val espresso_core = "com.android.support.test.espresso:espresso-core:${Versions.espresso_core}"
const val espresso_idling_resources = "com.android.support.test.espresso:espresso-idling-resource:${Versions.espresso_version}"
const val orchestrator = "androidx.test:orchestrator:${Versions.orchestrator}"
const val orchestrator = "androidx.test:orchestrator:${Versions.orchestrator}"
const val tools_test_rules = "com.android.support.test:rules:${Versions.tools_test_rules}"
const val tools_test_runner = "com.android.support.test:runner:${Versions.tools_test_runner}"
const val uiautomator = "com.android.support.test.uiautomator:uiautomator-v18:${Versions.uiautomator}"
Expand Down

0 comments on commit 92cfa3d

Please sign in to comment.