Skip to content

Conversation

@jaclync
Copy link
Contributor

@jaclync jaclync commented Jul 31, 2025

For WOOMOB-943
Just one review is required.

  • @jaclync registers events after approval

Description

This PR adds analytics tracking for address map picker interactions in the order details edit flow. Two new events are tracked to understand merchant engagement with the map-based address picker feature:

  • order_detail_edit_address_map_picker_tapped with locale property - Triggered when merchants tap the CTA to open the address map picker
  • order_detail_edit_address_map_picker_use_address_tapped - Triggered when merchants select an address from the map picker

Additionally, this PR includes the following changes to enable for release:

  • Unit tests with local search mocking
  • Enable feature flag

Steps to reproduce

  1. Navigate to an order details screen with at least one non-virtual product
  2. Tap "Add Shipping Address" or the pencil CTA on the shipping address row
  3. Tap the "Find on Map" to open the address map picker → order_detail_edit_address_map_picker_tapped event should be tracked with a locale property
  4. Search for and select a new address on the map
  5. Tap "Use This Address" → order_detail_edit_address_map_picker_use_address_tapped event should be tracked

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

@dangermattic
Copy link
Collaborator

dangermattic commented Jul 31, 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 Jul 31, 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 Numberpr15964-85c27c5
Version22.9
Bundle IDcom.automattic.alpha.woocommerce
Commit85c27c5
Installation URL66sj38toq0cu8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@jaclync jaclync added feature: order details Related to order details. category: tracks Related to analytics, including Tracks Events. labels Jul 31, 2025
@jaclync jaclync added this to the 23.0 milestone Jul 31, 2025
@jaclync jaclync changed the title Track analytics events for address map picker interactions [HACK Week] Address map search in order details: analytics, enable feature flag, unit tests Jul 31, 2025
@jaclync jaclync requested review from iamgabrielma and staskus July 31, 2025 07:38
@iamgabrielma iamgabrielma self-assigned this Jul 31, 2025
Copy link
Contributor

@iamgabrielma iamgabrielma left a comment

Choose a reason for hiding this comment

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

Works well!

I saw a warning in the console when tapping the map button, from a quick research seems to be coming from mapkit rendering and performance, but I did not see any crash nor freezes during testing:

Tracking a LayerData with no associated Registry: Assertion with expression - layerDataSets.keys.exiting.empty() : Failed in file - /Library/Caches/com.apple.xbs/Sources/VectorKit/src/RegistryManager.mm line - 475

updatedFields.city = "Original City"

// When
sut.updateFields(&updatedFields)
Copy link
Contributor

Choose a reason for hiding this comment

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

Passing the reference here caught my eye, is there a reason for the implementation to accept an inout and modify the reference rather than returning a copy? ( func updateFields(_ fields: AddressFormFields) -> AddressFormFields ). Then the tests would look something like:

// Given
fieldsToUpdate.city = "Original City"

// When
let updatedFields = sut.updateFields(fieldsToUpdate)

// Then
#expect(updatedFields.city == "Original City")

Copy link
Contributor Author

@jaclync jaclync Aug 5, 2025

Choose a reason for hiding this comment

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

I used inout here for direct mutation without copying the struct, which works well with SwiftUI's @Binding binding patterns. If using the functional approach (creating a new struct and updating the existing), because the map picker only updates a subset of address properties, other fields like names/email/phone need to be preserved manually with caution. Lemme know what you think!

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, thanks! The scenario where we only have to update the subset of properties while preserving the rest definitely makes for a good use case of mutating the object directly to avoid errors.

}

@available(iOS 17, *)
@Test func updateFields_with_unknown_country_sets_country_and_state_strings() async {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I found this test name tricky to understand at first (same with the one below), as the country is known as per the mock address, and we're testing the selected fields. Perhaps adding/updating something like unmatched_countryByCode or when_country_not_found_in_countryByCode bits would clarify it

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, the test names could use some improvements as you suggested. Updated in 18f3811

@jaclync
Copy link
Contributor Author

jaclync commented Aug 4, 2025

I saw a warning in the console when tapping the map button, from a quick research seems to be coming from mapkit rendering and performance, but I did not see any crash nor freezes during testing:

Tracking a LayerData with no associated Registry: Assertion with expression - layerDataSets.keys.exiting.empty() : Failed in file - /Library/Caches/com.apple.xbs/Sources/VectorKit/src/RegistryManager.mm line - 475

Thanks for testing and noticing this, which device type and iOS version did you see this warning? I tested 2 simulators and a device (all iOS 18) and didn't see this warning. I was wondering if it's specific to iOS 17.

@iamgabrielma
Copy link
Contributor

Thanks for testing and noticing this, which device type and iOS version did you see this warning? I tested 2 simulators and a device (all iOS 18) and didn't see this warning. I was wondering if it's specific to iOS 17.

It could be the iOS version indeed, my physical device is iPhone 14 running 17.7.1. I'm not positive I saw this error on the 18+ simulator 👍

@jaclync
Copy link
Contributor Author

jaclync commented Aug 5, 2025

It could be the iOS version indeed, my physical device is iPhone 14 running 17.7.1. I'm not positive I saw this error on the 18+ simulator 👍

I tried with an iOS 17.4 iPad simulator and saw a bunch of CoreUI warnings from launching the app 😅 I didn't see the warning/error you shared though. As the amount of iOS 17 users is decreasing, I think we can keep an eye out for merchant feedback and performance stats in Xcode to see if it becomes an issue. If so, I can bump the minimum iOS version to iOS 18.

@jaclync jaclync merged commit fe2f5ac into trunk Aug 5, 2025
14 checks passed
@jaclync jaclync deleted the hack/WOOMOB-943-address-map-picker-analytics branch August 5, 2025 07:11
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. feature: order details Related to order details.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants