1
0
Fork 0

For #2362: Adds telemetry for history (#3940)

master
Sawyer Blatz 2019-07-16 12:21:03 -07:00 committed by GitHub
parent 8855af2234
commit 11d36b5a00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 141 additions and 1 deletions

View File

@ -613,7 +613,7 @@ activation:
type: string
lifetime: ping
description: >
An hashed and salted version of the Google Advertising ID from the device.
A hashed and salted version of the Google Advertising ID from the device.
This will never be sent in a ping that also contains the client_id.
send_in_pings:
- activation
@ -844,3 +844,60 @@ sync_account:
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
history:
opened:
type: event
description: >
A user opened the history screen
bugs:
- 2362
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3940
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
removed:
type: event
description: >
A user removed a history item
bugs:
- 2362
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3940
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
removed_all:
type: event
description: >
A user removed all history items
bugs:
- 2362
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3940
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
shared:
type: event
description: >
A user shared a history item
bugs:
- 2362
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3940
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
opened_item:
type: event
description: >
A user opened a history item
bugs:
- 2362
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3940
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"

View File

@ -22,6 +22,7 @@ import org.mozilla.fenix.GleanMetrics.CustomTab
import org.mozilla.fenix.GleanMetrics.ErrorPage
import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.FindInPage
import org.mozilla.fenix.GleanMetrics.History
import org.mozilla.fenix.GleanMetrics.Library
import org.mozilla.fenix.GleanMetrics.Metrics
import org.mozilla.fenix.GleanMetrics.Pings
@ -227,6 +228,21 @@ private val Event.wrapper
{ Events.preferenceToggled.record(it) },
{ Events.preferenceToggledKeys.valueOf(it) }
)
is Event.HistoryOpened -> EventWrapper<NoExtraKeys>(
{ History.opened.record(it) }
)
is Event.HistoryItemShared -> EventWrapper<NoExtraKeys>(
{ History.shared.record(it) }
)
is Event.HistoryItemOpened -> EventWrapper<NoExtraKeys>(
{ History.openedItem.record(it) }
)
is Event.HistoryItemRemoved -> EventWrapper<NoExtraKeys>(
{ History.removed.record(it) }
)
is Event.HistoryAllItemsRemoved -> EventWrapper<NoExtraKeys>(
{ History.removedAll.record(it) }
)
// Don't track other events with Glean
else -> null

View File

@ -93,6 +93,11 @@ sealed class Event {
object SyncAccountClosed : Event()
object SyncAccountSyncNow : Event()
object SyncAccountSignOut : Event()
object HistoryOpened : Event()
object HistoryItemShared : Event()
object HistoryItemOpened : Event()
object HistoryItemRemoved : Event()
object HistoryAllItemsRemoved : Event()
data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() {
private val switchPreferenceTelemetryAllowList = listOf(

View File

@ -33,6 +33,7 @@ import org.mozilla.fenix.FenixViewModelProvider
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.components.Components
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.getHostFromUrl
import org.mozilla.fenix.ext.nav
@ -69,6 +70,7 @@ class HistoryFragment : Fragment(), BackHandler {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
requireComponents.analytics.metrics.track(Event.HistoryOpened)
setHasOptionsMenu(true)
}
@ -209,6 +211,7 @@ class HistoryFragment : Fragment(), BackHandler {
}
private fun openItem(item: HistoryItem) {
requireComponents.analytics.metrics.track(Event.HistoryItemOpened)
(activity as HomeActivity).openToBrowserAndLoad(
searchTermOrURL = item.url,
newTab = true,
@ -226,6 +229,7 @@ class HistoryFragment : Fragment(), BackHandler {
setPositiveButton(R.string.history_clear_dialog) { dialog: DialogInterface, _ ->
emitChange { HistoryChange.EnterDeletionMode }
lifecycleScope.launch {
requireComponents.analytics.metrics.track(Event.HistoryAllItemsRemoved)
requireComponents.core.historyStorage.deleteEverything()
reloadData()
launch(Dispatchers.Main) {
@ -279,6 +283,7 @@ class HistoryFragment : Fragment(), BackHandler {
selected: List<HistoryItem>,
components: Components = requireComponents
) {
requireComponents.analytics.metrics.track(Event.HistoryItemRemoved)
val storage = components.core.historyStorage
for (item in selected) {
storage.deleteVisit(item.url, item.visitedAt)
@ -286,6 +291,7 @@ class HistoryFragment : Fragment(), BackHandler {
}
private fun share(url: String? = null, tabs: List<ShareTab>? = null) {
requireComponents.analytics.metrics.track(Event.HistoryItemShared)
val directions =
HistoryFragmentDirections.actionHistoryFragmentToShareFragment(
url = url,

View File

@ -706,6 +706,62 @@ tracking_protection</td>
</pre>
## history
<pre>
<table style="width: 100%">
<tr>
<th>key</th>
<th>type</th>
<th>description</th>
<th>data deview</th>
<th>extras</th>
<th>expires</th>
</tr>
<tr>
<td>opened</td>
<td>event</td>
<td>A user opened the history screen</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3940">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>removed</td>
<td>event</td>
<td>A user removed a history item</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3940">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>removed_all</td>
<td>event</td>
<td>A user removed all history items</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3940">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>shared</td>
<td>event</td>
<td>A user shared a history item</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3940">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>opened_item</td>
<td>event</td>
<td>A user opened a history item</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3940">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
</table>
</pre>
## Metrics
Items that are added to the metrics ping