Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #986 - Adds support for opening Fenix with a link to telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
boek committed Mar 22, 2019
1 parent da311fc commit b2c8e59
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
17 changes: 11 additions & 6 deletions app/src/main/java/org/mozilla/fenix/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,17 @@ open class HomeActivity : AppCompatActivity() {
setSupportActionBar(navigationToolbar)
NavigationUI.setupWithNavController(navigationToolbar, navHost.navController, appBarConfiguration)

val safeIntent = intent?.let { SafeIntent(it) }

if (safeIntent?.isLauncherIntent == true) {
val source = if (isCustomTab) Event.OpenedApp.Source.CUSTOM_TAB else Event.OpenedApp.Source.APP_ICON
components.analytics.metrics.track(Event.OpenedApp(source))
}
intent
?.let { SafeIntent(it) }
?.let {
when {
isCustomTab -> Event.OpenedApp.Source.CUSTOM_TAB
it.isLauncherIntent -> Event.OpenedApp.Source.APP_ICON
it.action == Intent.ACTION_VIEW -> Event.OpenedApp.Source.LINK
else -> null
}
}
?.also { components.analytics.metrics.track(Event.OpenedApp(it)) }

handleOpenedFromExternalSourceIfNecessary(intent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ class BrowserFragment : Fragment(), BackHandler {
requireComponents.core.sessionManager.selectedSession?.id)
)

requireComponents.analytics.metrics.track(Event.SearchBarTapped(Event.SearchBarTapped.Source.BROWSER))
requireComponents.analytics.metrics.track(
Event.SearchBarTapped(Event.SearchBarTapped.Source.BROWSER)
)
}
is SearchAction.ToolbarMenuItemTapped -> handleToolbarItemInteraction(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.mozilla.fenix.debug.GleanMetrics.Metrics
import org.mozilla.fenix.debug.GleanMetrics.Events

private val Event.metricType: EventMetricType?
get() = when(this) {
get() = when (this) {
is Event.OpenedApp -> Events.appOpened
is Event.SearchBarTapped -> Events.searchBarTapped
is Event.EnteredUrl -> Events.enteredUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ sealed class Event {
object RemoveBookmark : Event()
object OpenedBookmark : Event()


data class OpenedApp(val source: Source) : Event() {
enum class Source { APP_ICON, CUSTOM_TAB }
enum class Source { APP_ICON, LINK, CUSTOM_TAB }
override val extras: Map<String, String>?
get() = hashMapOf("source" to source.name)
}
Expand Down

0 comments on commit b2c8e59

Please sign in to comment.