Skip to content

Commit

Permalink
For mozilla-mobile#9625: Add telemetry for Tracking Protection CFR
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Jun 24, 2020
1 parent 5216560 commit 9527f3e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 3 deletions.
51 changes: 51 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -553,6 +554,22 @@ private val Event.wrapper: EventWrapper<*>?
{ Events.tabCounterMenuActionKeys.valueOf(it) }
)

is Event.ContextualHintETPDisplayed -> EventWrapper<NoExtraKeys>(
{ ContextualHintTrackingProtection.display.record(it) }
)

is Event.ContextualHintETPDismissed -> EventWrapper<NoExtraKeys>(
{ ContextualHintTrackingProtection.dismiss.record(it) }
)

is Event.ContextualHintETPInsideTap -> EventWrapper<NoExtraKeys>(
{ ContextualHintTrackingProtection.insideTap.record(it) }
)

is Event.ContextualHintETPOutsideTap -> EventWrapper<NoExtraKeys>(
{ ContextualHintTrackingProtection.outsideTap.record(it) }
)

// Don't record other events in Glean:
is Event.AddBookmark -> null
is Event.OpenedBookmark -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ sealed class Event {
object SearchWidgetCFRNotNowPressed : Event()
object SearchWidgetCFRAddWidgetPressed : Event()

object ContextualHintETPDisplayed : Event()
object ContextualHintETPDismissed : Event()
object ContextualHintETPOutsideTap : Event()
object ContextualHintETPInsideTap : Event()

// Interaction events with extras

data class PreferenceToggled(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -63,6 +76,7 @@ class TrackingProtectionOverlay(
val closeButton = layout.findViewById<ImageView>(R.id.close_onboarding)
closeButton.increaseTapArea(BUTTON_INCREASE_DPS)
closeButton.setOnClickListener {
context.components.analytics.metrics.track(Event.ContextualHintETPDismissed)
trackingOnboardingDialog.dismiss()
}

Expand Down Expand Up @@ -101,10 +115,12 @@ class TrackingProtectionOverlay(
val etpShield =
getToolbar().findViewById<View>(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()
}
Expand Down
4 changes: 4 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)|<ul><li>tabs_open: The number of tabs open in the current session</li><li>tabs_selected: The number of tabs added to the collection</li></ul>|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)|<ul><li>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 ``` </li></ul>|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)|<ul><li>crash_submitted: A boolean that tells us whether or not the user submitted a crash report </li></ul>|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 |
Expand Down

0 comments on commit 9527f3e

Please sign in to comment.