Skip to content

Conversation

@staskus
Copy link
Contributor

@staskus staskus commented Jul 29, 2025

Description

More context: pdfdoF-7It-p2
Next PR: #15956

This is the start of the POS modularization work. For now, I'm merging everything into a development branch since things can still change a lot along the way and I don't want to be affecting trunk.

The goal of this PR is to remove one of the larger dependencies between POS and the main app code -Analytics through ServiceLocator. Also, create a platform on which to build further refactorings:

  1. Created PointOfSale and PointOfSaleTests target modules
  2. Defined POSAnalyticsProviding protocol within the PointOfSaleModule
  3. Created POSAnalyticsAdapter within the Woo app code that implements POSAnalyticsProviding to be injected into POS in the entry point
  4. Moved WooAnalyticsStat and WooAnalyticsEvent to WooFoundation to be reused between different modules.
  5. Moved POS-related analytic files to PointOfSale module. I also moved some models and entities that were used within analytics files to avoid changing things too much.
  6. Replaced usage of ServiceLocator.analytics with injected or environment version of POSAnalyticsProviding

Intermediate changes:

  • While refactoring is ongoing, I need to make some PointOfSale module types public to be used within the Woo app, I will turn them back to internal when refactoring is complete
  • For the same reason, I added a global import of PointOfSale to avoid importing it into tens or hundreds of files within the Woo app. In the end, we should only have one import PointOfSale in the entry point (POSTabCoordinator)

Steps to reproduce

Review a general approach. Thorough testing is not necessary since it's not targeting the trunk.

  • CI should succeed
  • POS should launch
  • POS events should be tracked

Testing information

Tested on iPad 18.5 simulator, iPad Air M2 26 device


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

staskus added 12 commits July 28, 2025 09:42
Introduces a new PointOfSale library target to the package, including a basic module interface and version constant. Adds corresponding test target with initial tests for version and initialization.
- Add Experiments and WooFoundation dependencies to PointOfSale module
- Create POSDependencyProviding protocols to abstract ServiceLocator access
- Use string-based analytics tracking to avoid WooAnalyticsEvent dependency
- Enable independent building of PointOfSale module with clean interfaces
- Create POSAnalyticsAdapter()
- Inject through environment to views and through initializer to service classes
- Remove the ServiceLocator.analytics dependency from POS
@staskus staskus added this to the 23.0 milestone Jul 29, 2025
@staskus staskus added type: task An internally driven task. category: architecture Related to architecture such as the database, FluxC, Networking, Core Data, etc. feature: POS labels Jul 29, 2025
@dangermattic
Copy link
Collaborator

dangermattic commented Jul 29, 2025

3 Warnings
⚠️ Modules/Package.swift was changed without updating its corresponding Package.resolved. Please resolve the Swift packages as appropriate to your project setup (e.g. in Xcode or by running swift package resolve).
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
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

@staskus staskus added the category: tracks Related to analytics, including Tracks Events. label Jul 29, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jul 29, 2025

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

App NameWooCommerce iOS Prototype
Build Numberpr15955-418d8a7
Version22.9
Bundle IDcom.automattic.alpha.woocommerce
Commit418d8a7
Installation URL0n4o8bilv09c0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@staskus staskus requested review from iamgabrielma and jaclync July 29, 2025 11:33
Copy link
Contributor

@jaclync jaclync left a comment

Choose a reason for hiding this comment

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

Nice work! Tested making a cash payment in POS and the events were tracked and sent remotely as before. :shipit: Keeping all changes in a development branch makes sense, maybe the dev branch can be merged to trunk by the end of the week / early next week since we might resume POS work after the HACK Week.

@staskus
Copy link
Contributor Author

staskus commented Jul 30, 2025

@jaclync I appreciate the review! 🙇

I know it's complicated to review since there are a lot of changes, and the future PRs make further changes on top of that. I have an idea in my mind of how this should be executed, but I discover new things along the way as I change plans.

I will incorporate your comments in the next PR #15956 that I have.

@staskus staskus merged commit f589dd6 into woomob-935-woo-pos-hack-week-pos-modularization Jul 30, 2025
14 checks passed
@staskus staskus deleted the woomob-935-woo-pos-hack-week-pos-modularization-service-locator-analytics branch July 30, 2025 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: architecture Related to architecture such as the database, FluxC, Networking, Core Data, etc. category: tracks Related to analytics, including Tracks Events. feature: POS type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants