parent
99f979e86b
commit
3450c6bcf1
|
@ -123,6 +123,19 @@ events:
|
||||||
notification_emails:
|
notification_emails:
|
||||||
- fenix-core@mozilla.com
|
- fenix-core@mozilla.com
|
||||||
expires: "2020-03-01"
|
expires: "2020-03-01"
|
||||||
|
total_uri_count:
|
||||||
|
type: counter
|
||||||
|
description: >
|
||||||
|
A counter of URIs visited by the user in the current session, including page reloads. This does not include background page requests and URIs from embedded pages or private browsing.
|
||||||
|
send_in_pings:
|
||||||
|
- metrics
|
||||||
|
bugs:
|
||||||
|
- 1301
|
||||||
|
data_reviews:
|
||||||
|
- https://github.com/mozilla-mobile/fenix/pull/1785
|
||||||
|
notification_emails:
|
||||||
|
- fenix-core@mozilla.com
|
||||||
|
expires: "2020-03-01"
|
||||||
|
|
||||||
crash_reporter:
|
crash_reporter:
|
||||||
opened:
|
opened:
|
||||||
|
|
|
@ -17,6 +17,7 @@ import androidx.navigation.ui.AppBarConfiguration
|
||||||
import androidx.navigation.ui.NavigationUI
|
import androidx.navigation.ui.NavigationUI
|
||||||
import mozilla.components.browser.search.SearchEngine
|
import mozilla.components.browser.search.SearchEngine
|
||||||
import mozilla.components.browser.session.Session
|
import mozilla.components.browser.session.Session
|
||||||
|
import mozilla.components.browser.session.SessionManager
|
||||||
import mozilla.components.concept.engine.EngineView
|
import mozilla.components.concept.engine.EngineView
|
||||||
import mozilla.components.feature.intent.IntentProcessor
|
import mozilla.components.feature.intent.IntentProcessor
|
||||||
import mozilla.components.lib.crash.Crash
|
import mozilla.components.lib.crash.Crash
|
||||||
|
@ -36,6 +37,7 @@ import org.mozilla.fenix.settings.SettingsFragmentDirections
|
||||||
@SuppressWarnings("TooManyFunctions")
|
@SuppressWarnings("TooManyFunctions")
|
||||||
open class HomeActivity : AppCompatActivity() {
|
open class HomeActivity : AppCompatActivity() {
|
||||||
open val isCustomTab = false
|
open val isCustomTab = false
|
||||||
|
private var sessionObserver: SessionManager.Observer? = null
|
||||||
|
|
||||||
val themeManager = DefaultThemeManager().also {
|
val themeManager = DefaultThemeManager().also {
|
||||||
it.onThemeChange = { theme ->
|
it.onThemeChange = { theme ->
|
||||||
|
@ -85,6 +87,11 @@ open class HomeActivity : AppCompatActivity() {
|
||||||
handleOpenedFromExternalSourceIfNecessary(intent)
|
handleOpenedFromExternalSourceIfNecessary(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
sessionObserver?.let { components.core.sessionManager.unregister(it) }
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onNewIntent(intent: Intent?) {
|
override fun onNewIntent(intent: Intent?) {
|
||||||
super.onNewIntent(intent)
|
super.onNewIntent(intent)
|
||||||
handleCrashIfNecessary(intent)
|
handleCrashIfNecessary(intent)
|
||||||
|
@ -168,6 +175,8 @@ open class HomeActivity : AppCompatActivity() {
|
||||||
BrowserDirection.FromHistory ->
|
BrowserDirection.FromHistory ->
|
||||||
HistoryFragmentDirections.actionHistoryFragmentToBrowserFragment(externalSessionId)
|
HistoryFragmentDirections.actionHistoryFragmentToBrowserFragment(externalSessionId)
|
||||||
}
|
}
|
||||||
|
if (sessionObserver == null)
|
||||||
|
sessionObserver = subscribeToSessions()
|
||||||
|
|
||||||
navHost.navController.navigate(directions)
|
navHost.navController.navigate(directions)
|
||||||
}
|
}
|
||||||
|
@ -197,6 +206,47 @@ open class HomeActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val singleSessionObserver = object : Session.Observer {
|
||||||
|
var urlLoading: String? = null
|
||||||
|
|
||||||
|
override fun onLoadingStateChanged(session: Session, loading: Boolean) {
|
||||||
|
super.onLoadingStateChanged(session, loading)
|
||||||
|
|
||||||
|
if (loading) urlLoading = session.url
|
||||||
|
else if (urlLoading != null && !session.private)
|
||||||
|
components.analytics.metrics.track(Event.UriOpened)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun subscribeToSessions(): SessionManager.Observer {
|
||||||
|
|
||||||
|
return object : SessionManager.Observer {
|
||||||
|
override fun onAllSessionsRemoved() {
|
||||||
|
super.onAllSessionsRemoved()
|
||||||
|
components.core.sessionManager.sessions.forEach {
|
||||||
|
it.unregister(singleSessionObserver)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSessionAdded(session: Session) {
|
||||||
|
super.onSessionAdded(session)
|
||||||
|
session.register(singleSessionObserver)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSessionRemoved(session: Session) {
|
||||||
|
super.onSessionRemoved(session)
|
||||||
|
session.unregister(singleSessionObserver)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSessionsRestored() {
|
||||||
|
super.onSessionsRestored()
|
||||||
|
components.core.sessionManager.sessions.forEach {
|
||||||
|
it.register(singleSessionObserver)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.also { components.core.sessionManager.register(it) }
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val OPEN_TO_BROWSER = "open_to_browser"
|
const val OPEN_TO_BROWSER = "open_to_browser"
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,6 +150,9 @@ private val Event.wrapper
|
||||||
is Event.CustomTabsClosed -> EventWrapper<NoExtraKeys>(
|
is Event.CustomTabsClosed -> EventWrapper<NoExtraKeys>(
|
||||||
{ CustomTab.closed.record(it) }
|
{ CustomTab.closed.record(it) }
|
||||||
)
|
)
|
||||||
|
is Event.UriOpened -> EventWrapper<NoExtraKeys>(
|
||||||
|
{ Events.totalUriCount.add(1) }
|
||||||
|
)
|
||||||
|
|
||||||
// Don't track other events with Glean
|
// Don't track other events with Glean
|
||||||
else -> null
|
else -> null
|
||||||
|
|
|
@ -70,6 +70,7 @@ sealed class Event {
|
||||||
object CustomTabsClosed : Event()
|
object CustomTabsClosed : Event()
|
||||||
object CustomTabsActionTapped : Event()
|
object CustomTabsActionTapped : Event()
|
||||||
object CustomTabsMenuOpened : Event()
|
object CustomTabsMenuOpened : Event()
|
||||||
|
object UriOpened : Event()
|
||||||
|
|
||||||
// Interaction Events
|
// Interaction Events
|
||||||
data class SearchBarTapped(val source: Source) : Event() {
|
data class SearchBarTapped(val source: Source) : Event() {
|
||||||
|
|
Loading…
Reference in New Issue