mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/3676: fix duplicate uri events on first load (https://github.com/mozilla-mobile/fenix/pull/6128)
This commit is contained in:
parent
16eebc77c9
commit
69406b4230
@ -30,14 +30,33 @@ class UriOpenedObserver(
|
||||
sessionManager.register(this, owner)
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently, [Session.Observer.onLoadingStateChanged] is called multiple times the first
|
||||
* time a new session loads a page. This is inflating our telemetry numbers, so we need to
|
||||
* handle it, but we will be able to remove this code when [onLoadingStateChanged] has
|
||||
* been fixed.
|
||||
*
|
||||
* See Fenix #3676
|
||||
* See AC https://github.com/mozilla-mobile/android-components/issues/4795
|
||||
* TODO remove this class after AC #4795 has been fixed
|
||||
*/
|
||||
private class TemporaryFix {
|
||||
var eventSentFor: String? = null
|
||||
|
||||
fun shouldSendEvent(newUrl: String): Boolean = eventSentFor != newUrl
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
internal val singleSessionObserver = object : Session.Observer {
|
||||
private var urlLoading: String? = null
|
||||
|
||||
private val temporaryFix = TemporaryFix()
|
||||
|
||||
override fun onLoadingStateChanged(session: Session, loading: Boolean) {
|
||||
if (loading) {
|
||||
urlLoading = session.url
|
||||
} else if (urlLoading != null && !session.private) {
|
||||
} else if (urlLoading != null && !session.private && temporaryFix.shouldSendEvent(session.url)) {
|
||||
temporaryFix.eventSentFor = session.url
|
||||
metrics.track(Event.UriOpened)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user