Skip to content

Conversation

@CGastrell
Copy link
Contributor

@CGastrell CGastrell commented Nov 26, 2025

Proposed changes

This PR adds enhanced logging and a feature flag for the webhook functionality in Jetpack Forms:

  • Add logging for skipped webhooks (invalid format, method, or empty URL)
  • Add jetpack_forms_webhooks_enabled filter flag to control webhook initialization
  • Improve webhook validation by logging specific skip reasons via jetpack_forms_log action
  • Fix method validation to be case-insensitive (convert to uppercase before comparison)

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

No

Testing instructions

  1. Enable webhooks via the filter flag:

    add_filter( 'jetpack_forms_webhooks_enabled', '__return_true' );
  2. Create a form with webhook configuration in the block editor

  3. Test logging for skipped webhooks:

    • Try an empty webhook URL (should log webhook_skipped with reason url_empty)
    • Try an invalid format value (should log webhook_skipped with reason format_invalid)
    • Try an invalid method value (should log webhook_skipped with reason method_invalid)
  4. Verify that without the filter flag enabled, webhooks are not initialized even if configured in the form

  5. Hook into the jetpack_forms_log action to capture the logging:

    add_action( 'jetpack_forms_log', function( $event, $reason, $data = null ) {
        error_log( "Forms Log - Event: $event, Reason: $reason" );
        if ( $data ) {
            error_log( print_r( $data, true ) );
        }
    }, 10, 3 );

@CGastrell CGastrell added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Package] Forms Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR labels Nov 26, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 26, 2025

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 add/form-webhooks-skipped-logging branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/form-webhooks-skipped-logging

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 Nov 26, 2025

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 🤖


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!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: December 2, 2025

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Nov 26, 2025
@jp-launch-control
Copy link

jp-launch-control bot commented Nov 26, 2025

Code Coverage Summary

No summary data is available for parent commit 079abaf, 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 079abaf is available.

Full summary · PHP report · JS report

Coverage check overridden by Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR .

@CGastrell CGastrell added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Nov 26, 2025
@github-actions github-actions bot added [Tests] Includes Tests [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Nov 26, 2025
@CGastrell CGastrell force-pushed the add/form-webhooks-skipped-logging branch from 41f2dea to e94c02d Compare November 26, 2025 18:27
@CGastrell CGastrell added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Nov 26, 2025
@CGastrell CGastrell merged commit 478890b into add/form-response-webhooks Nov 26, 2025
66 of 67 checks passed
@CGastrell CGastrell deleted the add/form-webhooks-skipped-logging branch November 26, 2025 23:06
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Nov 26, 2025
vianasw pushed a commit that referenced this pull request Nov 28, 2025
* add logging for skipped webhooks

* only init webhooks class if webhooks are enabled

* changelog

* add tests for webhooks and contact form flags

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

Labels

Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR [Feature] Contact Form [Package] Forms [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests [Type] Task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants