For #11578 - Add telemetry for how many times we download something (#16730)

upstream-sync
Mugurell 4 years ago committed by GitHub
parent edca0e05a9
commit d5b33aec43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3109,6 +3109,21 @@ download_notification:
- fenix-core@mozilla.com
expires: "2021-04-01"
downloads_misc:
download_added:
type: event
description:
A counter for how many times something is downloaded in the app.
send_in_pings:
- metrics
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11578
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/16730
notification_emails:
- fenix-core@mozilla.com
expires: "2021-04-01"
user_specified_search_engines:
custom_engine_added:
type: event

@ -7,6 +7,7 @@ package org.mozilla.fenix
import androidx.annotation.VisibleForTesting
import mozilla.components.browser.state.action.BrowserAction
import mozilla.components.browser.state.action.ContentAction
import mozilla.components.browser.state.action.DownloadAction
import mozilla.components.browser.state.action.TabListAction
import mozilla.components.browser.state.selector.findTab
import mozilla.components.browser.state.selector.normalTabs
@ -48,7 +49,7 @@ class TelemetryMiddleware(
}
}
@Suppress("TooGenericExceptionCaught")
@Suppress("TooGenericExceptionCaught", "ComplexMethod")
override fun invoke(
context: MiddlewareContext<BrowserState, BrowserAction>,
next: (BrowserAction) -> Unit,
@ -86,6 +87,9 @@ class TelemetryMiddleware(
}
}
}
is DownloadAction.AddDownloadAction -> {
metrics.track(Event.DownloadAdded)
}
}
next(action)

@ -113,6 +113,7 @@ sealed class Event {
object NotificationDownloadPause : Event()
object NotificationDownloadResume : Event()
object NotificationDownloadTryAgain : Event()
object DownloadAdded : Event()
object NotificationMediaPlay : Event()
object NotificationMediaPause : Event()
object TopSiteOpenDefault : Event()

@ -25,6 +25,7 @@ import org.mozilla.fenix.GleanMetrics.ContextualHintTrackingProtection
import org.mozilla.fenix.GleanMetrics.CrashReporter
import org.mozilla.fenix.GleanMetrics.CustomTab
import org.mozilla.fenix.GleanMetrics.DownloadNotification
import org.mozilla.fenix.GleanMetrics.DownloadsMisc
import org.mozilla.fenix.GleanMetrics.ErrorPage
import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.FindInPage
@ -423,6 +424,9 @@ private val Event.wrapper: EventWrapper<*>?
is Event.NotificationDownloadTryAgain -> EventWrapper<NoExtraKeys>(
{ DownloadNotification.tryAgain.record(it) }
)
is Event.DownloadAdded -> EventWrapper<NoExtraKeys>(
{ DownloadsMisc.downloadAdded.record(it) }
)
is Event.NotificationMediaPlay -> EventWrapper<NoExtraKeys>(
{ MediaNotification.play.record(it) }
)

@ -7,11 +7,13 @@ package org.mozilla.fenix
import io.mockk.mockk
import io.mockk.verify
import mozilla.components.browser.state.action.ContentAction
import mozilla.components.browser.state.action.DownloadAction
import mozilla.components.browser.state.action.TabListAction
import mozilla.components.browser.state.state.LoadRequestState
import mozilla.components.browser.state.state.createTab
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.support.test.ext.joinBlocking
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
@ -216,4 +218,11 @@ class TelemetryMiddlewareTest {
store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://mozilla.org")).joinBlocking()
assertNull(telemetryMiddleware.redirectChains[tab.id])
}
@Test
fun `WHEN a download is added THEN the downloads count is updated`() {
store.dispatch(DownloadAction.AddDownloadAction(mock())).joinBlocking()
verify { metrics.track(Event.DownloadAdded) }
}
}

@ -261,6 +261,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 |
| downloads_misc.download_added |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A counter for how many times something is downloaded in the app. |[1](https://github.com/mozilla-mobile/fenix/pull/16730)||2021-04-01 | |
| 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 |

Loading…
Cancel
Save