Commit 9d9ff959 authored by Emily Kager's avatar Emily Kager Committed by Emily Kager
Browse files

For #5312 - Add Telemetry for Tracking Protection

parent e9a645a1
Loading
Loading
Loading
Loading
+71 −0
Original line number Diff line number Diff line
@@ -1288,6 +1288,77 @@ private_browsing_mode:
      - fenix-core@mozilla.com
    expires: "2020-03-01"

tracking_protection:
  exception_added:
    type: event
    description: >
      A user added a tracking protection exception through the TP toggle in the panel.
    bugs:
      - 5312
    data_reviews:
      - https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188
    notification_emails:
      - fenix-core@mozilla.com
    expires: "2020-03-01"
  panel_settings:
    type: event
    description: >
      A user opened tracking protection settings from the panel.
    bugs:
      - 5312
    data_reviews:
      - https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188
    notification_emails:
      - fenix-core@mozilla.com
    expires: "2020-03-01"
  etp_shield:
    type: event
    description: >
      A user pressed the tracking protection shield icon in toolbar.
    bugs:
      - 5312
    data_reviews:
      - https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188
    notification_emails:
      - fenix-core@mozilla.com
    expires: "2020-03-01"
  etp_tracker_list:
    type: event
    description: >
      A user pressed into a list of categorized trackers in tracking protection panel.
    bugs:
      - 5312
    data_reviews:
      - https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188
    notification_emails:
      - fenix-core@mozilla.com
    expires: "2020-03-01"
  etp_settings:
    type: event
    description: >
      A user opened tracking protection settings through settings.
    bugs:
      - 5312
    data_reviews:
      - https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188
    notification_emails:
      - fenix-core@mozilla.com
    expires: "2020-03-01"
  etp_setting_changed:
    type: event
    description: >
      A user added a tracking protection exception through the TP toggle in the panel.
    extra_keys:
      etp_setting:
        description: "The new setting for ETP: strict, standard"
    bugs:
      - 5312
    data_reviews:
      - https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188
    notification_emails:
      - fenix-core@mozilla.com
    expires: "2020-03-01"

private_browsing_shortcut:
  create_shortcut:
    type: event
+3 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import org.mozilla.fenix.collections.CreateCollectionViewModel
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.FindInPageIntegration
import org.mozilla.fenix.components.StoreProvider
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.toolbar.BrowserFragmentState
import org.mozilla.fenix.components.toolbar.BrowserFragmentStore
import org.mozilla.fenix.components.toolbar.BrowserToolbarController
@@ -70,6 +71,7 @@ import org.mozilla.fenix.components.toolbar.ToolbarIntegration
import org.mozilla.fenix.downloads.DownloadService
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.enterToImmersiveMode
import org.mozilla.fenix.ext.metrics
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.isInExperiment
@@ -214,6 +216,7 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
            }

            browserToolbarView.view.setOnTrackingProtectionClickedListener {
                context.metrics.track(Event.TrackingProtectionIconPressed)
                showTrackingProtectionPanel()
            }

+20 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import org.mozilla.fenix.GleanMetrics.SearchWidget
import org.mozilla.fenix.GleanMetrics.SyncAccount
import org.mozilla.fenix.GleanMetrics.SyncAuth
import org.mozilla.fenix.GleanMetrics.Tab
import org.mozilla.fenix.GleanMetrics.TrackingProtection
import org.mozilla.fenix.ext.components

private class EventWrapper<T : Enum<T>>(
@@ -377,7 +378,25 @@ private val Event.wrapper: EventWrapper<*>?
        is Event.TabMediaPause -> EventWrapper<NoExtraKeys>(
            { Tab.mediaPause.record(it) }
        )

        is Event.TrackingProtectionTrackerList -> EventWrapper<NoExtraKeys>(
            { TrackingProtection.etpTrackerList.record(it) }
        )
        is Event.TrackingProtectionIconPressed -> EventWrapper<NoExtraKeys>(
            { TrackingProtection.etpShield.record(it) }
        )
        is Event.TrackingProtectionSettingsPanel -> EventWrapper<NoExtraKeys>(
            { TrackingProtection.panelSettings.record(it) }
        )
        is Event.TrackingProtectionSettings -> EventWrapper<NoExtraKeys>(
            { TrackingProtection.etpSettings.record(it) }
        )
        is Event.TrackingProtectionException -> EventWrapper<NoExtraKeys>(
            { TrackingProtection.exceptionAdded.record(it) }
        )
        is Event.TrackingProtectionSettingChanged -> EventWrapper(
            { TrackingProtection.etpSettingChanged.record(it) },
            { TrackingProtection.etpSettingChangedKeys.valueOf(it) }
        )
        // Don't record other events in Glean:
        is Event.AddBookmark -> null
        is Event.OpenedBookmark -> null
+12 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import org.mozilla.fenix.GleanMetrics.ErrorPage
import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.Library
import org.mozilla.fenix.GleanMetrics.SearchShortcuts
import org.mozilla.fenix.GleanMetrics.TrackingProtection
import org.mozilla.fenix.R
import java.util.Locale

@@ -115,6 +116,11 @@ sealed class Event {
    object PrivateBrowsingStaticShortcutPrivateTab : Event()
    object TabMediaPlay : Event()
    object TabMediaPause : Event()
    object TrackingProtectionTrackerList : Event()
    object TrackingProtectionIconPressed : Event()
    object TrackingProtectionSettingsPanel : Event()
    object TrackingProtectionSettings : Event()
    object TrackingProtectionException : Event()

    // Interaction events with extras

@@ -138,6 +144,12 @@ sealed class Event {
        }
    }

    data class TrackingProtectionSettingChanged(val setting: Setting) : Event() {
        enum class Setting { STRICT, STANDARD }
        override val extras: Map<TrackingProtection.etpSettingChangedKeys, String>?
            get() = hashMapOf(TrackingProtection.etpSettingChangedKeys.etpSetting to setting.name)
    }

    data class OpenedApp(val source: Source) : Event() {
        enum class Source { APP_ICON, LINK, CUSTOM_TAB }
        override val extras: Map<Events.appOpenedKeys, String>?
+4 −1
Original line number Diff line number Diff line
@@ -8,11 +8,13 @@ import android.content.Context
import android.content.SharedPreferences
import mozilla.components.support.ktx.android.content.PreferencesHolder
import mozilla.components.support.ktx.android.content.stringPreference
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.metrics

/**
 * Contains functionality to manage custom domains for allow-list.
 */
class ExceptionDomains(context: Context) : PreferencesHolder {
class ExceptionDomains(val context: Context) : PreferencesHolder {

    override val preferences: SharedPreferences =
        context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE)
@@ -70,6 +72,7 @@ class ExceptionDomains(context: Context) : PreferencesHolder {
        if (domain in load()) {
            remove(listOf(domain))
        } else {
            context.metrics.track(Event.TrackingProtectionException)
            add(domain)
        }
    }
Loading