WC_Tracker::record_send_failure │ private static │ WC 1.0

Record a failed delivery attempt.

The attempt was already counted before the snapshot was built, so this only decides whether to keep retrying: a non-retryable failure or the last allowed attempt gives up on the current snapshot. Retry state is discarded when tracking was turned off while the request was in flight.

Method of the class: WC_Tracker{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = WC_Tracker::record_send_failure( $retryable, $status, $error_code, $body_bytes ): void;
$retryable(true|false) (required)
Whether the next scheduled run should try again.
$status(int) (required)
HTTP status code, 0 when no response was received.
$error_code(string) (required)
Error code when no response was received.
$body_bytes(int) (required)
Size of the snapshot.

WC_Tracker::record_send_failure() code WC 11.3.0

private static function record_send_failure( $retryable, $status, $error_code, $body_bytes ): void {
	// The attempt was already counted before the snapshot was built.
	$failures = (int) get_option( 'woocommerce_tracker_send_failures', 0 );
	$give_up  = ! $retryable || self::MAX_CONSECUTIVE_SEND_FAILURES <= $failures;

	if ( $give_up ) {
		self::finish_snapshot();
	} elseif ( true !== wc_string_to_bool( get_option( 'woocommerce_allow_tracking', 'no' ) ) ) {
		delete_option( 'woocommerce_tracker_send_failures' );
	}

	if ( 413 === $status ) {
		$message = 'WooCommerce tracker snapshot delivery failed; the snapshot is too large for the service and will not be retried.';
	} elseif ( 'json_encode_failure' === $error_code ) {
		$message = 'WooCommerce tracker snapshot could not be encoded and will not be retried.';
	} elseif ( $give_up ) {
		$message = 'WooCommerce tracker snapshot delivery failed; giving up until the next interval.';
	} else {
		$message = 'WooCommerce tracker snapshot delivery failed; it will be retried on the next run.';
	}

	wc_get_logger()->warning(
		$message,
		array(
			'source'      => 'woocommerce-tracker',
			'http_status' => $status,
			'error_code'  => $error_code,
			'failures'    => $failures,
			'body_bytes'  => $body_bytes,
		)
	);
}