diff --git a/modules/contact-form/grunion-contact-form.php b/modules/contact-form/grunion-contact-form.php index c60af31e2e679..968e06150d3ce 100644 --- a/modules/contact-form/grunion-contact-form.php +++ b/modules/contact-form/grunion-contact-form.php @@ -26,7 +26,11 @@ function grunion_contact_form_require_endpoint() { require_once GRUNION_PLUGIN_DIR . 'class-grunion-contact-form-endpoint.php'; } -require_once GRUNION_PLUGIN_DIR . 'tracks-events.php'; +if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { + require_once GRUNION_PLUGIN_DIR . 'tracks-events-wpcom.php'; +} else { + require_once GRUNION_PLUGIN_DIR . 'tracks-events.php'; +} /** * Sets up various actions, filters, post types, post statuses, shortcodes. diff --git a/modules/contact-form/tracks-events-wpcom.php b/modules/contact-form/tracks-events-wpcom.php new file mode 100644 index 0000000000000..4a6a4e6de6cc2 --- /dev/null +++ b/modules/contact-form/tracks-events-wpcom.php @@ -0,0 +1,33 @@ + esc_url( $all_values['entry_permalink'] ), + 'feedback_id' => absint( $all_values['feedback_id'] ), + ) + ); + } +} + +add_action( 'grunion_pre_message_sent', 'jetpack_wpcom_tracks_record_grunion_pre_message_sent', 12, 3 ); diff --git a/modules/contact-form/tracks-events.php b/modules/contact-form/tracks-events.php index 3f167edb50052..8902b3260a4cc 100644 --- a/modules/contact-form/tracks-events.php +++ b/modules/contact-form/tracks-events.php @@ -2,6 +2,8 @@ /** * Jetpack_Contact_Form: Add tracking for submitting contact form blocks * + * This file is specific to Jetpack's Tracks implementation + * * @package Jetpack * @since ? */ @@ -16,22 +18,15 @@ * @param array $all_values - fields from the default contact form. * @param array $extra_values - extra fields added to from the contact form. - * @return null + * @return null|void */ function jetpack_tracks_record_grunion_pre_message_sent( $post_id, $all_values, $extra_values ) { $status = new Automattic\Jetpack\Status(); - if ( $status->is_development_mode() ) { return false; } if ( isset( $extra_values['is_block'] ) && $extra_values['is_block'] ) { - if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { - require_lib( 'tracks/client' ); - tracks_record_event( $current_user, 'simple_payments_button_' . $event_action, $event_properties ); - return; - } - $tracking = new Automattic\Jetpack\Tracking(); $tracking->tracks_record_event( wp_get_current_user(),