[Woo POS][Local Catalog] Beta-fix Add Better Analytics to Background Task Refresh System #16014
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
N.B. – replaces #16011, as we decided to move it to a beta fix
Description
This PR adds detailed analytics tracking to the existing background task refresh system to help us understand
how background syncing works in real-world conditions. This will inform our choices for POS local catalog sync, whether we can use the same App Refresh task or would need a background processing task.
@toupper @jaclync What do you think – 23.1, or put it in the 23.0 beta? I'm happy either way, but have done 23.1 for now.
Also, if you think there's anything else we should try to track, let me know.
Changes
Analytics Updates
System Info Collection
Analytics Properties
Steps to reproduce
- Turn Low Data Mode on/off: Settings → Cellular → Cellular Data Options → Low Data Mode
- Turn Low Power Mode on/off: Settings → Battery → Low Power Mode
- Try different networks: WiFi, Cellular, WiFi hotspot
- Run from Xcode, adding a breakpoint after the task is scheduled (at the end of AppDelegate.applicationDidEnterBackground(_:))
- In Xcode debug console, run this command:
-
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.automattic.woocommerce.refresh"]
- Allow the app to run on
- Look for Tracked background_data_synced in the logs
- Make sure all the properties show up and look correct:
network_type
should show your current connectionis_low_data_mode
should match what you set in Settingsis_low_power_mode
should match what you set in Settingsbattery_level
should show current battery percentageis_powered
should show if you're chargingbackground_time_granted
won't be logged, because the app is essentially in the foreground even when you background it.- WiFi with/without Low Data Mode
- Cellular with/without roaming (if you can)
- Different battery levels and charging states
- Run while app is in background vs foreground
Expected Results
Analytics should show detailed info like:
Testing information
I've tested this on an iPhone running iOS 18, with both simulated and real BGAppRefreshTasks. Screenshot below shows a real task's logged result.
Screenshots
RELEASE-NOTES.txt
if necessary.