From 6e866c420635668eeb5ad86df7fff2f96af1e3ce Mon Sep 17 00:00:00 2001 From: Lina Butler Date: Fri, 2 Feb 2024 16:11:14 -0800 Subject: [PATCH] Bug 1878434 - Add the `awesomebar.{engagement, abandonment}` events. This commit: * Sends the new `awesomebar.{engagement, abandonment}` events when the user finishes interacting with the awesomebar. These events match iOS's events of the same name, and Desktop's `urlbar.{engagement, abandonment}` events. * Removes the `engagement_abandoned` extra key for the `awesomebar.{sponsored, non_sponsored}_suggestion_impressed` events, since they're specific to AMP and Wikipedia suggestions, and are subsumed by the new events. This is the first step toward unifying our awesomebar search telemetry on all our platforms. --- app/metrics.yaml | 51 ++++++++++++++++--- .../components/metrics/MetricController.kt | 2 - .../fenix/telemetry/TelemetryMiddleware.kt | 11 +++- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/app/metrics.yaml b/app/metrics.yaml index fe36185ed8..636f46ff28 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -9204,8 +9204,10 @@ awesomebar: A sponsored suggestion was visible when the user finished interacting with the awesomebar. bugs: - https://bugzilla.mozilla.org/show_bug.cgi?id=1871156 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1878434 data_reviews: - https://github.com/mozilla-mobile/firefox-android/pull/4914#issuecomment-1874271848 + - https://github.com/mozilla-mobile/firefox-android/pull/5438#issuecomment-1930970336 data_sensitivity: - interaction notification_emails: @@ -9216,12 +9218,6 @@ awesomebar: expires: never extra_keys: provider: *sponsored_suggestion_provider - engagement_abandoned: &awesomebar_engagement_abandoned - description: | - If `true`, the user dismissed the awesomebar without navigating to a destination. If - `false`, the user finished engaging with the awesomebar by navigating to a destination, - like a URL, a search results page, or a suggestion. - type: boolean metadata: tags: - Search @@ -9231,8 +9227,10 @@ awesomebar: A non-sponsored suggestion was visible when the user finished interacting with the awesomebar. bugs: - https://bugzilla.mozilla.org/show_bug.cgi?id=1871156 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1878434 data_reviews: - https://github.com/mozilla-mobile/firefox-android/pull/4914#issuecomment-1874271848 + - https://github.com/mozilla-mobile/firefox-android/pull/5438#issuecomment-1930970336 data_sensitivity: - interaction notification_emails: @@ -9243,10 +9241,49 @@ awesomebar: expires: never extra_keys: provider: *non_sponsored_suggestion_provider - engagement_abandoned: *awesomebar_engagement_abandoned metadata: tags: - Search + engagement: + type: event + description: | + The user completed their search session by tapping a search result, + or entering a URL or a search term. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1878434 + data_reviews: + - https://github.com/mozilla-mobile/firefox-android/pull/5438#issuecomment-1930970336 + data_sensitivity: + - interaction + notification_emails: + - android-probes@mozilla.com + - lina@mozilla.com + - ttran@mozilla.com + - najiang@mozilla.com + expires: never + metadata: + tags: + - Search + abandonment: + type: event + description: | + The user dismissed the awesomebar without completing their search. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1878434 + data_reviews: + - https://github.com/mozilla-mobile/firefox-android/pull/5438#issuecomment-1930970336 + data_sensitivity: + - interaction + notification_emails: + - android-probes@mozilla.com + - lina@mozilla.com + - ttran@mozilla.com + - najiang@mozilla.com + expires: never + metadata: + tags: + - Search + android_autofill: supported: type: boolean diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt index 453ff4750a..6e43803f46 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt @@ -339,7 +339,6 @@ internal class ReleaseMetricController( Awesomebar.sponsoredSuggestionImpressed.record( Awesomebar.SponsoredSuggestionImpressedExtra( provider = "amp", - engagementAbandoned = engagementAbandoned, ), ) } @@ -347,7 +346,6 @@ internal class ReleaseMetricController( Awesomebar.nonSponsoredSuggestionImpressed.record( Awesomebar.NonSponsoredSuggestionImpressedExtra( provider = "wikipedia", - engagementAbandoned = engagementAbandoned, ), ) } diff --git a/app/src/main/java/org/mozilla/fenix/telemetry/TelemetryMiddleware.kt b/app/src/main/java/org/mozilla/fenix/telemetry/TelemetryMiddleware.kt index 3b448bdb42..53c1fc8fef 100644 --- a/app/src/main/java/org/mozilla/fenix/telemetry/TelemetryMiddleware.kt +++ b/app/src/main/java/org/mozilla/fenix/telemetry/TelemetryMiddleware.kt @@ -5,6 +5,7 @@ package org.mozilla.fenix.telemetry import android.content.Context +import mozilla.components.browser.state.action.AwesomeBarAction import mozilla.components.browser.state.action.BrowserAction import mozilla.components.browser.state.action.ContentAction import mozilla.components.browser.state.action.DownloadAction @@ -25,6 +26,7 @@ import mozilla.telemetry.glean.internal.TimerId import mozilla.telemetry.glean.private.NoExtras import org.mozilla.fenix.Config import org.mozilla.fenix.GleanMetrics.Addons +import org.mozilla.fenix.GleanMetrics.Awesomebar import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.Metrics import org.mozilla.fenix.components.metrics.Event @@ -59,7 +61,7 @@ class TelemetryMiddleware( private val logger = Logger("TelemetryMiddleware") - @Suppress("TooGenericExceptionCaught", "ComplexMethod", "NestedBlockDepth") + @Suppress("TooGenericExceptionCaught", "ComplexMethod", "NestedBlockDepth", "LongMethod") override fun invoke( context: MiddlewareContext, next: (BrowserAction) -> Unit, @@ -144,6 +146,13 @@ class TelemetryMiddleware( is ExtensionsProcessAction.DisabledAction -> { Addons.extensionsProcessUiDisable.add() } + is AwesomeBarAction.EngagementFinished -> { + if (action.abandoned) { + Awesomebar.abandonment.record() + } else { + Awesomebar.engagement.record() + } + } else -> { // no-op }