forked from mozilla-mobile/fenix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
for mozilla-mobile#11830 added new metric for collecting startup method
for mozilla-mobile#11830 collecting startup metric inaside onNewIntent in HomeActivity clean up, added comments nitpicks cleanup move all source startup telemetry into its own logic and added an UNKOWN state nit cleanup minor changes
- Loading branch information
Showing
5 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,23 @@ no_lint: | |
- CATEGORY_GENERIC | ||
|
||
events: | ||
app_opened_all_startup: | ||
type: event | ||
description: | | ||
A user opened the app from any one of the following flows: | ||
hot, warm or cold start to the HomeActivity. | ||
extra_keys: | ||
source: | ||
description: | | ||
The method used to open Fenix. Possible values are `app_icon`, | ||
`custom_tab` or `link` or `unknown` | ||
bugs: | ||
- https://github.com/mozilla-mobile/fenix/issues/11830 | ||
data_reviews: | ||
- https://github.com/mozilla-mobile/fenix/pull/11940/ | ||
notification_emails: | ||
- [email protected] | ||
expires: "2020-12-01" | ||
app_opened: | ||
type: event | ||
description: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
app/src/main/java/org/mozilla/fenix/components/metrics/AllSourceStartupTelemetry.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.fenix.components.metrics | ||
|
||
import android.content.Intent | ||
import mozilla.components.support.utils.SafeIntent | ||
import mozilla.components.support.utils.toSafeIntent | ||
import org.mozilla.fenix.customtabs.ExternalAppBrowserActivity | ||
|
||
/** | ||
* Tracks how the application was opened through [Event.OpenedAppAllStart] | ||
* Since OnNewIntent() is always called before onStart() (in a warm/hot startup), we update | ||
* our current intent with the new intent. However we only track the event during onStart() | ||
* Because we dont want random intents with [Intent.ACTION_VIEW] to be recorded as app_opened | ||
* For example, Start app through APP_ICON -> run adb intent command to open a link. | ||
* We want to ignore these adb commands since app is already on foreground. | ||
*/ | ||
open class AllSourceStartupTelemetry(private var currentIntent: Intent?, val metrics: MetricController) { | ||
|
||
/** | ||
* Called from activity's onStart() function. records the OpenedAppALlStart telemetry. | ||
*/ | ||
fun onStart() { | ||
currentIntent?.toSafeIntent() | ||
?.let(::getIntentAllStartSource) | ||
?.also { | ||
metrics.track(Event.OpenedAppAllStart(it)) | ||
} | ||
} | ||
|
||
/** | ||
* Called from Activity's onNewIntent() function. sets our currentIntent with the latest one | ||
* received by activity's onNewIntent() function. | ||
*/ | ||
fun onNewIntent(intent: Intent?) { | ||
currentIntent = intent | ||
} | ||
|
||
open fun getIntentAllStartSource(intent: SafeIntent): Event.OpenedAppAllStart.Source? { | ||
val callingActivityName: String = intent.unsafe.component?.className.toString() | ||
return when { | ||
callingActivityName == ExternalAppBrowserActivity::class.java.name | ||
-> Event.OpenedAppAllStart.Source.CUSTOM_TAB | ||
intent.isLauncherIntent -> Event.OpenedAppAllStart.Source.APP_ICON | ||
intent.action == Intent.ACTION_VIEW -> Event.OpenedAppAllStart.Source.LINK | ||
else -> Event.OpenedAppAllStart.Source.UNKNOWN | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters