Skip to content

Conversation

@itsmeichigo
Copy link
Contributor

@itsmeichigo itsmeichigo commented Sep 12, 2025

Closes WOOMOB-1332

Description

This PR removes the default nil value for selectedSite in AlamofireNetwork. It is now required to explicitly decide if network switching should be supported when the network is created.

Network switching is disabled for the following flows:

  • App widget
  • Notification extension
  • Watch app
  • Jetpack setup
  • App password generation
  • App password deletion

For POS flows, since AlamofireNetwork is created separately and there were no clear disagreement on the network switching in p91TBi-dve-p2, I updated all the services to inject selected site and app password support availability to their networks.

Testing steps

  • For the app, you can follow the test plan in pe5sF9-4Am-p2 if you're interested in testing how the network layer works now.
  • For POS, I need help with confirming that all features work correctly when the requests are made directly with remote sites via application passwords. To confirm this:
    • Log in to a Jetpack site with WPCom credentials.
    • Confirm that the app makes direct requests with the site.
    • Confirm that all POS features work correctly.

Testing information

  • Tested alpha build with iPad and card reader M2 and confirmed that POS features use direct requests and payments are successful.
  • Tested development build with iPhone and confirmed app widget, watch app, Jetpack setup, app password generation and deletion works correctly.

Screenshots

N/A


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

@itsmeichigo itsmeichigo added this to the 23.3 milestone Sep 12, 2025
@itsmeichigo itsmeichigo added type: task An internally driven task. feature: core Core work. See "category: tooling" and "category: architecture" labels Sep 12, 2025
public init(siteID: Int64,
credentials: Credentials?) {
credentials: Credentials?,
selectedSite: AnyPublisher<JetpackSite?, Never>? = nil) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has nil as the default value to avoid updating all related unit tests.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 12, 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 Numberpr16124-9462373
Version23.2
Bundle IDcom.automattic.alpha.woocommerce
Commit9462373
Installation URL22qhveulgmrs0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@itsmeichigo itsmeichigo marked this pull request as ready for review September 12, 2025 10:25
@itsmeichigo itsmeichigo requested a review from a team September 12, 2025 10:25
@iamgabrielma iamgabrielma self-assigned this Sep 16, 2025
@dangermattic
Copy link
Collaborator

dangermattic commented Sep 16, 2025

2 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ This PR is assigned to the milestone 23.3. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@itsmeichigo
Copy link
Contributor Author

itsmeichigo commented Sep 16, 2025

@iamgabrielma I see that you're already reviewing this PR. I just added some changes above to inject app password support availability (from remote feature flag and experimental feature flag) to POS's networks. This PR is ready for a new testing round 🙇

@iamgabrielma
Copy link
Contributor

@iamgabrielma I see that you're already reviewing this PR. I just added some changes above to inject app password support availability (from remote feature flag and experimental feature flag) to POS's networks. This PR is ready for a new testing round 🙇

Great, thanks for the updates!

I tested all POS flows and I see no issues, when logging into the site via a JP-connected account and enabling application passwords in Settings > Experimental features, all requests appear to be done through direct requests rather than tunneled through the JP proxy 👍

Screenshot 2025-09-17 at 12 02 06

Aside from POS, I smoke tested a bit the app and requests for Blaze and some parts of Analytics (analytics reports) do seem to go through a tunneled request and return a 404 for some endpoints. Is this expected? I believe it is since are routes for gifts and bundles, which I do not have on the test site, but just to be sure.

Screenshot 2025-09-17 at 12 15 07

ie:

https://public-api.wordpress.com/rest/v1.1/jetpack-blogs/215063064/rest-api/?json=true&path=/wc-analytics/reports/bundles%26_method%3Dget&query=%7B%22before%22%3A%222025-09-17T23%3A59%3A59%22%2C%22after%22%3A%222025-09-17T00%3A00%3A00%22%2C%22orderby%22%3A%22items_sold%22%2C%22extended_info%22%3A%22true%22%2C%22per_page%22%3A%225%22%2C%22order%22%3A%22desc%22%7D
https://public-api.wordpress.com/rest/v1.1/jetpack-blogs/215063064/rest-api/?json=true&path=/wc-analytics/reports/bundles/stats%26_method%3Dget&query=%7B%22interval%22%3A%22hour%22%2C%22after%22%3A%222025-09-16T00%3A00%3A00%22%2C%22per_page%22%3A%2224%22%2C%22before%22%3A%222025-09-16T12%3A14%3A36%22%2C%22force_cache_refresh%22%3Atrue%7D
https://public-api.wordpress.com/rest/v1.1/jetpack-blogs/215063064/rest-api/?json=true&path=/wc-analytics/reports/giftcards/used/stats%26_method%3Dget&query=%7B%22before%22%3A%222025-09-16T12%3A14%3A36%22%2C%22force_cache_refresh%22%3Atrue%2C%22interval%22%3A%22hour%22%2C%22per_page%22%3A%2224%22%2C%22after%22%3A%222025-09-16T00%3A00%3A00%22%7D
https://public-api.wordpress.com/rest/v1.1/jetpack-blogs/215063064/rest-api/?json=true&path=/wc-analytics/reports/giftcards/used/stats%26_method%3Dget&query=%7B%22after%22%3A%222025-09-17T00%3A00%3A00%22%2C%22interval%22%3A%22hour%22%2C%22force_cache_refresh%22%3Atrue%2C%22before%22%3A%222025-09-17T23%3A59%3A59%22%2C%22per_page%22%3A%2224%22%7D
https://public-api.wordpress.com/rest/v1.1/jetpack-blogs/215063064/rest-api/?json=true&path=/wc-analytics/reports/bundles/stats%26_method%3Dget&query=%7B%22force_cache_refresh%22%3Atrue%2C%22interval%22%3A%22hour%22%2C%22after%22%3A%222025-09-17T00%3A00%3A00%22%2C%22per_page%22%3A%2224%22%2C%22before%22%3A%222025-09-17T23%3A59%3A59%22%7D

@itsmeichigo
Copy link
Contributor Author

Thanks @iamgabrielma for the review!

Aside from POS, I smoke tested a bit the app and requests for Blaze and some parts of Analytics (analytics reports) do seem to go through a tunneled request and return a 404 for some endpoints. Is this expected? I believe it is since are routes for gifts and bundles, which I do not have on the test site, but just to be sure.

Yeah these are expected. Blaze endpoints requires DotCom requests instead of direct requests. Analytics for gifts and bundles analytics fails if you don't have those plugins on your sites, and requests are retried with JP proxy to ensure the failures were not from the direct requests.

I noticed that the app does not switch network requests immediately upon toggling the experimental flag. I added a commit 43e4592 to persist ApplicationPasswordsExperimentState and observe the flag to update the app reactively. Please check again when you have the time 🙏

@iamgabrielma
Copy link
Contributor

Works great, toggling the option switches between tunneled/direct requests at runtime 🚀

@itsmeichigo itsmeichigo merged commit 3b620a9 into trunk Sep 18, 2025
14 checks passed
@itsmeichigo itsmeichigo deleted the woomob-1332-add-support-for-network-switching-in-pos branch September 18, 2025 10:48
@sentry
Copy link

sentry bot commented Sep 25, 2025

Issues attributed to commits in this pull request

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

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

Labels

feature: core Core work. See "category: tooling" and "category: architecture" type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants