Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Track event.
- *
- * Track an event with the Bento site tracking API.
- *
- * @since 3.38.16
- *
- * @param string $event The event title.
- * @param bool|string $event_data The event description.
- * @param bool|string $email_address The user email address.
- * @return bool|WP_Error True if success, WP_Error if failed.
- */
- public function track_event( $event, $event_data = false, $email_address = false ) {
- if ( empty( $email_address ) && ! wpf_is_user_logged_in() ) {
- // Tracking only works if WP Fusion knows who the contact is.
- return;
- }
- // Get the email address to track.
- if ( empty( $email_address ) ) {
- $user = wpf_get_current_user();
- $email_address = $user->user_email;
- }
- $site_uuid = wpf_get_option( 'site_uuid' );
- $data['events'][] = array(
- 'email' => $email_address,
- 'type' => $event,
- 'details' => $event_data,
- );
- $request = $this->url . '/batch/events/?site_uuid=' . $site_uuid;
- $params = $this->get_params();
- $params['body'] = wp_json_encode( $data );
- $params['blocking'] = false;
- $response = wp_safe_remote_post( $request, $params );
- if ( is_wp_error( $response ) ) {
- return $response;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement