From 9690fa7c67d4a8a32981672b8609c40d93a04ba0 Mon Sep 17 00:00:00 2001 From: Irfan Omur Date: Tue, 20 Feb 2024 15:31:47 +0300 Subject: [PATCH 1/3] Remove stats_single_post_accessed event --- .../ui/stats/refresh/lists/detail/StatsDetailActivity.kt | 6 ------ .../org/wordpress/android/analytics/AnalyticsTracker.java | 1 - .../wordpress/android/analytics/AnalyticsTrackerNosara.java | 2 -- 3 files changed, 9 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailActivity.kt index 725e9ded2d76..a78ff06f39f4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailActivity.kt @@ -9,7 +9,6 @@ import androidx.fragment.app.commit import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.R import org.wordpress.android.WordPress -import org.wordpress.android.analytics.AnalyticsTracker.Stat import org.wordpress.android.databinding.StatsDetailActivityBinding import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.fluxc.network.utils.StatsGranularity @@ -19,7 +18,6 @@ import org.wordpress.android.ui.stats.refresh.StatsViewAllFragment import org.wordpress.android.ui.stats.refresh.lists.StatsListFragment import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection import org.wordpress.android.ui.stats.refresh.lists.sections.granular.SelectedDateProvider.SelectedDate -import org.wordpress.android.util.analytics.AnalyticsUtils import org.wordpress.android.util.extensions.getSerializableCompat import java.io.Serializable import android.R as AndroidR @@ -79,10 +77,6 @@ class StatsDetailActivity : LocaleAwareActivity() { if (postUrl != null) { statsPostViewIntent.putExtra(POST_URL, postUrl) } - AnalyticsUtils.trackWithSiteId( - Stat.STATS_SINGLE_POST_ACCESSED, - site.siteId - ) context.startActivity(statsPostViewIntent) } diff --git a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java index 0fe9a77f7d2e..50fd7d55e709 100644 --- a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java +++ b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java @@ -133,7 +133,6 @@ public enum Stat { STATS_SEARCH_TERMS_VIEW_MORE_TAPPED, STATS_AUTHORS_VIEW_MORE_TAPPED, STATS_FILE_DOWNLOADS_VIEW_MORE_TAPPED, - STATS_SINGLE_POST_ACCESSED, STATS_TAPPED_BAR_CHART, STATS_OVERVIEW_TYPE_TAPPED, STATS_SCROLLED_TO_BOTTOM, diff --git a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java index 2f946200e424..ffc340a33c3b 100644 --- a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java +++ b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java @@ -1191,8 +1191,6 @@ public static String getEventNameForStat(AnalyticsTracker.Stat stat) { return "stats_authors_view_post_tapped"; case STATS_CLICKS_ITEM_TAPPED: return "stats_clicks_item_tapped"; - case STATS_SINGLE_POST_ACCESSED: - return "stats_single_post_accessed"; case STATS_TAPPED_BAR_CHART: return "stats_bar_chart_tapped"; case STATS_OVERVIEW_TYPE_TAPPED: From 066813497835d37be2c2e66b5c2a85216b48af56 Mon Sep 17 00:00:00 2001 From: Irfan Omur Date: Tue, 20 Feb 2024 15:32:37 +0300 Subject: [PATCH 2/3] Track opening stats from posts --- .../wordpress/android/ui/stats/refresh/StatsActivity.kt | 1 + .../stats/refresh/lists/detail/StatsDetailViewModel.kt | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt index 0366e091f397..bd6a90359e6e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt @@ -95,6 +95,7 @@ class StatsActivity : LocaleAwareActivity() { QUICK_ACTIONS("quick_actions"), TODAY_STATS_CARD("today_stats_card"), ROW("row"), + POSTS("posts"), WIDGET("widget"), NOTIFICATION("notification"), LINK("link"), diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailViewModel.kt index fbf2dd1203ec..76a2de2817ce 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailViewModel.kt @@ -10,11 +10,14 @@ import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalOverlayUtil import org.wordpress.android.ui.jetpackoverlay.JetpackOverlayConnectedFeature import org.wordpress.android.ui.pages.SnackbarMessageHolder import org.wordpress.android.ui.stats.refresh.BLOCK_DETAIL_USE_CASE +import org.wordpress.android.ui.stats.refresh.StatsActivity import org.wordpress.android.ui.stats.refresh.lists.BaseListUseCase import org.wordpress.android.ui.stats.refresh.utils.StatsPostProvider import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider +import org.wordpress.android.ui.stats.refresh.utils.trackStatsAccessed import org.wordpress.android.ui.utils.UiString.UiStringRes import org.wordpress.android.util.NetworkUtilsWrapper +import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper import org.wordpress.android.util.mergeNotNull import org.wordpress.android.viewmodel.Event import org.wordpress.android.viewmodel.ScopedViewModel @@ -28,6 +31,7 @@ class StatsDetailViewModel private val statsSiteProvider: StatsSiteProvider, private val statsPostProvider: StatsPostProvider, private val networkUtilsWrapper: NetworkUtilsWrapper, + private val analyticsTrackerWrapper: AnalyticsTrackerWrapper, private val jetpackFeatureRemovalOverlayUtil: JetpackFeatureRemovalOverlayUtil ) : ScopedViewModel(mainDispatcher) { private val _isRefreshing = MutableLiveData() @@ -49,6 +53,11 @@ class StatsDetailViewModel postTitle: String, postUrl: String? ) { + analyticsTrackerWrapper.trackStatsAccessed( + statsSiteProvider.siteModel, + StatsActivity.StatsLaunchedFrom.POSTS.value + ) + statsPostProvider.init(postId, postType, postTitle, postUrl) if (jetpackFeatureRemovalOverlayUtil.shouldShowFeatureSpecificJetpackOverlay( From 88960d9db30bfe014ecb90b2f754ca1af16eef38 Mon Sep 17 00:00:00 2001 From: Irfan Omur Date: Tue, 20 Feb 2024 16:06:35 +0300 Subject: [PATCH 3/3] Move `StatsLaunchedFrom` to a more appropriate place --- .../org/wordpress/android/ui/ActivityLauncher.java | 2 +- .../ui/JetpackConnectionResultActivity.java | 2 +- .../wordpress/android/ui/ShortcutsNavigator.java | 2 +- .../android/ui/deeplinks/DeepLinkNavigator.kt | 6 +++--- .../wordpress/android/ui/main/WPMainActivity.java | 2 +- .../wordpress/android/ui/mysite/MySiteFragment.kt | 6 +++--- .../android/ui/mysite/menu/MenuActivity.kt | 4 ++-- .../notifications/NotificationsDetailActivity.java | 2 +- .../utils/FormattableContentClickHandler.kt | 4 ++-- .../android/ui/stats/refresh/StatsActivity.kt | 14 +------------- .../android/ui/stats/refresh/StatsViewModel.kt | 2 +- .../refresh/lists/detail/StatsDetailViewModel.kt | 4 ++-- .../lists/widget/WidgetBlockListProvider.kt | 2 +- .../widget/alltime/AllTimeWidgetListProvider.kt | 2 +- .../lists/widget/today/TodayWidgetListProvider.kt | 2 +- .../refresh/lists/widget/utils/WidgetUtils.kt | 2 +- .../lists/widget/views/ViewsWidgetListProvider.kt | 2 +- .../widget/weeks/WeekViewsWidgetListProvider.kt | 2 +- .../ui/stats/refresh/utils/StatsAnalyticsUtils.kt | 13 +++++++++++++ .../workers/weeklyroundup/WeeklyRoundupNotifier.kt | 4 ++-- .../android/ui/stats/refresh/StatsViewModelTest.kt | 5 +++-- 21 files changed, 43 insertions(+), 41 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java b/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java index e3827621c198..c747aa323831 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java @@ -116,12 +116,12 @@ import org.wordpress.android.ui.stats.StatsTimeframe; import org.wordpress.android.ui.stats.StatsViewType; import org.wordpress.android.ui.stats.refresh.StatsActivity; -import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom; import org.wordpress.android.ui.stats.refresh.StatsViewAllActivity; import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection; import org.wordpress.android.ui.stats.refresh.lists.detail.StatsDetailActivity; import org.wordpress.android.ui.stats.refresh.lists.sections.granular.SelectedDateProvider.SelectedDate; import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management.InsightsManagementActivity; +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom; import org.wordpress.android.ui.stockmedia.StockMediaPickerActivity; import org.wordpress.android.ui.stories.StoryComposerActivity; import org.wordpress.android.ui.suggestion.SuggestionActivity; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java index 85b6abe0cde0..7bc61f8a5342 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java @@ -20,7 +20,7 @@ import org.wordpress.android.fluxc.store.SiteStore; import org.wordpress.android.login.LoginMode; import org.wordpress.android.ui.accounts.LoginActivity; -import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom; +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.SiteUtils; import org.wordpress.android.util.ToastUtils; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ShortcutsNavigator.java b/WordPress/src/main/java/org/wordpress/android/ui/ShortcutsNavigator.java index 59f1d5a96a01..f0f1a1efb166 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/ShortcutsNavigator.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/ShortcutsNavigator.java @@ -5,7 +5,7 @@ import org.wordpress.android.analytics.AnalyticsTracker; import org.wordpress.android.fluxc.model.SiteModel; import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalPhaseHelper; -import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom; +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom; import org.wordpress.android.util.AppLog; import javax.inject.Inject; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkNavigator.kt b/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkNavigator.kt index 748e26a9baec..93b81619cefd 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkNavigator.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkNavigator.kt @@ -29,7 +29,7 @@ import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.ViewP import org.wordpress.android.ui.sitecreation.misc.SiteCreationSource.DEEP_LINK import org.wordpress.android.ui.sitemonitor.SiteMonitorType import org.wordpress.android.ui.stats.StatsTimeframe -import org.wordpress.android.ui.stats.refresh.StatsActivity +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import org.wordpress.android.util.UriWrapper import javax.inject.Inject @@ -66,14 +66,14 @@ class DeepLinkNavigator is OpenStatsForSite -> ActivityLauncher.viewStatsInNewStack( activity, navigateAction.site, - StatsActivity.StatsLaunchedFrom.LINK + StatsLaunchedFrom.LINK ) is OpenStatsForSiteAndTimeframe -> ActivityLauncher.viewStatsInNewStack( activity, navigateAction.site, navigateAction.statsTimeframe, - StatsActivity.StatsLaunchedFrom.LINK + StatsLaunchedFrom.LINK ) OpenReader -> ActivityLauncher.viewReaderInNewStack(activity) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java index 27cc8feae2a3..b2a55812a397 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java @@ -134,7 +134,7 @@ import org.wordpress.android.ui.review.ReviewViewModel; import org.wordpress.android.ui.sitecreation.misc.SiteCreationSource; import org.wordpress.android.ui.stats.StatsTimeframe; -import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom; +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom; import org.wordpress.android.ui.stories.intro.StoriesIntroDialogFragment; import org.wordpress.android.ui.uploads.UploadActionUseCase; import org.wordpress.android.ui.uploads.UploadUtils; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteFragment.kt index fecc440b3294..d6f4d88ee399 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteFragment.kt @@ -59,7 +59,7 @@ import org.wordpress.android.ui.quickstart.QuickStartTracker import org.wordpress.android.ui.reader.ReaderActivityLauncher import org.wordpress.android.ui.reader.tracker.ReaderTracker import org.wordpress.android.ui.stats.StatsTimeframe -import org.wordpress.android.ui.stats.refresh.StatsActivity +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import org.wordpress.android.ui.uploads.UploadService import org.wordpress.android.ui.uploads.UploadUtilsWrapper import org.wordpress.android.ui.utils.TitleSubtitleSnackbarSpannable @@ -611,7 +611,7 @@ class MySiteFragment : Fragment(R.layout.my_site_fragment), is SiteNavigationAction.OpenStats -> ActivityLauncher.viewBlogStats( activity, action.site, - StatsActivity.StatsLaunchedFrom.QUICK_ACTIONS + StatsLaunchedFrom.QUICK_ACTIONS ) is SiteNavigationAction.ConnectJetpackForStats -> @@ -678,7 +678,7 @@ class MySiteFragment : Fragment(R.layout.my_site_fragment), requireActivity(), action.site, StatsTimeframe.INSIGHTS, - StatsActivity.StatsLaunchedFrom.TODAY_STATS_CARD + StatsLaunchedFrom.TODAY_STATS_CARD ) is SiteNavigationAction.OpenExternalUrl -> diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuActivity.kt index 33f583b28840..77ac0aa5d5c1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuActivity.kt @@ -64,7 +64,7 @@ import org.wordpress.android.ui.mysite.items.listitem.ListItemAction import org.wordpress.android.ui.pages.SnackbarMessageHolder import org.wordpress.android.ui.prefs.SiteSettingsFragment import org.wordpress.android.ui.quickstart.QuickStartMySitePrompts -import org.wordpress.android.ui.stats.refresh.StatsActivity +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import org.wordpress.android.ui.utils.ListItemInteraction import org.wordpress.android.ui.utils.UiString import org.wordpress.android.util.LocaleManager @@ -147,7 +147,7 @@ class MenuActivity : AppCompatActivity() { is SiteNavigationAction.OpenStats -> ActivityLauncher.viewBlogStats( this, action.site, - StatsActivity.StatsLaunchedFrom.ROW + StatsLaunchedFrom.ROW ) is SiteNavigationAction.OpenDomains -> ActivityLauncher.viewDomainsDashboardActivity( diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java index 4dc25520a642..750629d332f5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java @@ -54,7 +54,7 @@ import org.wordpress.android.ui.reader.comments.ThreadedCommentsActionSource; import org.wordpress.android.ui.reader.tracker.ReaderTracker; import org.wordpress.android.ui.stats.StatsViewType; -import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom; +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.StringUtils; import org.wordpress.android.util.ToastUtils; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/utils/FormattableContentClickHandler.kt b/WordPress/src/main/java/org/wordpress/android/ui/notifications/utils/FormattableContentClickHandler.kt index f42672dc941e..46d85fabbbc4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/utils/FormattableContentClickHandler.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/utils/FormattableContentClickHandler.kt @@ -16,7 +16,7 @@ import org.wordpress.android.ui.reader.comments.ThreadedCommentsActionSource.ACT import org.wordpress.android.ui.reader.tracker.ReaderTracker import org.wordpress.android.ui.reader.utils.ReaderUtils import org.wordpress.android.ui.stats.StatsViewType.FOLLOWERS -import org.wordpress.android.ui.stats.refresh.StatsActivity +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import org.wordpress.android.util.AppLog import org.wordpress.android.util.AppLog.T.API import org.wordpress.android.util.ToastUtils @@ -118,7 +118,7 @@ class FormattableContentClickHandler @Inject constructor( if (rangeType == FormattableRangeType.FOLLOW) { ActivityLauncher.viewAllTabbedInsightsStats(activity, FOLLOWERS, 0, site.id) } else { - ActivityLauncher.viewBlogStats(activity, site, StatsActivity.StatsLaunchedFrom.ACTIVITY_LOG) + ActivityLauncher.viewBlogStats(activity, site, StatsLaunchedFrom.ACTIVITY_LOG) } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt index bd6a90359e6e..9ee8db7113e6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt @@ -15,6 +15,7 @@ import org.wordpress.android.ui.ActivityLauncher import org.wordpress.android.ui.LocaleAwareActivity import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalPhaseHelper import org.wordpress.android.ui.stats.StatsTimeframe +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider import org.wordpress.android.util.JetpackBrandingUtils import javax.inject.Inject @@ -90,17 +91,4 @@ class StatsActivity : LocaleAwareActivity() { notificationType?.let { putExtra(ARG_NOTIFICATION_TYPE, it) } } } - - enum class StatsLaunchedFrom(val value: String) { - QUICK_ACTIONS("quick_actions"), - TODAY_STATS_CARD("today_stats_card"), - ROW("row"), - POSTS("posts"), - WIDGET("widget"), - NOTIFICATION("notification"), - LINK("link"), - SHORTCUT("shortcut"), - ACTIVITY_LOG("activity_log"), - JETPACK_CONNECTION("jetpack_connection") - } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewModel.kt index cc1ae6094087..4c4fa6cfd0b3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewModel.kt @@ -37,7 +37,6 @@ import org.wordpress.android.ui.stats.StatsTimeframe.DAY import org.wordpress.android.ui.stats.StatsTimeframe.MONTH import org.wordpress.android.ui.stats.StatsTimeframe.WEEK import org.wordpress.android.ui.stats.StatsTimeframe.YEAR -import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom import org.wordpress.android.ui.stats.refresh.StatsModuleActivateRequestState.Failure.NetworkUnavailable import org.wordpress.android.ui.stats.refresh.StatsModuleActivateRequestState.Failure.RemoteRequestFailure import org.wordpress.android.ui.stats.refresh.StatsModuleActivateRequestState.Success @@ -47,6 +46,7 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.granular.SelectedDa import org.wordpress.android.ui.stats.refresh.utils.NewsCardHandler import org.wordpress.android.ui.stats.refresh.utils.SelectedSectionManager import org.wordpress.android.ui.stats.refresh.utils.SelectedTrafficGranularityManager +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider import org.wordpress.android.ui.stats.refresh.utils.toStatsGranularity import org.wordpress.android.ui.stats.refresh.utils.trackStatsAccessed diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailViewModel.kt index 76a2de2817ce..553705b62d29 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailViewModel.kt @@ -10,8 +10,8 @@ import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalOverlayUtil import org.wordpress.android.ui.jetpackoverlay.JetpackOverlayConnectedFeature import org.wordpress.android.ui.pages.SnackbarMessageHolder import org.wordpress.android.ui.stats.refresh.BLOCK_DETAIL_USE_CASE -import org.wordpress.android.ui.stats.refresh.StatsActivity import org.wordpress.android.ui.stats.refresh.lists.BaseListUseCase +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import org.wordpress.android.ui.stats.refresh.utils.StatsPostProvider import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider import org.wordpress.android.ui.stats.refresh.utils.trackStatsAccessed @@ -55,7 +55,7 @@ class StatsDetailViewModel ) { analyticsTrackerWrapper.trackStatsAccessed( statsSiteProvider.siteModel, - StatsActivity.StatsLaunchedFrom.POSTS.value + StatsLaunchedFrom.POSTS.value ) statsPostProvider.init(postId, postType, postTitle, postUrl) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/WidgetBlockListProvider.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/WidgetBlockListProvider.kt index 51437fe4dba2..3449a5ac4691 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/WidgetBlockListProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/WidgetBlockListProvider.kt @@ -11,9 +11,9 @@ import org.wordpress.android.WordPress import org.wordpress.android.ui.stats.StatsTimeframe import org.wordpress.android.ui.stats.StatsTimeframe.INSIGHTS import org.wordpress.android.ui.stats.refresh.StatsActivity -import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsColorSelectionViewModel.Color import org.wordpress.android.ui.stats.refresh.lists.widget.utils.getColorMode +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom class WidgetBlockListProvider(val context: Context, val viewModel: WidgetBlockListViewModel, intent: Intent) : RemoteViewsFactory { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/alltime/AllTimeWidgetListProvider.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/alltime/AllTimeWidgetListProvider.kt index 3c47027e270b..b1b164b131df 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/alltime/AllTimeWidgetListProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/alltime/AllTimeWidgetListProvider.kt @@ -10,10 +10,10 @@ import org.wordpress.android.R import org.wordpress.android.WordPress import org.wordpress.android.ui.stats.StatsTimeframe import org.wordpress.android.ui.stats.refresh.StatsActivity -import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom import org.wordpress.android.ui.stats.refresh.lists.widget.SITE_ID_KEY import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsColorSelectionViewModel.Color import org.wordpress.android.ui.stats.refresh.lists.widget.utils.getColorMode +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import javax.inject.Inject class AllTimeWidgetListProvider(val context: Context, intent: Intent) : RemoteViewsFactory { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetListProvider.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetListProvider.kt index e0e3918d8bd4..2324165600a6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetListProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetListProvider.kt @@ -9,10 +9,10 @@ import org.wordpress.android.R import org.wordpress.android.WordPress import org.wordpress.android.ui.stats.StatsTimeframe import org.wordpress.android.ui.stats.refresh.StatsActivity -import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom import org.wordpress.android.ui.stats.refresh.lists.widget.SITE_ID_KEY import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsColorSelectionViewModel.Color import org.wordpress.android.ui.stats.refresh.lists.widget.utils.getColorMode +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import javax.inject.Inject class TodayWidgetListProvider(val context: Context, intent: Intent) : RemoteViewsFactory { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/utils/WidgetUtils.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/utils/WidgetUtils.kt index 6693aa25c36f..e0610129a1ac 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/utils/WidgetUtils.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/utils/WidgetUtils.kt @@ -21,7 +21,6 @@ import org.wordpress.android.fluxc.model.stats.time.VisitsAndViewsModel.PeriodDa import org.wordpress.android.modules.UI_THREAD import org.wordpress.android.ui.stats.StatsTimeframe import org.wordpress.android.ui.stats.refresh.StatsActivity -import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom import org.wordpress.android.ui.stats.refresh.lists.widget.IS_WIDE_VIEW_KEY import org.wordpress.android.ui.stats.refresh.lists.widget.SITE_ID_KEY import org.wordpress.android.ui.stats.refresh.lists.widget.WidgetService @@ -29,6 +28,7 @@ import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsCo import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsColorSelectionViewModel.Color.DARK import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsColorSelectionViewModel.Color.LIGHT import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsWidgetConfigureFragment.WidgetType +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import org.wordpress.android.util.image.ImageManager import org.wordpress.android.util.image.ImageType.ICON import org.wordpress.android.viewmodel.ResourceProvider diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/views/ViewsWidgetListProvider.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/views/ViewsWidgetListProvider.kt index 0f7c58c6d537..01bc058bdc45 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/views/ViewsWidgetListProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/views/ViewsWidgetListProvider.kt @@ -11,10 +11,10 @@ import org.wordpress.android.WordPress import org.wordpress.android.ui.stats.StatsTimeframe import org.wordpress.android.ui.stats.refresh.StatsActivity import org.wordpress.android.ui.stats.refresh.StatsActivity.Companion.INITIAL_SELECTED_PERIOD_KEY -import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom import org.wordpress.android.ui.stats.refresh.lists.widget.IS_WIDE_VIEW_KEY import org.wordpress.android.ui.stats.refresh.lists.widget.SITE_ID_KEY import org.wordpress.android.ui.stats.refresh.lists.widget.utils.getColorMode +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import javax.inject.Inject class ViewsWidgetListProvider(val context: Context, intent: Intent) : RemoteViewsFactory { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/WeekViewsWidgetListProvider.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/WeekViewsWidgetListProvider.kt index 9ea2cf71fd5c..0dec0e048699 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/WeekViewsWidgetListProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/WeekViewsWidgetListProvider.kt @@ -9,10 +9,10 @@ import org.wordpress.android.R import org.wordpress.android.WordPress import org.wordpress.android.ui.stats.StatsTimeframe import org.wordpress.android.ui.stats.refresh.StatsActivity -import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom import org.wordpress.android.ui.stats.refresh.lists.widget.SITE_ID_KEY import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsColorSelectionViewModel.Color import org.wordpress.android.ui.stats.refresh.lists.widget.utils.getColorMode +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import javax.inject.Inject class WeekViewsWidgetListProvider(val context: Context, intent: Intent) : RemoteViewsFactory { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/StatsAnalyticsUtils.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/StatsAnalyticsUtils.kt index cc2f79968e45..2b7e7aa738f1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/StatsAnalyticsUtils.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/StatsAnalyticsUtils.kt @@ -30,6 +30,19 @@ private const val MINIFIED_WIDGET_PROPERTY = "minified" private const val CHIP_VIEWS_PROPERTY = "views" private const val CHIP_VISITORS__PROPERTY = "visitors" +enum class StatsLaunchedFrom(val value: String) { + QUICK_ACTIONS("quick_actions"), + TODAY_STATS_CARD("today_stats_card"), + ROW("row"), + POSTS("posts"), + WIDGET("widget"), + NOTIFICATION("notification"), + LINK("link"), + SHORTCUT("shortcut"), + ACTIVITY_LOG("activity_log"), + JETPACK_CONNECTION("jetpack_connection") +} + fun AnalyticsTrackerWrapper.trackStatsAccessed(site: SiteModel, tapSource: String) = track(stat = Stat.STATS_ACCESSED, site = site, properties = mutableMapOf(TAP_SOURCE_PROPERTY to tapSource)) diff --git a/WordPress/src/main/java/org/wordpress/android/workers/weeklyroundup/WeeklyRoundupNotifier.kt b/WordPress/src/main/java/org/wordpress/android/workers/weeklyroundup/WeeklyRoundupNotifier.kt index 0924049102aa..93d7e89bf823 100644 --- a/WordPress/src/main/java/org/wordpress/android/workers/weeklyroundup/WeeklyRoundupNotifier.kt +++ b/WordPress/src/main/java/org/wordpress/android/workers/weeklyroundup/WeeklyRoundupNotifier.kt @@ -16,7 +16,7 @@ import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalPhaseHelper import org.wordpress.android.ui.notifications.SystemNotificationsTracker import org.wordpress.android.ui.prefs.AppPrefsWrapper import org.wordpress.android.ui.stats.StatsTimeframe.WEEK -import org.wordpress.android.ui.stats.refresh.StatsActivity +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import org.wordpress.android.ui.stats.refresh.utils.StatsUtils import org.wordpress.android.util.SiteUtilsWrapper import org.wordpress.android.viewmodel.ContextProvider @@ -76,7 +76,7 @@ class WeeklyRoundupNotifier @Inject constructor( WEEK, data.period, WEEKLY_ROUNDUP, - StatsActivity.StatsLaunchedFrom.NOTIFICATION, + StatsLaunchedFrom.NOTIFICATION, notificationId, FLAG_CANCEL_CURRENT or FLAG_IMMUTABLE ) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/StatsViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/StatsViewModelTest.kt index 8a79b56d866f..2cd57e936815 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/StatsViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/StatsViewModelTest.kt @@ -40,6 +40,7 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.granular.SelectedDa import org.wordpress.android.ui.stats.refresh.utils.NewsCardHandler import org.wordpress.android.ui.stats.refresh.utils.SelectedSectionManager import org.wordpress.android.ui.stats.refresh.utils.SelectedTrafficGranularityManager +import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider import org.wordpress.android.ui.stats.refresh.utils.trackWithGranularity import org.wordpress.android.ui.utils.UiString.UiStringRes @@ -129,7 +130,7 @@ class StatsViewModelTest : BaseUnitTest() { trafficTabFeatureConfig ) - viewModel.start(1, StatsActivity.StatsLaunchedFrom.QUICK_ACTIONS, TRAFFIC, null, false, null) + viewModel.start(1, StatsLaunchedFrom.QUICK_ACTIONS, TRAFFIC, null, false, null) } @Test @@ -352,7 +353,7 @@ class StatsViewModelTest : BaseUnitTest() { private fun startViewModel(statsModuleEnabled: Boolean = true) { whenever(site.isActiveModuleEnabled(any())).thenReturn(statsModuleEnabled) - viewModel.start(1, StatsActivity.StatsLaunchedFrom.QUICK_ACTIONS, null, null, false, null) + viewModel.start(1, StatsLaunchedFrom.QUICK_ACTIONS, null, null, false, null) } private val networkUnavailableError = StatsModuleActivateRequestState.Failure.NetworkUnavailable