diff --git a/app/metrics.yaml b/app/metrics.yaml index 18ca414ae..6436d9afa 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1866,6 +1866,57 @@ private_browsing_mode: - fenix-core@mozilla.com expires: "2020-09-01" +contextual_hint.tracking_protection: + display: + type: event + description: | + The enhanced tracking protection contextual hint was + displayed. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/9625 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/11923 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" + dismiss: + type: event + description: | + The enhanced tracking protection contextual hint was + dismissed + by pressing the close button + bugs: + - https://github.com/mozilla-mobile/fenix/issues/9625 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/11923 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" + outside_tap: + type: event + description: | + The user tapped outside of the etp contextual hint + (which has no effect). + bugs: + - https://github.com/mozilla-mobile/fenix/issues/9625 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/11923 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" + inside_tap: + type: event + description: | + The user tapped inside of the etp contextual hint + (which brings up the etp panel for this site). + bugs: + - https://github.com/mozilla-mobile/fenix/issues/9625 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/11923 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" + tracking_protection: exception_added: type: event diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt index d159bdc40..882e63fd3 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt @@ -16,6 +16,7 @@ import org.mozilla.fenix.GleanMetrics.BookmarksManagement import org.mozilla.fenix.GleanMetrics.BrowserSearch import org.mozilla.fenix.GleanMetrics.Collections import org.mozilla.fenix.GleanMetrics.ContextMenu +import org.mozilla.fenix.GleanMetrics.ContextualHintTrackingProtection import org.mozilla.fenix.GleanMetrics.CrashReporter import org.mozilla.fenix.GleanMetrics.CustomTab import org.mozilla.fenix.GleanMetrics.DownloadNotification @@ -585,6 +586,22 @@ private val Event.wrapper: EventWrapper<*>? { Onboarding.prefToggledToolbarPositionKeys.valueOf(it) } ) + is Event.ContextualHintETPDisplayed -> EventWrapper( + { ContextualHintTrackingProtection.display.record(it) } + ) + + is Event.ContextualHintETPDismissed -> EventWrapper( + { ContextualHintTrackingProtection.dismiss.record(it) } + ) + + is Event.ContextualHintETPInsideTap -> EventWrapper( + { ContextualHintTrackingProtection.insideTap.record(it) } + ) + + is Event.ContextualHintETPOutsideTap -> EventWrapper( + { ContextualHintTrackingProtection.outsideTap.record(it) } + ) + // Don't record other events in Glean: is Event.AddBookmark -> null is Event.OpenedBookmark -> null diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt index a5a7cda2a..a14351a02 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt @@ -179,6 +179,11 @@ sealed class Event { object OnboardingWhatsNew : Event() object OnboardingFinish : Event() + object ContextualHintETPDisplayed : Event() + object ContextualHintETPDismissed : Event() + object ContextualHintETPOutsideTap : Event() + object ContextualHintETPInsideTap : Event() + // Interaction events with extras data class OnboardingToolbarPosition(val position: Position) : Event() { enum class Position { TOP, BOTTOM } diff --git a/app/src/main/java/org/mozilla/fenix/trackingprotection/TrackingProtectionOverlay.kt b/app/src/main/java/org/mozilla/fenix/trackingprotection/TrackingProtectionOverlay.kt index 9edace5ec..e3839c5d3 100644 --- a/app/src/main/java/org/mozilla/fenix/trackingprotection/TrackingProtectionOverlay.kt +++ b/app/src/main/java/org/mozilla/fenix/trackingprotection/TrackingProtectionOverlay.kt @@ -10,6 +10,7 @@ import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.view.Gravity import android.view.LayoutInflater +import android.view.MotionEvent import android.view.View import android.widget.ImageView import androidx.core.view.isGone @@ -19,6 +20,8 @@ import kotlinx.android.synthetic.main.tracking_protection_onboarding_popup.* import kotlinx.android.synthetic.main.tracking_protection_onboarding_popup.view.* import mozilla.components.browser.session.Session import org.mozilla.fenix.R +import org.mozilla.fenix.components.metrics.Event +import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.increaseTapArea import org.mozilla.fenix.utils.Settings @@ -40,13 +43,23 @@ class TrackingProtectionOverlay( private fun shouldShowTrackingProtectionOnboarding(session: Session) = settings.shouldShowTrackingProtectionOnboarding && - session.trackerBlockingEnabled && - session.trackersBlocked.isNotEmpty() + session.trackerBlockingEnabled && + session.trackersBlocked.isNotEmpty() @Suppress("MagicNumber", "InflateParams") private fun showTrackingProtectionOnboarding() { if (!getToolbar().hasWindowFocus()) return - val trackingOnboardingDialog = Dialog(context) + + val trackingOnboardingDialog = object : Dialog(context) { + override fun onTouchEvent(event: MotionEvent): Boolean { + + if (event.action == MotionEvent.ACTION_DOWN) { + context.components.analytics.metrics.track(Event.ContextualHintETPOutsideTap) + } + return super.onTouchEvent(event) + } + } + val layout = LayoutInflater.from(context) .inflate(R.layout.tracking_protection_onboarding_popup, null) val isBottomToolbar = Settings.getInstance(context).shouldUseBottomToolbar @@ -63,6 +76,7 @@ class TrackingProtectionOverlay( val closeButton = layout.findViewById(R.id.close_onboarding) closeButton.increaseTapArea(BUTTON_INCREASE_DPS) closeButton.setOnClickListener { + context.components.analytics.metrics.track(Event.ContextualHintETPDismissed) trackingOnboardingDialog.dismiss() } @@ -101,10 +115,12 @@ class TrackingProtectionOverlay( val etpShield = getToolbar().findViewById(R.id.mozac_browser_toolbar_tracking_protection_indicator) trackingOnboardingDialog.message.setOnClickListener { + context.components.analytics.metrics.track(Event.ContextualHintETPInsideTap) trackingOnboardingDialog.dismiss() etpShield.performClick() } + context.components.analytics.metrics.track(Event.ContextualHintETPDisplayed) trackingOnboardingDialog.show() settings.incrementTrackingProtectionOnboardingCount() } diff --git a/docs/metrics.md b/docs/metrics.md index 4943d1b5d..0c0cd6540 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -82,6 +82,10 @@ The following metrics are added to the ping: | collections.tab_select_opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened the select tabs screen (the first step of the collection creation flow) |[1](https://github.com/mozilla-mobile/fenix/pull/3935)||2020-09-01 | | collections.tabs_added |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user saved a list of tabs to an existing collection |[1](https://github.com/mozilla-mobile/fenix/pull/3935)|
  • tabs_open: The number of tabs open in the current session
  • tabs_selected: The number of tabs added to the collection
