-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
questionFurther information is requestedFurther information is requested
Description
Summary
fun trackScreenViewedEvent(activity: Activity) {
try {
val packageManager = activity.packageManager
val info = packageManager?.getActivityInfo(
activity.componentName,
PackageManager.GET_META_DATA,
)
/* Get the label metadata in following order
1. activity label
2. if 1 is missing, fallback to parent application label
3. if 2 is missing, use the activity name
*/
val activityLabel = info?.loadLabel(packageManager)?.toString() ?: info?.name
amplitude.track(EventTypes.SCREEN_VIEWED, mapOf(EventProperties.SCREEN_NAME to activityLabel))
} catch (e: PackageManager.NameNotFoundException) {
amplitude.logger.error("Failed to get activity info: $e")
} catch (e: Exception) {
amplitude.logger.error("Failed to track screen viewed event: $e")
}
}
Most of our activity has not set a label and our application has a label.
Then it would fallback to parent application label, and never goes to #3 to return a activity name.
Which means all the [Amplitude] Screen Viewed
event can not tell the difference of which screen the user is viewing.
Do we have a plan to use the activity name as fallback when there is no activity label?
We can use the info?labelRes == 0
to find whether #1 is matched, instead of info?.loadLabel
liuyang1520 and Toby237
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested