Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launchpad: verifying email sends appropriate launchpad track event #41624

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

verify_email task sends appropriate tracks event
Original file line number Diff line number Diff line change
Expand Up @@ -946,20 +946,21 @@ function wpcom_launchpad_is_woocommerce_task_completed( $task, $is_complete ) {
/**
* Record completion event in Tracks if we're running on WP.com.
*
* @param string $task_id The task ID.
* @param array $extra_props Optional extra arguments to pass to the Tracks event.
* @param string $task_id The task ID.
* @param array $extra_props Optional extra arguments to pass to the Tracks event.
* @param WP_User|null $user Optional user to use instead of the current user.
*
* @return void
*/
function wpcom_launchpad_track_completed_task( $task_id, $extra_props = array() ) {
function wpcom_launchpad_track_completed_task( $task_id, $extra_props = array(), $user = null ) {
if ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) {
return;
}

require_lib( 'tracks/client' );

tracks_record_event(
wp_get_current_user(),
$user ?? wp_get_current_user(),
'wpcom_launchpad_mark_task_complete',
array_merge(
array( 'task_id' => $task_id ),
Expand Down Expand Up @@ -1887,6 +1888,20 @@ function wpcom_launchpad_is_email_verified() {
return ! Email_Verification::is_email_unverified();
}

/**
* Handles WPCOM action fired when email verification is completed.
*
* @param int $user_id The user ID.
*/
function wpcom_launchpad_mark_verify_email_complete( $user_id ) {
$user = get_user_by( 'id', $user_id );
if ( empty( $user ) ) {
return;
}
wpcom_launchpad_track_completed_task( 'verify_email', array(), $user );
}
add_action( 'wpcom_email_verification_complete', 'wpcom_launchpad_mark_verify_email_complete' );

/**
* If the site has a paid-subscriber goal.
*
Expand Down
Loading