1
0
Fork 0

for #11830 added new metric for collecting startup method from all startup phases (#11940)

* for #11830 added new metric for collecting startup method

move all source startup telemetry into its own logic and added an UNKOWN state

* switched back to onNewIntent solution

* renamed the metric
master
Sachin 2020-06-26 17:38:08 -07:00 committed by GitHub
parent 61b1b5a895
commit 4b9cc954fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 2 deletions

View File

@ -8,6 +8,32 @@ no_lint:
- CATEGORY_GENERIC
events:
app_received_intent:
type: event
description: |
The system received an Intent for the HomeActivity. An intent
is received an external entity wants to the app to display
content. Intents can be received when the app is closed at
which point the app will be opened or when the app is
already opened at which point the already open app will make
changes such as loading a url. This can be used loosely as a
heuristic for when the user requested to open the app. The
HomeActivity encompasses the home screen and browser screen but
may include other screens. This differs from the app_opened
probe because it measures all startups, not just cold startup.
extra_keys:
source:
description: |
The method used to open Fenix. Possible values are `app_icon`,
`custom_tab`, `link` or `unknown`
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11830
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/11940/
notification_emails:
- esmyth@mozilla.com
- perf-android-fe@mozilla.com
expires: "2020-12-01"
app_opened:
type: event
description: |

View File

@ -174,10 +174,14 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
lifecycle.addObserver(BreadcrumbsRecorder(components.analytics.crashReporter,
navHost.navController, ::getBreadcrumbMessage))
intent
?.toSafeIntent()
val safeIntent = intent?.toSafeIntent()
safeIntent
?.let(::getIntentSource)
?.also { components.analytics.metrics.track(Event.OpenedApp(it)) }
// record on cold startup
safeIntent
?.let(::getIntentAllSource)
?.also { components.analytics.metrics.track(Event.AppRecievedIntent(it)) }
}
supportActionBar?.hide()
@ -250,6 +254,15 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
?.let { it as? TabTrayDialogFragment }
?.also { it.dismissAllowingStateLoss() }
}
// If there is a warm or hot startup, onNewIntent method is always called first.
// Note: This does not work in case of an user sending an intent with ACTION_VIEW
// for example, launch the application, and than use adb to send an intent with
// ACTION_VIEW to open a link. In this case, we will get multiple telemetry events.
intent
.toSafeIntent()
.let(::getIntentAllSource)
?.also { components.analytics.metrics.track(Event.AppRecievedIntent(it)) }
}
/**
@ -320,6 +333,14 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
}
}
protected open fun getIntentAllSource(intent: SafeIntent): Event.AppRecievedIntent.Source? {
return when {
intent.isLauncherIntent -> Event.AppRecievedIntent.Source.APP_ICON
intent.action == Intent.ACTION_VIEW -> Event.AppRecievedIntent.Source.LINK
else -> Event.AppRecievedIntent.Source.UNKNOWN
}
}
/**
* External sources such as 3rd party links and shortcuts use this function to enter
* private mode directly before the content view is created. Returns the mode set by the intent

View File

@ -97,6 +97,10 @@ private val Event.wrapper: EventWrapper<*>?
{ Events.appOpened.record(it) },
{ Events.appOpenedKeys.valueOf(it) }
)
is Event.AppRecievedIntent -> EventWrapper(
{ Events.appReceivedIntent.record(it) },
{ Events.appReceivedIntentKeys.valueOf(it) }
)
is Event.SearchBarTapped -> EventWrapper(
{ Events.searchBarTapped.record(it) },
{ Events.searchBarTappedKeys.valueOf(it) }

View File

@ -309,6 +309,13 @@ sealed class Event {
get() = hashMapOf(Events.appOpenedKeys.source to source.name)
}
data class AppRecievedIntent(val source: Source) : Event() {
enum class Source { APP_ICON, LINK, CUSTOM_TAB, UNKNOWN }
override val extras: Map<Events.appReceivedIntentKeys, String>?
get() = hashMapOf(Events.appReceivedIntentKeys.source to source.name)
}
data class CollectionSaveButtonPressed(val fromScreen: String) : Event() {
override val extras: Map<Collections.saveButtonKeys, String>?
get() = mapOf(Collections.saveButtonKeys.fromScreen to fromScreen)

View File

@ -41,6 +41,8 @@ open class ExternalAppBrowserActivity : HomeActivity() {
final override fun getIntentSource(intent: SafeIntent) = Event.OpenedApp.Source.CUSTOM_TAB
final override fun getIntentAllSource(intent: SafeIntent) = Event.AppRecievedIntent.Source.CUSTOM_TAB
final override fun getIntentSessionId(intent: SafeIntent) = intent.getSessionId()
override fun getNavDirections(

File diff suppressed because one or more lines are too long