1
0
Fork 0

For #5737: Adds telemetry for open links in a private tab (#5975)

master
Sawyer Blatz 2019-10-24 17:16:49 -07:00 committed by liuche
parent 6290c0c826
commit 4359c215e6
5 changed files with 44 additions and 3 deletions

View File

@ -111,16 +111,18 @@ events:
preference_key:
description: "The preference key for the switch preference the user toggled. We currently track:
show_search_suggestions, remote_debugging, telemetry, tracking_protection, search_bookmarks,
search_browsing_history, show_clipboard_suggestions, and show_search_shortcuts"
search_browsing_history, show_clipboard_suggestions, show_search_shortcuts, and open_links_in_a_private_tab"
enabled:
description: "Whether or not the preference is *now* enabled"
bugs:
- https://github.com/mozilla-mobile/fenix/issue/975
- https://github.com/mozilla-mobile/fenix/issue/5094
- https://github.com/mozilla-mobile/fenix/issues/5737
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1896
- https://github.com/mozilla-mobile/fenix/pull/5704
- https://github.com/mozilla-mobile/fenix/pull/5886
- https://github.com/mozilla-mobile/fenix/pull/5975
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
@ -138,6 +140,20 @@ events:
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
opened_link:
type: event
description: >
A user opened a link with Fenix
extra_keys:
mode:
description: "The mode the link was opened in. Either 'PRIVATE' or 'NORMAL'"
bugs:
- https://github.com/mozilla-mobile/fenix/issue/5737
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/5975
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
search_shortcuts:
selected:

View File

@ -13,6 +13,7 @@ import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import mozilla.components.feature.intent.processing.TabIntentProcessor
import mozilla.components.support.utils.Browsers
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.customtabs.ExternalAppBrowserActivity
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
@ -47,14 +48,26 @@ class IntentReceiverActivity : Activity() {
Which only appears if the user doesn't have a default set. */
if (didLaunchPrivateLink && Browsers.all(this).isDefaultBrowser) {
this.settings().openLinksInAPrivateTab = true
components.analytics.metrics.track(Event.PreferenceToggled(
preferenceKey = getString(R.string.pref_key_open_links_in_a_private_tab),
enabled = true,
context = applicationContext
))
} else if (!Browsers.all(this).isDefaultBrowser) {
/* If the user has unset us as the default browser, unset openLinksInAPrivateTab */
this.settings().openLinksInAPrivateTab = false
components.analytics.metrics.track(Event.PreferenceToggled(
preferenceKey = getString(R.string.pref_key_open_links_in_a_private_tab),
enabled = false,
context = applicationContext
))
}
val tabIntentProcessor = if (settings().openLinksInAPrivateTab || didLaunchPrivateLink) {
components.analytics.metrics.track(Event.OpenedLink(Event.OpenedLink.Mode.PRIVATE))
components.intentProcessors.privateIntentProcessor
} else {
components.analytics.metrics.track(Event.OpenedLink(Event.OpenedLink.Mode.NORMAL))
components.intentProcessors.intentProcessor
}

View File

@ -416,6 +416,10 @@ private val Event.wrapper: EventWrapper<*>?
{ TrackingProtection.etpSettingChanged.record(it) },
{ TrackingProtection.etpSettingChangedKeys.valueOf(it) }
)
is Event.OpenedLink -> EventWrapper(
{ Events.openedLink.record(it) },
{ Events.openedLinkKeys.valueOf(it) }
)
// Don't record other events in Glean:
is Event.AddBookmark -> null
is Event.OpenedBookmark -> null

View File

@ -138,7 +138,8 @@ sealed class Event {
context.getString(R.string.pref_key_search_bookmarks),
context.getString(R.string.pref_key_search_browsing_history),
context.getString(R.string.pref_key_show_clipboard_suggestions),
context.getString(R.string.pref_key_show_search_shortcuts)
context.getString(R.string.pref_key_show_search_shortcuts),
context.getString(R.string.pref_key_open_links_in_a_private_tab)
)
override val extras: Map<Events.preferenceToggledKeys, String>?
@ -153,6 +154,12 @@ sealed class Event {
}
}
data class OpenedLink(val mode: Mode) : Event() {
enum class Mode { NORMAL, PRIVATE }
override val extras: Map<Events.openedLinkKeys, String>?
get() = hashMapOf(Events.openedLinkKeys.mode to mode.name)
}
data class TrackingProtectionSettingChanged(val setting: Setting) : Event() {
enum class Setting { STRICT, STANDARD }
override val extras: Map<TrackingProtection.etpSettingChangedKeys, String>?

File diff suppressed because one or more lines are too long