woocommerce / woocommerce-android

WooCommerce Android app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
277 stars 135 forks source link

Track errors when failing to load suggestions in Blaze campaign creation #12888

Closed JorgeMucientes closed 1 week ago

JorgeMucientes commented 2 weeks ago

Closes: #12878

Description

This PR adds tracking to errors when fetching suggestion for a Blaze ad.

Steps to reproduce

To reproduce the error where fetching suggestions fail to load, you have to create a scenario where Jetpack sync issues happen. I followed the next steps to create a Jetpack Sync issues:

  1. Create jurassic ninja site with WooCommerce and Jetapack
  2. Connect Jetpack
  3. dd a few products (I used smooth generator)
  4. Disconnect Jetpack from your account. Jetpack > My Jetpack > scroll down and click Manage > Disconnect Jetpack
  5. Add some more products to your site (remember which are the new products you are adding in this step)
  6. Connect Jetpack again to the same account you connected it before
  7. Attempt to create a Blaze campaign for one of the products you added in step 5
  8. Loading the suggestions will fail with the following error:
    {"message":"Unexpected Server Error","errorMessage":"Request failed with status code 404","stack":["AxiosError: Request failed with status code 404","    at settle (\/app\/dsp\/node_modules\/axios\/lib\/core\/settle.js:19:12)","    at BrotliDecompress.handleStreamEnd (\/app\/dsp\/node_modules\/axios\/lib\/adapters\/http.js:585:11)","    at BrotliDecompress.emit (node:events:529:35)","    at endReadableNT (node:internal\/streams\/readable:1400:12)","    at processTicksAndRejections (node:internal\/process\/task_queues:82:21)"]}

If you can't reproduce this error or don't want to follow these steps ping me and I'll invite you to https://traditional-sable-finfoot.jurassic.ninja/ which is already experiencing the Jetpack sync issue.

Testing information

  1. Follow the steps above
  2. Attempt to create a Blaze campaign for a product that is not synced (step 5 products)
  3. When suggestions fail to load check logcat to verify the following event is tracked:
    🔵 Tracked: blaze_suggestions_loading_failed, Properties: {"error":"Unexpected Server Error",

The tests that have been performed

The above

https://github.com/user-attachments/assets/8e1c0324-475c-44e5-9d61-ad31d1663563

This is an internal tracking change no need to add anything to release notes.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

dangermattic commented 2 weeks ago
1 Warning
:warning: This PR is assigned to the milestone 21.2. 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.
1 Message
:book:

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 :no_entry_sign: Danger

wpmobilebot commented 2 weeks ago
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit626eaa93239d02b48d9cfd2cbb9432538728d5dc
Direct Downloadwoocommerce-wear-prototype-build-pr12888-626eaa9.apk
wpmobilebot commented 2 weeks ago

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

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit626eaa93239d02b48d9cfd2cbb9432538728d5dc
Direct Downloadwoocommerce-prototype-build-pr12888-626eaa9.apk
codecov-commenter commented 1 week ago

Codecov Report

Attention: Patch coverage is 47.05882% with 9 lines in your changes missing coverage. Please review.

Project coverage is 40.22%. Comparing base (fc0c7e6) to head (626eaa9). Report is 165 commits behind head on trunk.

Files with missing lines Patch % Lines
...n/preview/BlazeCampaignCreationPreviewViewModel.kt 46.66% 5 Missing and 3 partials :warning:
...om/woocommerce/android/ui/blaze/BlazeRepository.kt 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## trunk #12888 +/- ## ========================================= Coverage 40.21% 40.22% Complexity 5788 5788 ========================================= Files 1251 1251 Lines 71261 71270 +9 Branches 9955 9955 ========================================= + Hits 28660 28665 +5 - Misses 39966 39970 +4 Partials 2635 2635 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

JorgeMucientes commented 1 week ago

Hey @irfano great questions! Thanks for bringing those up.

Do you know why I can't see woocommerceandroid_blaze_suggestions_loading_failed in the Tracks Live View or Events?

Hmm, that's interesting. Afaik the live view should show the tracked events even if the app is DEBUG build. I did notice that the live view takes around 5-10 mins to display the events tracked. Did you wait that long? Although when I looked for woocommerceandroid_blaze_suggestions_loading_failed in the events section, there are no results showing there, which is weird since the events we fired for testing should show there. I wonder if the event is only is_debug: true it doesn't show up in the events panel? But I think that'd be really strange because I checked other events and is showing results for both debug and production builds.

The auto-message suggested that “The tracks events must be validated in the Tracks system.” Should we validate all newly added events?

I think we should. Good reminder. I tried starting the event validation process, but since there aren't any tracked instances of it I don't think I can complete it. I'll look into this to figure out why woocommerceandroid_blaze_suggestions_loading_failed is not showing up on tracks

irfano commented 6 days ago

Did you wait that long?

Yes, I did. Thank you for investigating this further. For further discussion: p1731584513235259-slack-C03L1NF1EA3