woocommerce / woocommerce-ios

WooCommerce iOS app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
312 stars 113 forks source link

[Performance Dashboard Card] Performance Card not showing cached Visitors and Conversion value #14436

Open hafizrahman opened 2 hours ago

hafizrahman commented 2 hours ago

Inside StorePerformanceViewModel.reloadDataIfNeeded(), which handles the data loading, the logic is:

Meanwhile, the viewmodel has the siteVisitStatMode property, which decides whether to show or hide the visit stats:

https://github.com/woocommerce/woocommerce-ios/blob/cac1fca1cb771f750171cfc41800f473085e8f94/WooCommerce/Classes/ViewRelated/Dashboard/StoreStats/StorePerformanceViewModel.swift#L36

This property is checked inside StorePerfomanceView:

https://github.com/woocommerce/woocommerce-ios/blob/cac1fca1cb771f750171cfc41800f473085e8f94/WooCommerce/Classes/ViewRelated/Dashboard/StoreStats/StorePerformanceView.swift#L214-L225

Back in reloadDataIfNeeded(), the value of siteVisitStatMode is only changed after the skip fetching data logic. In other words, it's only updated if remote fetching is being done:

https://github.com/woocommerce/woocommerce-ios/blob/cac1fca1cb771f750171cfc41800f473085e8f94/WooCommerce/Classes/ViewRelated/Dashboard/StoreStats/StorePerformanceViewModel.swift#L179-L188

This created an edge case issue: if the app starts and loads visit data from cache, and the timestamp is fresh enough to skip remote fetching, then the cached data is available but redacted:

This can be replicated by doing so:

  1. Have a demo site with a newly completed Order within this month, so stats can appear
  2. Start app,
  3. Enable Performance card, and set range to This Month.
  4. Wait until data appears properly (Orders, Visitors, and Conversion), then quickly build the app again in Xcode. The rebuild needs to be done as soon as possible after the data appears, so if you're unsure, do pull-to-refresh, wait for data, then rebuild,
  5. This will start the app again. Check how Visitors and Conversions value in Performance card are now redacted.

Expected: Visitors and Conversion values should be shown.

dangermattic commented 2 hours ago

Thanks for reporting! 👍