diff --git a/includes/Checkout.php b/includes/Checkout.php index ad5a9d410..d0e557391 100644 --- a/includes/Checkout.php +++ b/includes/Checkout.php @@ -110,7 +110,7 @@ public function load_checkout_permalink_template( $template ) { ); } } else { - \WC_Facebookcommerce_Utils::logTelemetryToMeta( + \WC_Facebookcommerce_Utils::logToMeta( 'Failed to add product to cart', array( 'flow_name' => 'checkout', diff --git a/includes/Feed/FeedUploadUtils.php b/includes/Feed/FeedUploadUtils.php index 66220e33d..4dd14772f 100644 --- a/includes/Feed/FeedUploadUtils.php +++ b/includes/Feed/FeedUploadUtils.php @@ -81,7 +81,7 @@ public static function get_ratings_and_reviews_data( array $query_args ): array 'product.productIdentifiers.skus' => "['" . implode( "','", $product_skus ) . "']", ); } catch ( \Exception $e ) { - \WC_Facebookcommerce_Utils::logTelemetryToMeta( + \WC_Facebookcommerce_Utils::logToMeta( 'Exception while trying to map product review data for feed', array( 'flow_name' => self::RATINGS_AND_REVIEWS_SYNC_LOGGING_FLOW_NAME, @@ -145,7 +145,7 @@ public static function get_coupons_data( array $query_args ): array { $value_type = self::VALUE_TYPE_FIXED_AMOUNT; $fixed_amount_off = $coupon->get_amount(); // TODO we may want to pass in optional currency code for multinational support } else { - \WC_Facebookcommerce_Utils::logTelemetryToMeta( + \WC_Facebookcommerce_Utils::logToMeta( 'Unknown discount type encountered during feed processing', array( 'promotion_id' => $coupon_post->ID, @@ -238,7 +238,7 @@ public static function get_coupons_data( array $query_args ): array { $coupons_data[] = $data; } catch ( \Exception $e ) { - \WC_Facebookcommerce_Utils::logTelemetryToMeta( + \WC_Facebookcommerce_Utils::logToMeta( 'Exception while trying to get coupon data for feed', array( 'promotion_id' => $coupon_post->ID, diff --git a/includes/Framework/BatchLogHandler.php b/includes/Framework/BatchLogHandler.php index 5f334b0d2..c32aa1e5e 100644 --- a/includes/Framework/BatchLogHandler.php +++ b/includes/Framework/BatchLogHandler.php @@ -29,7 +29,7 @@ class BatchLogHandler extends LogHandlerBase { * @since 3.5.0 */ public function __construct() { - add_action( Heartbeat::EVERY_5_MINUTES, array( $this, 'process_telemetry_logs_batch' ) ); + add_action( Heartbeat::EVERY_5_MINUTES, array( $this, 'process_logs_batch' ) ); } /** @@ -39,9 +39,9 @@ public function __construct() { * * @since 3.5.0 */ - public function process_telemetry_logs_batch() { - if ( get_transient( 'global_telemetry_message_queue' ) !== false && ! empty( get_transient( 'global_telemetry_message_queue' ) ) ) { - $logs = get_transient( 'global_telemetry_message_queue' ); + public function process_logs_batch() { + if ( get_transient( 'global_logging_message_queue' ) !== false && ! empty( get_transient( 'global_logging_message_queue' ) ) ) { + $logs = get_transient( 'global_logging_message_queue' ); $chunked_logs = array_chunk( $logs, 20 ); $chunked_failed_logs = array_map( @@ -54,21 +54,21 @@ function ( $log ) { ); $context = [ - 'event' => 'persist_meta_telemetry_logs', - 'extra_data' => [ 'telemetry_logs' => wp_json_encode( $logs_chunk_with_core_context ) ], + 'event' => 'persist_meta_logs', + 'extra_data' => [ 'meta_logs' => wp_json_encode( $logs_chunk_with_core_context ) ], ]; try { $response = facebook_for_woocommerce()->get_api()->log_to_meta( $context ); if ( $response->success ) { - WC_Facebookcommerce_Utils::logWithDebugModeEnabled( 'Telemetry logs: ' . wp_json_encode( $context ) ); + WC_Facebookcommerce_Utils::logWithDebugModeEnabled( 'Meta logs: ' . wp_json_encode( $context ) ); return []; } else { WC_Facebookcommerce_Utils::logWithDebugModeEnabled( 'Bad response from log_to_meta request' ); return $logs_chunk; } } catch ( \Exception $e ) { - WC_Facebookcommerce_Utils::logWithDebugModeEnabled( 'Error persisting telemetry logs: ' . $e->getMessage() ); + WC_Facebookcommerce_Utils::logWithDebugModeEnabled( 'Error persisting meta logs: ' . $e->getMessage() ); return $logs_chunk; } }, @@ -82,11 +82,11 @@ function ( $log ) { } if ( ! empty( $failed_logs ) ) { - set_transient( 'global_telemetry_message_queue', $failed_logs, HOUR_IN_SECONDS ); + set_transient( 'global_logging_message_queue', $failed_logs, HOUR_IN_SECONDS ); return; } } - set_transient( 'global_telemetry_message_queue', [], HOUR_IN_SECONDS ); + set_transient( 'global_logging_message_queue', [], HOUR_IN_SECONDS ); } } diff --git a/includes/fbutils.php b/includes/fbutils.php index a97ad1068..9a6c5233f 100644 --- a/includes/fbutils.php +++ b/includes/fbutils.php @@ -871,21 +871,21 @@ public static function logExceptionImmediatelyToMeta(Throwable $error, array $co } /** - * Utility function for sending telemetry logs to Meta. + * Utility function for sending logs to Meta. * @since 3.5.0 * * @param string $message * @param array $context wiki: https://www.internalfb.com/wiki/Commerce_Platform/Teams/3P_Ecosystems_(3PE)/3rd_Party_platforms/Woo_Commerce/How_To_Use_WooCommerce_Side_Logging/ */ - public static function logTelemetryToMeta(string $message, array $context = []) { + public static function logToMeta(string $message, array $context = []) { $extra_data = self::getContextData( $context, 'extra_data', [] ); $extra_data['message'] = $message; $context['extra_data'] = $extra_data; // Push logging request to global message queue function. - $logs = get_transient( 'global_telemetry_message_queue' ); + $logs = get_transient( 'global_logging_message_queue' ); $logs[] = $context; - set_transient( 'global_telemetry_message_queue', $logs, HOUR_IN_SECONDS ); + set_transient( 'global_logging_message_queue', $logs, HOUR_IN_SECONDS ); } /**