|2020-09-01 | | context_menu.item_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped an item in the browsers context menu |[1](https://github.com/mozilla-mobile/fenix/pull/1344#issuecomment-479285010)|
  • named: The name of the item that was tapped. Available items are: ``` open_in_new_tab, open_in_private_tab, open_image_in_new_tab, save_image, share_link, copy_link, copy_image_location ```
|2020-09-01 | +| contextual_hint.tracking_protection.dismiss |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The enhanced tracking protection contextual hint was dismissed by pressing the close button |[1](https://github.com/mozilla-mobile/fenix/pull/TODO)||2020-09-01 | +| contextual_hint.tracking_protection.display |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The enhanced tracking protection contextual hint was displayed. |[1](https://github.com/mozilla-mobile/fenix/pull/TODO)||2020-09-01 | +| contextual_hint.tracking_protection.inside_tap |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The user tapped inside of the etp contextual hint (which brings up the etp panel for this site). |[1](https://github.com/mozilla-mobile/fenix/pull/TODO)||2020-09-01 | +| contextual_hint.tracking_protection.outside_tap |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The user tapped outside of the etp contextual hint (which has no effect). |[1](https://github.com/mozilla-mobile/fenix/pull/TODO)||2020-09-01 | | crash_reporter.closed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The crash reporter was closed |[1](https://github.com/mozilla-mobile/fenix/pull/1214#issue-264756708)|
  • crash_submitted: A boolean that tells us whether or not the user submitted a crash report
|2020-09-01 | | crash_reporter.opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The crash reporter was displayed |[1](https://github.com/mozilla-mobile/fenix/pull/1214#issue-264756708)||2020-09-01 | | custom_tab.action_button |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the action button provided by the launching app |[1](https://github.com/mozilla-mobile/fenix/pull/1697)||2020-09-01 |