Skip to content

Conversation

@toupper
Copy link
Contributor

@toupper toupper commented Jun 20, 2025

Description

With this PR we add analytics support for the first iteration of the POS as a Tab project, as well as fix the callback logic for the tab bar that was broken through #14183

Broken callback logic

With WooPosTabController, we had overridden the entire BottomNavigation listener, which caused some methods in MainActivity.kt not to be called as expected. To fix this, I removed the listener override from WooPosTabController and now invoke that logic directly from MainActivity.kt's onNavItemSelected.

To support this change, I also made a slight adjustment to the logic in MainBottomNavigationView to handle the POS mode activation, which doesn't follow the same pattern as the other tabs. See the in-code comment for details.

Since this logic was tightly coupled with analytics, I decided to include the fix in the analytics PR—otherwise, analytics wouldn't function correctly. I hope that's okay.

Steps to reproduce

Prerequisite: a WPCOM account that has at least two connected stores, one eligible for POS and the other one not eligible.

  • Log in to the account in the prerequisite with the store that is eligible for POS --> after the POS tab is shown, an event should be tracked 🔵 Tracked: woocommerceandroid_pos_tab_visibility_checked, Properties: {"is_visible":"true"...]
  • Tap on the POS tab --> it should launch POS in full-screen with an event tracked 🔵 Tracked: woocommerceandroid_main_tab_pos_selected.
  • Exit POS
  • Go to Menu tab and switch to a store ineligible for POS --> after switching stores, the POS tab should not appear even after a while. An event should be tracked 🔵 Tracked pos_tab_visibility_checked, properties: [is_visible: false, ...]

Testing information

I also verified that the rest of the main bottom navigation logic continues to work as expected.

  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

@toupper toupper marked this pull request as draft June 20, 2025 10:17
@dangermattic
Copy link
Collaborator

dangermattic commented Jun 20, 2025

1 Warning
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.
1 Message
📖

This PR contains changes to Tracks-related logic. Please ensure (author and reviewer) the following are completed:

  • The tracks events must be validated in the Tracks system.
  • Verify the internal Tracks spreadsheet has also been updated.
  • Please consider registering any new events.
  • The PR must be assigned the category: tracks label.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jun 20, 2025

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit10aff47
Direct Downloadwoocommerce-wear-prototype-build-pr14225-10aff47.apk

@toupper toupper changed the title Issue/woomob 572 pos as a tab analytics [POS as a Tab] Analytics Jun 20, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jun 20, 2025

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit10aff47
Direct Downloadwoocommerce-prototype-build-pr14225-10aff47.apk

ORDERS -> AnalyticsEvent.MAIN_TAB_ORDERS_RESELECTED
PRODUCTS -> AnalyticsEvent.MAIN_TAB_PRODUCTS_RESELECTED
MORE -> AnalyticsEvent.MAIN_TAB_HUB_MENU_RESELECTED
else -> null
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The POS tab cannot be reselected.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 I'd consider explicitly listing POS instead of relying on else.
If someone introduces a new BottomNavigationPosition, they might forget to update this when, however, if the when doesn't have else statement, the compiler will inform them about their mistake.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Done in 10aff47


override fun onNavigationItemSelected(item: MenuItem): Boolean {
navController?.let { navController ->
val navSuccess = NavigationUI.onNavDestinationSelected(item, navController)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary to call listener.onNavItemSelected only when onNavDestinationSelected is successful. The listener's name suggests that it's triggered when an item is selected, regardless of whether navigation occurred. We need to adjust this for the POS tab, where navigation follows a custom flow and doesn't succeed through the usual mechanism.

@toupper toupper added the category: tracks Related to analytics, including Tracks Events. label Jun 20, 2025
@toupper toupper added this to the 22.7 milestone Jun 20, 2025
@toupper toupper added the status: do not merge Dependent on another PR, ready for review but not ready for merge. label Jun 20, 2025
@toupper toupper requested a review from malinajirka June 20, 2025 11:27
Base automatically changed from issue/WOOMOB-620-cache-POS-tab-value to trunk June 20, 2025 11:33
@toupper toupper removed the status: do not merge Dependent on another PR, ready for review but not ready for merge. label Jun 20, 2025
@toupper toupper marked this pull request as ready for review June 20, 2025 12:40
@codecov-commenter
Copy link

codecov-commenter commented Jun 20, 2025

Codecov Report

Attention: Patch coverage is 6.25000% with 15 lines in your changes missing coverage. Please review.

Project coverage is 37.76%. Comparing base (1275211) to head (10aff47).
Report is 48 commits behind head on trunk.

Files with missing lines Patch % Lines
...d/ui/woopos/util/analytics/WooPosAnalyticsEvent.kt 0.00% 7 Missing ⚠️
...merce/android/ui/woopos/tab/WooPosTabController.kt 0.00% 6 Missing ⚠️
...mmerce/android/ui/main/BottomNavigationPosition.kt 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##              trunk   #14225   +/-   ##
=========================================
  Coverage     37.75%   37.76%           
- Complexity     8954     8955    +1     
=========================================
  Files          1962     1962           
  Lines        109594   109594           
  Branches      14366    14364    -2     
=========================================
+ Hits          41382    41384    +2     
+ Misses        64455    64454    -1     
+ Partials       3757     3756    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@malinajirka malinajirka self-assigned this Jun 23, 2025
Copy link
Contributor

@malinajirka malinajirka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @toupper! The changes look good to me.

I've noticed the event is tracked even on phones (with is_visible=false). I assume that is expected and desired, but just noting it to be sure.

🚢

ORDERS -> AnalyticsEvent.MAIN_TAB_ORDERS_RESELECTED
PRODUCTS -> AnalyticsEvent.MAIN_TAB_PRODUCTS_RESELECTED
MORE -> AnalyticsEvent.MAIN_TAB_HUB_MENU_RESELECTED
else -> null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 I'd consider explicitly listing POS instead of relying on else.
If someone introduces a new BottomNavigationPosition, they might forget to update this when, however, if the when doesn't have else statement, the compiler will inform them about their mistake.

@toupper toupper enabled auto-merge June 23, 2025 10:47
@toupper toupper merged commit 6dfbab0 into trunk Jun 23, 2025
17 checks passed
@toupper toupper deleted the issue/WOOMOB-572-pos-as-a-tab-analytics branch June 23, 2025 11:08
@sentry
Copy link

sentry bot commented Jun 25, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: tracks Related to analytics, including Tracks Events.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants