|
|
|
@ -3,6 +3,7 @@
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
package org.mozilla.fenix.components.metrics
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import mozilla.components.browser.search.SearchEngine
|
|
|
|
|
import mozilla.components.support.base.Component
|
|
|
|
|
import mozilla.components.support.base.facts.Fact
|
|
|
|
@ -10,6 +11,8 @@ import mozilla.components.support.base.facts.FactProcessor
|
|
|
|
|
import mozilla.components.support.base.facts.Facts
|
|
|
|
|
import mozilla.components.support.base.log.logger.Logger
|
|
|
|
|
import org.mozilla.fenix.BuildConfig
|
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
|
import java.lang.IllegalArgumentException
|
|
|
|
|
|
|
|
|
|
sealed class Event {
|
|
|
|
|
|
|
|
|
@ -72,6 +75,29 @@ sealed class Event {
|
|
|
|
|
object CustomTabsMenuOpened : Event()
|
|
|
|
|
object UriOpened : Event()
|
|
|
|
|
|
|
|
|
|
data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() {
|
|
|
|
|
private val switchPreferenceTelemetryAllowList = listOf(
|
|
|
|
|
context.getString(R.string.pref_key_leakcanary),
|
|
|
|
|
context.getString(R.string.pref_key_make_default_browser),
|
|
|
|
|
context.getString(R.string.pref_key_show_search_suggestions),
|
|
|
|
|
context.getString(R.string.pref_key_show_visited_sites_bookmarks),
|
|
|
|
|
context.getString(R.string.pref_key_remote_debugging),
|
|
|
|
|
context.getString(R.string.pref_key_telemetry),
|
|
|
|
|
context.getString(R.string.pref_key_tracking_protection)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
override val extras: Map<String, String>?
|
|
|
|
|
get() = mapOf(
|
|
|
|
|
"preferenceKey" to preferenceKey,
|
|
|
|
|
"enabled" to enabled.toString()
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
init {
|
|
|
|
|
// If the event is not in the allow list, we don't want to track it
|
|
|
|
|
if (!switchPreferenceTelemetryAllowList.contains(preferenceKey)) { throw IllegalArgumentException() }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Interaction Events
|
|
|
|
|
data class SearchBarTapped(val source: Source) : Event() {
|
|
|
|
|
enum class Source { HOME, BROWSER }
|
|
|
|
|