Repository: wordpress-mobile/WordPress-Android (language: kotlin)

Issue:
Missing tracking of Menu items in MySiteDashboard
### Expected behavior
On clicking menu items in MySiteDashboard the following event should be triggered for all the items 
-  🔵 Tracked: my_site_menu_item_tapped, Properties: {"type":"MENU_ITEM_LABEL"}

### Actual behavior
The tracking is present only for Posts and Stats Menu item 

### Steps to reproduce the behavior
1. Login to the app 
2. Go to Menu 
3. Tap on menu item posts|stats
4. Verify that the tracking is present 
5. Tap on any other item 
6. Notice that no tracking is present

##### Tested on [device], Android [version], JPAndroid / WPAndroid [version]
Pixel 6, Android 13, version 23.1



Discussion hints:

Pull request: Fixes: My site dashboard menu items tracking 
Fixes #19114

## Description
This PR implements the tracking on clicking menu items in MySiteDashboard

## To test:
1. Login to the app
2. Go to Menu
3. Tap on menu item posts|stats
4. Verify that the tracking is present
5. 🔵 Tracked: my_site_menu_item_tapped, Properties: {"type":"posts|stats"}
5. Tap on any other item
6. Verify that following tracking is present
7. 🔵 Tracked: my_site_menu_item_tapped, Properties: {"type":"MENU_LABEL"}

## Regression Notes
1. Potential unintended areas of impact
Incorrect tracking 

2. What I did to test those areas of impact (or what existing automated tests I relied on)
Manual testing and Unit testing

3. What automated tests I added (or what prevented me from doing so)
Unit tests

PR submission checklist:
- [x] I have completed the Regression Notes.
- [x] I have considered adding accessibility improvements for my changes.
- [x] I have considered if this change warrants user-facing release notes and have added them to `RELEASE-NOTES.txt` if necessary.

UI Changes testing checklist:
- [x] Portrait and landscape orientations.
- [x] Light and dark modes.
- [x] Fonts: Larger, smaller and bold text.
- [x] High contrast.
- [x] Talkback.
- [x] Languages with large words or with letters/accents not frequently used in English.
- [x] Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
- [x] Large and small screen sizes. (Tablet and smaller phones)
- [x] Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)

Test command: ./gradlew :WordPress:testWordpressVanillaDebugUnitTest --tests "org.wordpress.android.ui.mysite.MySiteViewModelTest" --tests "org.wordpress.android.ui.mysite.items.SiteItemsTrackerTest"

Fix patch:
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt
index 00af915c6a45..75d903da827c 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt
@@ -106,7 +106,6 @@ import org.wordpress.android.ui.mysite.cards.quickstart.QuickStartRepository.Qui
 import org.wordpress.android.ui.mysite.cards.quickstart.QuickStartRepository.QuickStartTabStep
 import org.wordpress.android.ui.mysite.cards.siteinfo.SiteInfoHeaderCardBuilder
 import org.wordpress.android.ui.mysite.items.SiteItemsBuilder
-import org.wordpress.android.ui.mysite.items.SiteItemsTracker
 import org.wordpress.android.ui.mysite.items.listitem.ListItemAction
 import org.wordpress.android.ui.mysite.tabs.MySiteTabType
 import org.wordpress.android.ui.pages.SnackbarMessageHolder
@@ -181,7 +180,6 @@ class MySiteViewModel @Inject constructor(
     private val landOnTheEditorFeatureConfig: LandOnTheEditorFeatureConfig,
     private val mySiteSourceManager: MySiteSourceManager,
     private val cardsTracker: CardsTracker,
-    private val siteItemsTracker: SiteItemsTracker,
     private val domainRegistrationCardShownTracker: DomainRegistrationCardShownTracker,
     private val buildConfigWrapper: BuildConfigWrapper,
     mySiteDashboardTabsFeatureConfig: MySiteDashboardTabsFeatureConfig,
@@ -914,7 +912,7 @@ class MySiteViewModel @Inject constructor(
     @Suppress("ComplexMethod")
     private fun onItemClick(action: ListItemAction) {
         selectedSiteRepository.getSelectedSite()?.let { selectedSite ->
-            siteItemsTracker.trackSiteItemClicked(action)
+            analyticsTrackerWrapper.track(Stat.MY_SITE_MENU_ITEM_TAPPED, mapOf(TYPE to action.trackingLabel))
             val navigationAction = when (action) {
                 ListItemAction.ACTIVITY_LOG -> SiteNavigationAction.OpenActivityLog(selectedSite)
                 ListItemAction.BACKUP -> SiteNavigationAction.OpenBackup(selectedSite)
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/items/SiteItemsTracker.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/items/SiteItemsTracker.kt
deleted file mode 100644
index 552b676db0d1..000000000000
--- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/items/SiteItemsTracker.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.wordpress.android.ui.mysite.items
-
-import org.wordpress.android.analytics.AnalyticsTracker.Stat
-import org.wordpress.android.ui.mysite.items.listitem.ListItemAction
-import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper
-import javax.inject.Inject
-
-class SiteItemsTracker @Inject constructor(
-    private val analyticsTrackerWrapper: AnalyticsTrackerWrapper
-) {
-    enum class Type(val label: String) {
-        POSTS("posts"),
-        STATS("stats")
-    }
-
-    fun trackSiteItemClicked(listItemAction: ListItemAction) = trackSiteItemClicked(listItemAction.toTypeValue())
-
-    private fun trackSiteItemClicked(type: Type?) {
-        type?.let {
-            analyticsTrackerWrapper.track(Stat.MY_SITE_MENU_ITEM_TAPPED, mapOf(TYPE to it.label))
-        }
-    }
-
-    private fun ListItemAction.toTypeValue(): Type? {
-        return when (this) {
-            ListItemAction.POSTS -> Type.POSTS
-            ListItemAction.STATS -> Type.STATS
-            else -> null
-        }
-    }
-
-    companion object {
-        private const val TYPE = "type"
-    }
-}
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/items/listitem/ListItemAction.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/items/listitem/ListItemAction.kt
index 1cf63b3dd10d..b56aa26bc32f 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/items/listitem/ListItemAction.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/items/listitem/ListItemAction.kt
@@ -1,24 +1,24 @@
 package org.wordpress.android.ui.mysite.items.listitem
 
-enum class ListItemAction {
-    ACTIVITY_LOG,
-    BACKUP,
-    SCAN,
-    JETPACK_SETTINGS,
-    PLAN,
-    POSTS,
-    PAGES,
-    ADMIN,
-    PEOPLE,
-    SHARING,
-    DOMAINS,
-    SITE_SETTINGS,
-    THEMES,
-    PLUGINS,
-    STATS,
-    MEDIA,
-    COMMENTS,
-    VIEW_SITE,
-    BLAZE,
-    ME
+enum class ListItemAction (val trackingLabel: String) {
+    ACTIVITY_LOG("activity_log"),
+    BACKUP("backup"),
+    SCAN("scan"),
+    JETPACK_SETTINGS("jetpack_settings"),
+    PLAN("plan"),
+    POSTS("posts"),
+    PAGES("pages"),
+    ADMIN("admin"),
+    PEOPLE("people"),
+    SHARING("sharing"),
+    DOMAINS("domains"),
+    SITE_SETTINGS("site_settings"),
+    THEMES("themes"),
+    PLUGINS("plugins"),
+    STATS("stats"),
+    MEDIA("media"),
+    COMMENTS("comments"),
+    VIEW_SITE("view_site"),
+    BLAZE("blaze"),
+    ME("me"),
 }


Test patch:
diff --git a/WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt
index 55323820a635..9b529e23026a 100644
--- a/WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt
+++ b/WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt
@@ -126,7 +126,6 @@ import org.wordpress.android.ui.mysite.cards.quickstart.QuickStartRepository.Qui
 import org.wordpress.android.ui.mysite.cards.quickstart.QuickStartRepository.QuickStartTabStep
 import org.wordpress.android.ui.mysite.cards.siteinfo.SiteInfoHeaderCardBuilder
 import org.wordpress.android.ui.mysite.items.SiteItemsBuilder
-import org.wordpress.android.ui.mysite.items.SiteItemsTracker
 import org.wordpress.android.ui.mysite.items.listitem.ListItemAction
 import org.wordpress.android.ui.mysite.tabs.MySiteTabType
 import org.wordpress.android.ui.pages.SnackbarMessageHolder
@@ -232,9 +231,6 @@ class MySiteViewModelTest : BaseUnitTest() {
     @Mock
     lateinit var cardsTracker: CardsTracker
 
-    @Mock
-    lateinit var siteItemsTracker: SiteItemsTracker
-
     @Mock
     lateinit var domainRegistrationCardShownTracker: DomainRegistrationCardShownTracker
 
@@ -523,7 +519,6 @@ class MySiteViewModelTest : BaseUnitTest() {
             landOnTheEditorFeatureConfig,
             mySiteSourceManager,
             cardsTracker,
-            siteItemsTracker,
             domainRegistrationCardShownTracker,
             buildConfigWrapper,
             mySiteDashboardTabsFeatureConfig,
@@ -2342,7 +2337,10 @@ class MySiteViewModelTest : BaseUnitTest() {
     fun `when site item is clicked, then event is tracked`() = test {
         invokeItemClickAction(ListItemAction.POSTS)
 
-        verify(siteItemsTracker).trackSiteItemClicked(ListItemAction.POSTS)
+        verify(analyticsTrackerWrapper).track(
+            Stat.MY_SITE_MENU_ITEM_TAPPED,
+            mapOf("type" to ListItemAction.POSTS.trackingLabel)
+        )
     }
 
     @Test
diff --git a/WordPress/src/test/java/org/wordpress/android/ui/mysite/items/SiteItemsTrackerTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/mysite/items/SiteItemsTrackerTest.kt
deleted file mode 100644
index 45611d887247..000000000000
--- a/WordPress/src/test/java/org/wordpress/android/ui/mysite/items/SiteItemsTrackerTest.kt
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.wordpress.android.ui.mysite.items
-
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.mockito.Mock
-import org.mockito.junit.MockitoJUnitRunner
-import org.mockito.kotlin.any
-import org.mockito.kotlin.times
-import org.mockito.kotlin.verify
-import org.wordpress.android.analytics.AnalyticsTracker.Stat
-import org.wordpress.android.ui.mysite.items.SiteItemsTracker.Type
-import org.wordpress.android.ui.mysite.items.listitem.ListItemAction
-import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper
-
-private const val TYPE = "type"
-
-@RunWith(MockitoJUnitRunner::class)
-class SiteItemsTrackerTest {
-    @Mock
-    lateinit var analyticsTracker: AnalyticsTrackerWrapper
-    private lateinit var siteItemsTracker: SiteItemsTracker
-
-    @Before
-    fun setUp() {
-        siteItemsTracker = SiteItemsTracker(analyticsTracker)
-    }
-
-    @Test
-    fun `when site item posts is clicked, then menu item tapped posts is tracked`() {
-        siteItemsTracker.trackSiteItemClicked(ListItemAction.POSTS)
-
-        verifySiteItemClickedTracked(Type.POSTS)
-    }
-
-    @Test
-    fun `when site item stats is clicked, then menu item tapped stats is tracked`() {
-        siteItemsTracker.trackSiteItemClicked(ListItemAction.STATS)
-
-        verifySiteItemClickedTracked(Type.STATS)
-    }
-
-    @Test
-    fun `given not tracking site item, when site item is clicked, then click is not tracked`() {
-        siteItemsTracker.trackSiteItemClicked(ListItemAction.VIEW_SITE)
-
-        verify(analyticsTracker, times(0)).track(any())
-    }
-
-    private fun verifySiteItemClickedTracked(typeValue: Type) {
-        verify(analyticsTracker).track(Stat.MY_SITE_MENU_ITEM_TAPPED, mapOf(TYPE to typeValue.label))
-    }
-}