Skip to content

Commit

Permalink
For mozilla-mobile#986 - Adds support for opening Fenix with a link t…
Browse files Browse the repository at this point in the history
…o telemetry
  • Loading branch information
boek committed Mar 19, 2019
1 parent 6b68d16 commit 9c25ad4
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 @@ -59,12 +59,17 @@ open class HomeActivity : AppCompatActivity() {
setSupportActionBar(navigationToolbar)
NavigationUI.setupWithNavController(navigationToolbar, hostNavController, 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 @@ -244,7 +244,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 9c25ad4

Please sign in to comment.