1
0
Fork 0

For #959 - Adds search related telemetry

master
Jeff Boek 2019-03-18 16:09:27 -07:00
parent 786592e8d0
commit 32f8e06e98
5 changed files with 86 additions and 34 deletions

View File

@ -31,6 +31,32 @@ events:
notification_emails:
- telemetry-client-dev@mozilla.com
expires: never
entered_url:
type: event
description: >
A user entered a url
extra_keys:
autocomplete: "The url was filled by the autocomplete"
bugs:
- 123456789
data_reviews:
- N/A
notification_emails:
- telemetry-client-dev@mozilla.com
expires: never
performed_search:
type: event
description: >
A user performed a search
extra_keys:
search_suggestion: "The search was initiated from a search suggestion"
bugs:
- 123456789
data_reviews:
- N/A
notification_emails:
- telemetry-client-dev@mozilla.com
expires: never
metrics:
default_browser:

View File

@ -16,6 +16,8 @@ private val Event.metricType: EventMetricType?
get() = when(this) {
is Event.OpenedApp -> Events.appOpened
is Event.SearchBarTapped -> Events.searchBarTapped
is Event.EnteredUrl -> Events.enteredUrl
is Event.PerformedSearch -> Events.performedSearch
else -> null
}

View File

@ -13,41 +13,43 @@ import org.mozilla.fenix.utils.Settings
private val Event.name: String?
get() = when (this) {
is Event.AddBookmark -> "E_Add_Bookmark"
is Event.RemoveBookmark -> "E_Remove_Bookmark"
is Event.OpenedBookmark -> "E_Opened_Bookmark"
is Event.OpenedApp -> "E_Opened_App"
is Event.OpenedAppFirstRun -> "E_Opened_App_FirstRun"
is Event.InteractWithSearchURLArea -> "E_Interact_With_Search_URL_Area"
is Event.SavedLoginandPassword -> "E_Saved_Login_and_Password"
is Event.FXANewSignup -> "E_FXA_New_Signup"
is Event.UserSignedInToFxA -> "E_User_Signed_In_To_FxA"
is Event.UserDownloadedFocus -> "E_User_Downloaded_Focus"
is Event.UserDownloadedLockbox -> "E_User_Downloaded_Lockbox"
is Event.UserDownloadedFennec -> "E_User_Downloaded_Fennec"
is Event.TrackingProtectionSettingsChanged -> "E_Tracking_Protection_Settings_Changed"
is Event.FXASyncedNewDevice -> "E_FXA_Synced_New_Device"
is Event.DismissedOnboarding -> "E_Dismissed_Onboarding"
is Event.Uninstall -> "E_Uninstall"
is Event.OpenNewNormalTab -> "E_Open_New_Normal_Tab"
is Event.OpenNewPrivateTab -> "E_Open_New_Private_Tab"
is Event.ShareStarted -> "E_Share_Started"
is Event.ShareCanceled -> "E_Share_Canceled"
is Event.ShareCompleted -> "E_Share_Completed"
is Event.ClosePrivateTabs -> "E_Close_Private_Tabs"
is Event.ClearedPrivateData -> "E_Cleared_Private_Data"
is Event.OpenedLoginManager -> "E_Opened_Login_Manager"
is Event.OpenedMailtoLink -> "E_Opened_Mailto_Link"
is Event.DownloadMediaSavedImage -> "E_Download_Media_Saved_Image"
is Event.UserUsedReaderView -> "E_User_Used_Reader_View"
is Event.UserDownloadedPocket -> "E_User_Downloaded_Pocket"
is Event.UserDownloadedSend -> "E_User_Downloaded_Send"
is Event.OpenedPocketStory -> "E_Opened_Pocket_Story"
is Event.DarkModeEnabled -> "E_Dark_Mode_Enabled"
is Event.AddBookmark -> "E_Add_Bookmark"
is Event.RemoveBookmark -> "E_Remove_Bookmark"
is Event.OpenedBookmark -> "E_Opened_Bookmark"
is Event.OpenedApp -> "E_Opened_App"
is Event.OpenedAppFirstRun -> "E_Opened_App_FirstRun"
is Event.InteractWithSearchURLArea -> "E_Interact_With_Search_URL_Area"
is Event.SavedLoginandPassword -> "E_Saved_Login_and_Password"
is Event.FXANewSignup -> "E_FXA_New_Signup"
is Event.UserSignedInToFxA -> "E_User_Signed_In_To_FxA"
is Event.UserDownloadedFocus -> "E_User_Downloaded_Focus"
is Event.UserDownloadedLockbox -> "E_User_Downloaded_Lockbox"
is Event.UserDownloadedFennec -> "E_User_Downloaded_Fennec"
is Event.TrackingProtectionSettingsChanged -> "E_Tracking_Protection_Settings_Changed"
is Event.FXASyncedNewDevice -> "E_FXA_Synced_New_Device"
is Event.DismissedOnboarding -> "E_Dismissed_Onboarding"
is Event.Uninstall -> "E_Uninstall"
is Event.OpenNewNormalTab -> "E_Open_New_Normal_Tab"
is Event.OpenNewPrivateTab -> "E_Open_New_Private_Tab"
is Event.ShareStarted -> "E_Share_Started"
is Event.ShareCanceled -> "E_Share_Canceled"
is Event.ShareCompleted -> "E_Share_Completed"
is Event.ClosePrivateTabs -> "E_Close_Private_Tabs"
is Event.ClearedPrivateData -> "E_Cleared_Private_Data"
is Event.OpenedLoginManager -> "E_Opened_Login_Manager"
is Event.OpenedMailtoLink -> "E_Opened_Mailto_Link"
is Event.DownloadMediaSavedImage -> "E_Download_Media_Saved_Image"
is Event.UserUsedReaderView -> "E_User_Used_Reader_View"
is Event.UserDownloadedPocket -> "E_User_Downloaded_Pocket"
is Event.UserDownloadedSend -> "E_User_Downloaded_Send"
is Event.OpenedPocketStory -> "E_Opened_Pocket_Story"
is Event.DarkModeEnabled -> "E_Dark_Mode_Enabled"
// Do not track these events in Leanplum
is Event.SearchBarTapped -> ""
}
// Do not track these events in Leanplum
is Event.SearchBarTapped -> ""
is Event.EnteredUrl -> ""
is Event.PerformedSearch -> ""
}
class LeanplumMetricsService(private val application: Application) : MetricsService {
data class Token(val id: String, val token: String) {

View File

@ -52,6 +52,16 @@ sealed class Event {
get() = mapOf("source" to source.name)
}
data class EnteredUrl(val autoCompleted: Boolean) : Event() {
override val extras: Map<String, String>?
get() = mapOf("autocomplete" to autoCompleted.toString())
}
data class PerformedSearch(val fromSearchSuggestion: Boolean) : Event() {
override val extras: Map<String, String>?
get() = mapOf("search_suggestion" to fromSearchSuggestion.toString())
}
open val extras: Map<String, String>?
get() = null
}

View File

@ -14,10 +14,12 @@ import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.fragment_search.view.*
import mozilla.components.feature.search.SearchUseCases
import mozilla.components.feature.session.SessionUseCases
import mozilla.components.support.ktx.kotlin.isUrl
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.utils.ItsNotBrokenSnack
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.toolbar.SearchAction
import org.mozilla.fenix.components.toolbar.SearchState
import org.mozilla.fenix.components.toolbar.ToolbarComponent
@ -92,6 +94,14 @@ class SearchFragment : Fragment() {
if (it.url.isNotBlank()) {
(activity as HomeActivity).openToBrowserAndLoad(it.url, it.session,
BrowserDirection.FromSearch)
val event = if (it.url.isUrl()) {
Event.EnteredUrl(false)
} else {
Event.PerformedSearch(false)
}
requireComponents.analytics.metrics.track(event)
}
}
is SearchAction.TextChanged -> {
@ -109,11 +119,13 @@ class SearchFragment : Fragment() {
is AwesomeBarAction.URLTapped -> {
getSessionUseCase(requireContext(), sessionId == null).invoke(it.url)
(activity as HomeActivity).openToBrowser(sessionId, BrowserDirection.FromSearch)
requireComponents.analytics.metrics.track(Event.EnteredUrl(false))
}
is AwesomeBarAction.SearchTermsTapped -> {
getSearchUseCase(requireContext(), sessionId == null)
.invoke(it.searchTerms, it.engine)
(activity as HomeActivity).openToBrowser(sessionId, BrowserDirection.FromSearch)
requireComponents.analytics.metrics.track(Event.PerformedSearch(true))
}
}
}