diff --git a/app/metrics.yaml b/app/metrics.yaml index 2ccba8ad4cc..d07ef8ac5ea 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1900,3 +1900,57 @@ metrics: metadata: tags: - Performance + search_widget_installed: + type: boolean + lifetime: application + description: | + Whether or not the search widget is installed + send_in_pings: + - metrics + bugs: + - https://github.com/mozilla-mobile/fenix/issues/ + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/ + data_sensitivity: + - interaction + notification_emails: + - android-probes@mozilla.com + expires: 119 + metadata: + tags: + - Search + +search_widget: + new_tab_button: + type: event + description: | + A user pressed anywhere from the Focus logo until the start of the + microphone icon, opening a new tab search screen. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/ + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/ + data_sensitivity: + - interaction + notification_emails: + - android-probes@mozilla.com + expires: 119 + metadata: + tags: + - Search + voice_button: + type: event + description: | + A user pressed the microphone icon, opening a new voice search screen. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/ + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/ + data_sensitivity: + - interaction + notification_emails: + - android-probes@mozilla.com + expires: 119 + metadata: + tags: + - Search diff --git a/app/src/main/java/org/mozilla/focus/FocusApplication.kt b/app/src/main/java/org/mozilla/focus/FocusApplication.kt index 0a243b2adec..7ae95fdf603 100644 --- a/app/src/main/java/org/mozilla/focus/FocusApplication.kt +++ b/app/src/main/java/org/mozilla/focus/FocusApplication.kt @@ -25,6 +25,7 @@ import mozilla.components.support.locale.LocaleAwareApplication import mozilla.components.support.rusthttp.RustHttpConfig import mozilla.components.support.rustlog.RustLog import mozilla.components.support.webextensions.WebExtensionSupport +import org.mozilla.focus.GleanMetrics.Metrics import org.mozilla.focus.biometrics.LockObserver import org.mozilla.focus.ext.settings import org.mozilla.focus.navigation.StoreLink @@ -87,6 +88,8 @@ open class FocusApplication : LocaleAwareApplication(), CoroutineScope { components.appStartReasonProvider.registerInAppOnCreate(this) components.startupActivityLog.registerInAppOnCreate(this) + Metrics.searchWidgetInstalled.set(settings.searchWidgetInstalled) + ProcessLifecycleOwner.get().lifecycle.addObserver(lockObserver) } } diff --git a/app/src/main/java/org/mozilla/focus/activity/IntentReceiverActivity.kt b/app/src/main/java/org/mozilla/focus/activity/IntentReceiverActivity.kt index a919bc93499..b8d1b483014 100644 --- a/app/src/main/java/org/mozilla/focus/activity/IntentReceiverActivity.kt +++ b/app/src/main/java/org/mozilla/focus/activity/IntentReceiverActivity.kt @@ -8,7 +8,9 @@ import android.app.Activity import android.content.Intent import android.os.Bundle import mozilla.components.feature.intent.ext.sanitize +import mozilla.components.service.glean.private.NoExtras import mozilla.components.support.utils.toSafeIntent +import org.mozilla.focus.GleanMetrics.SearchWidget import org.mozilla.focus.ext.components import org.mozilla.focus.session.IntentProcessor import org.mozilla.focus.utils.SupportUtils @@ -25,7 +27,9 @@ class IntentReceiverActivity : Activity() { super.onCreate(savedInstanceState) val intent = intent.sanitize().toSafeIntent() - + if (intent.getBooleanExtra(SEARCH_WIDGET, false)) { + SearchWidget.newTabButton.record(NoExtras()) + } if (intent.dataString.equals(SupportUtils.OPEN_WITH_DEFAULT_BROWSER_URL)) { dispatchNormalIntent() return @@ -61,4 +65,8 @@ class IntentReceiverActivity : Activity() { startActivity(intent) } + + companion object { + const val SEARCH_WIDGET = "search_widget" + } } diff --git a/app/src/main/java/org/mozilla/focus/searchwidget/VoiceSearchActivity.kt b/app/src/main/java/org/mozilla/focus/searchwidget/VoiceSearchActivity.kt index e249d740508..bb5b8747be7 100644 --- a/app/src/main/java/org/mozilla/focus/searchwidget/VoiceSearchActivity.kt +++ b/app/src/main/java/org/mozilla/focus/searchwidget/VoiceSearchActivity.kt @@ -8,6 +8,8 @@ import android.content.Intent import mozilla.components.feature.search.widget.BaseVoiceSearchActivity import mozilla.components.support.locale.LocaleManager import mozilla.components.support.locale.LocaleManager.getCurrentLocale +import mozilla.telemetry.glean.private.NoExtras +import org.mozilla.focus.GleanMetrics.SearchWidget import org.mozilla.focus.activity.IntentReceiverActivity import java.util.Locale @@ -19,7 +21,7 @@ class VoiceSearchActivity : BaseVoiceSearchActivity() { } override fun recordVoiceButtonTelemetry() { - // TO DO add + SearchWidget.voiceButton.record(NoExtras()) } override fun startIntentAfterVoiceSearch(spokenText: String?) { diff --git a/app/src/main/java/org/mozilla/gecko/search/SearchWidgetProvider.kt b/app/src/main/java/org/mozilla/gecko/search/SearchWidgetProvider.kt index 2a5efeb51e8..ae3ee815602 100644 --- a/app/src/main/java/org/mozilla/gecko/search/SearchWidgetProvider.kt +++ b/app/src/main/java/org/mozilla/gecko/search/SearchWidgetProvider.kt @@ -14,6 +14,7 @@ import mozilla.components.support.utils.PendingIntentUtils import org.mozilla.focus.R import org.mozilla.focus.activity.IntentReceiverActivity import org.mozilla.focus.ext.components +import org.mozilla.focus.searchwidget.VoiceSearchActivity class SearchWidgetProvider : AppSearchWidgetProvider() { @@ -42,6 +43,7 @@ class SearchWidgetProvider : AppSearchWidgetProvider() { val createTextSearchIntentFlags = PendingIntentUtils.defaultFlags or PendingIntent.FLAG_UPDATE_CURRENT intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK + intent.putExtra(IntentReceiverActivity.SEARCH_WIDGET, true) PendingIntent.getActivity( context, REQUEST_CODE_NEW_TAB, intent, createTextSearchIntentFlags @@ -54,7 +56,7 @@ class SearchWidgetProvider : AppSearchWidgetProvider() { } override fun voiceSearchActivity(): Class { - return BaseVoiceSearchActivity::class.java + return VoiceSearchActivity::class.java } companion object {