Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

The checkout tracking deduplication logic in should_track_checkout() and mark_checkout_tracked() had no test coverage despite being critical for preventing duplicate product_checkout events.

Changes

  • Core deduplication scenarios: Tests for first checkout, duplicate with same cart state, checkout after cart modification, and checkout with different/same JS session IDs
  • Edge cases: Null session handling for both tracking methods
  • Session state verification: Tests that mark_checkout_tracked() correctly stores tracking flag and session ID
  • Test infrastructure: Helper methods set_session_cookie() and clear_session_cookie() to reduce duplication

All tests use reflection to access private methods and integrate with existing WC_Session mock infrastructure.

// Example: Testing session ID change triggers re-tracking
$session->set( Universal::CHECKOUT_TRACKED_KEY, true );
$session->set( Universal::CHECKOUT_SESSION_ID_KEY, 'old-session-id' );
$this->set_session_cookie( 'new-session-id' );

$result = $method->invoke( $universal, $session );
$this->assertTrue( $result ); // Different session ID → should track

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 8, 2026 10:34
Co-authored-by: chihsuan <4344253+chihsuan@users.noreply.github.com>
Co-authored-by: chihsuan <4344253+chihsuan@users.noreply.github.com>
Co-authored-by: chihsuan <4344253+chihsuan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 8, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • downloads.wordpress.org
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/kV3Yas /usr/bin/composer install (dns block)
  • https://api.github.com/repos/Automattic/wordbless/zipball/7db3385da450e6568627894fa1a431d68dea1440
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/kV3Yas /usr/bin/composer install (http block)
  • https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/kV3Yas /usr/bin/composer install (http block)
  • https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/kV3Yas /usr/bin/composer install (http block)
  • https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/kV3Yas /usr/bin/composer install (http block)
  • https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/kV3Yas /usr/bin/composer install (http block)
  • https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/9SOCPJ /usr/bin/composer install (http block)
  • https://api.github.com/repos/roots/wordpress-core-installer/zipball/714d2e2a9e523f6e7bde4810d5a04aedf0ec217f
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/kV3Yas /usr/bin/composer install (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/3e6ccf7657d4f0a59200564b08cead899313b53c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/kV3Yas /usr/bin/composer install (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/9SOCPJ /usr/bin/composer install (http block)
  • https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/9SOCPJ /usr/bin/composer install (http block)
  • https://api.github.com/repos/symfony/process/zipball/2f8e1a6cdf590ca63715da4d3a7a3327404a523f
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/9SOCPJ /usr/bin/composer install (http block)
  • https://api.github.com/repos/symfony/string/zipball/d50e862cb0a0e0886f73ca1f31b865efbb795003
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/9SOCPJ /usr/bin/composer install (http block)
  • https://api.github.com/repos/theseer/tokenizer/zipball/7989e43bf381af0eac72e4f0ca5bcbfa81658be4
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/kV3Yas /usr/bin/composer install (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Address feedback on WooCommerce Analytics product checkout deduplication Add comprehensive tests for checkout deduplication logic Jan 8, 2026
Copilot AI requested a review from chihsuan January 8, 2026 10:39
@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the copilot/sub-pr-46497 branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack copilot/sub-pr-46497

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • 🔴 Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • 🔴 Add testing instructions.
  • 🔴 Specify whether this PR includes any changes to data or privacy.
  • 🔴 Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


🔴 Action required: Please include detailed testing steps, explaining how to test your change, like so:

## Testing instructions:

* Go to '..'
*

🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so:

## Does this pull request change what data or activity we track or use?

My PR adds *x* and *y*.

🔴 Action required: Please add missing changelog entries for the following projects: projects/packages/woocommerce-analytics

Use the Jetpack CLI tool to generate changelog entries by running the following command: jetpack changelog add.
Guidelines: /docs/writing-a-good-changelog-entry.md


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jan 8, 2026
@chihsuan chihsuan marked this pull request as ready for review January 8, 2026 10:44
@chihsuan chihsuan merged commit c6915cd into fix/deduplicate-product-checkout-event Jan 8, 2026
48 of 52 checks passed
@chihsuan chihsuan deleted the copilot/sub-pr-46497 branch January 8, 2026 10:45
@github-actions github-actions bot removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Jan 8, 2026
@jp-launch-control
Copy link

Code Coverage Summary

No summary data is available for parent commit 4ee5151, so cannot calculate coverage changes. 😴

If that commit is a feature branch rather than a trunk commit, this is expected. Otherwise, this should be updated once coverage for 4ee5151 is available.

Full summary · PHP report · JS report

chihsuan added a commit that referenced this pull request Jan 9, 2026
* Initial plan

* Add comprehensive tests for checkout deduplication logic

Co-authored-by: chihsuan <4344253+chihsuan@users.noreply.github.com>

* Refactor cookie setup into helper methods to reduce duplication

Co-authored-by: chihsuan <4344253+chihsuan@users.noreply.github.com>

* Address code review feedback: improve test patterns

Co-authored-by: chihsuan <4344253+chihsuan@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: chihsuan <4344253+chihsuan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants