Skip to content

feat(woocommerce): log error notices#3952

Merged
miguelpeixe merged 3 commits into
trunkfrom
feat/woocommerce-logs
May 7, 2025
Merged

feat(woocommerce): log error notices#3952
miguelpeixe merged 3 commits into
trunkfrom
feat/woocommerce-logs

Conversation

@miguelpeixe

@miguelpeixe miguelpeixe commented Apr 25, 2025

Copy link
Copy Markdown
Member

All Submissions:

Changes proposed in this Pull Request:

Log WooCommerce error notices, which is the primary error handling across Woo features. This includes My Account form validation, cart, and checkout issues. The payload will include the cart contents as wc_cart.

This PR also adds the user referrer and user agent to always be sent as part of the log payload.

How to test the changes in this Pull Request:

  1. Donate or purchase a subscription and use the following card number so it's declined: 4100000000000019
  2. Confirm you were unable to complete the checkout
  3. Confirm a log entry was pushed with the following error_code: newspack_woocommerce_error_notice
  4. Confirm the log entry has the following message: Error: Your card was declined. and the extra property includes the correct agent, referrer, and wc_cart information

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@miguelpeixe miguelpeixe added the [Status] Needs Review The issue or pull request needs to be reviewed label Apr 25, 2025
@miguelpeixe miguelpeixe self-assigned this Apr 25, 2025
@miguelpeixe miguelpeixe requested a review from a team as a code owner April 25, 2025 18:21

@dkoo dkoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is a great idea! While testing this I noticed a handful of logs where message was empty, and I couldn't quite figure out where those were coming from, but I'm not sure it's useful to log in that case. I also think we should be more intentional about the data we attach to the log—cart info might not always be what we're looking for, as the hook can be called if an error notice is added during non-checkout My Account operations as well.

Comment thread includes/reader-revenue/woocommerce/class-woocommerce-logs.php
Comment thread includes/reader-revenue/woocommerce/class-woocommerce-logs.php
@miguelpeixe miguelpeixe requested a review from dkoo May 5, 2025 18:13
@github-actions github-actions Bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels May 7, 2025
@miguelpeixe miguelpeixe merged commit 1654007 into trunk May 7, 2025
10 checks passed
@miguelpeixe miguelpeixe deleted the feat/woocommerce-logs branch May 7, 2025 16:05
@github-actions

github-actions Bot commented May 7, 2025

Copy link
Copy Markdown

Hey @miguelpeixe, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

matticbot pushed a commit that referenced this pull request May 23, 2025
# [6.7.0-alpha.1](v6.6.2...v6.7.0-alpha.1) (2025-05-23)

### Bug Fixes

* **404-images:** use JS without modifying content ([#3963](#3963)) ([9f5646b](9f5646b))
* add missing namespace ([#3980](#3980)) ([6d58793](6d58793))
* **emails:** add missing HTML markup in the change-email-cancel template ([#3981](#3981)) ([040ae30](040ae30))
* **ga4:** fire login/registration activities via SSO ([#3965](#3965)) ([8c97515](8c97515))
* hide modal content gate when modal checkout is opened ([#3953](#3953)) ([a503973](a503973))
* **jetpack:** handle the related posts max age option ([#3964](#3964)) ([8aad2b8](8aad2b8))
* make sure fix duplcate fields apply filters ([#3971](#3971)) ([f361a4e](f361a4e))
* namespace Lite Site ([#3975](#3975)) ([e4665ae](e4665ae))
* sync correction status with parent post status ([#3978](#3978)) ([dcd5a12](dcd5a12))

### Features

* add compatibility to network in custom bylines ([#3972](#3972)) ([199a993](199a993))
* add icons repository and remove custom icons ([#3883](#3883)) ([e56d2e0](e56d2e0))
* **analytics:** "My Account" dashboard interactions ([#3949](#3949)) ([22e9590](22e9590))
* **donations:** update notice style and type ([#3962](#3962)) ([3f60ef3](3f60ef3))
* **email-change:** remove env constant requirement ([#3943](#3943)) ([4158bf1](4158bf1))
* **my-account:** apply Newspack UI styles to My Account w/ env constant ([#3951](#3951)) ([e4aa5a2](e4aa5a2))
* **my-account:** full-site takeover template and custom nav menu ([#3974](#3974)) ([5cf8403](5cf8403))
* **woocommerce:** log error notices ([#3952](#3952)) ([1654007](1654007))
@matticbot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.7.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Jun 2, 2025
# [6.7.0](v6.6.4...v6.7.0) (2025-06-02)

### Bug Fixes

* **404-images:** use JS without modifying content ([#3963](#3963)) ([9f5646b](9f5646b))
* add missing namespace ([#3980](#3980)) ([6d58793](6d58793))
* **emails:** add missing HTML markup in the change-email-cancel template ([#3981](#3981)) ([040ae30](040ae30))
* **ga4:** fire login/registration activities via SSO ([#3965](#3965)) ([8c97515](8c97515))
* hide modal content gate when modal checkout is opened ([#3953](#3953)) ([a503973](a503973))
* **jetpack:** handle the related posts max age option ([#3964](#3964)) ([8aad2b8](8aad2b8))
* make sure fix duplcate fields apply filters ([#3971](#3971)) ([f361a4e](f361a4e))
* namespace Lite Site ([#3975](#3975)) ([e4665ae](e4665ae))
* prevent auto-publishing corrections when scheduling posts ([#4006](#4006)) ([7531832](7531832))
* sync correction status with parent post status ([#3978](#3978)) ([dcd5a12](dcd5a12))

### Features

* add compatibility to network in custom bylines ([#3972](#3972)) ([199a993](199a993))
* add icons repository and remove custom icons ([#3883](#3883)) ([e56d2e0](e56d2e0))
* **analytics:** "My Account" dashboard interactions ([#3949](#3949)) ([22e9590](22e9590))
* **donations:** update notice style and type ([#3962](#3962)) ([3f60ef3](3f60ef3))
* **email-change:** remove env constant requirement ([#3943](#3943)) ([4158bf1](4158bf1))
* **my-account:** apply Newspack UI styles to My Account w/ env constant ([#3951](#3951)) ([e4aa5a2](e4aa5a2))
* **my-account:** full-site takeover template and custom nav menu ([#3974](#3974)) ([5cf8403](5cf8403))
* **woocommerce:** log error notices ([#3952](#3952)) ([1654007](1654007))
@matticbot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.7.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

released on @alpha released [Status] Approved The pull request has been reviewed and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants