Skip to content
Closed
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
10 changes: 8 additions & 2 deletions includes/API/Plugin/Settings/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use WooCommerce\Facebook\API\Plugin\AbstractRESTEndpoint;
use WooCommerce\Facebook\API\Plugin\Settings\Update\Request as UpdateRequest;
use WooCommerce\Facebook\API\Plugin\Settings\Uninstall\Request as UninstallRequest;
use WooCommerce\Facebook\Framework\Logger;

defined( 'ABSPATH' ) || exit;

Expand Down Expand Up @@ -283,12 +284,17 @@ private function maybe_trigger_feed_uploads( bool $should_trigger_products_and_s
if ( facebook_for_woocommerce()->get_integration()->allow_full_batch_api_sync() ) {
facebook_for_woocommerce()->get_products_sync_handler()->create_or_update_all_products();
} else {
\WC_Facebookcommerce_Utils::log_to_meta(
Logger::log(
'Initial full product sync disabled by filter hook `facebook_for_woocommerce_allow_full_batch_api_sync`',
[
'flow_name' => 'product_sync',
'flow_step' => 'initial_sync',
]
],
array(
'should_send_log_to_meta' => true,
'should_save_log_in_woocommerce' => true,
'woocommerce_log_level' => \WC_Log_Levels::DEBUG,
)
);
}
}
Expand Down
34 changes: 26 additions & 8 deletions includes/Feed/FeedUploadUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace WooCommerce\Facebook\Feed;

use WC_Coupon;
use WooCommerce\Facebook\Framework\Logger;

/**
* Class containing util functions related to various feed uploads.
Expand Down Expand Up @@ -88,14 +89,19 @@ public static function get_ratings_and_reviews_data( array $query_args ): array
'product.productIdentifiers.skus' => "['" . implode( "','", $product_skus ) . "']",
);
} catch ( \Exception $e ) {
\WC_Facebookcommerce_Utils::log_to_meta(
Logger::log(
'Exception while trying to map product review data for feed',
array(
'flow_name' => self::RATINGS_AND_REVIEWS_SYNC_LOGGING_FLOW_NAME,
'flow_step' => 'map_ratings_and_reviews_data',
'extra_data' => [
'exception_message' => $e->getMessage(),
],
),
array(
'should_send_log_to_meta' => true,
'should_save_log_in_woocommerce' => true,
'woocommerce_log_level' => \WC_Log_Levels::ERROR,
)
);
continue;
Expand Down Expand Up @@ -152,13 +158,18 @@ 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::log_to_meta(
Logger::log(
'Unknown discount type encountered during feed processing',
array(
'promotion_id' => $coupon_post->ID,
'extra_data' => [ 'discount_type' => $woo_discount_type ],
'flow_name' => self::PROMO_SYNC_LOGGING_FLOW_NAME,
'flow_step' => 'map_discount_type',
),
array(
'should_send_log_to_meta' => true,
'should_save_log_in_woocommerce' => true,
'woocommerce_log_level' => \WC_Log_Levels::WARNING,
)
);
continue;
Expand Down Expand Up @@ -250,7 +261,7 @@ public static function get_coupons_data( array $query_args ): array {

$coupons_data[] = $data;
} catch ( \Exception $e ) {
\WC_Facebookcommerce_Utils::log_to_meta(
Logger::log(
'Exception while trying to get coupon data for feed',
array(
'promotion_id' => $coupon_post->ID,
Expand All @@ -260,6 +271,11 @@ public static function get_coupons_data( array $query_args ): array {
],
'flow_name' => self::PROMO_SYNC_LOGGING_FLOW_NAME,
'flow_step' => 'map_coupon_data',
),
array(
'should_send_log_to_meta' => true,
'should_save_log_in_woocommerce' => true,
'woocommerce_log_level' => \WC_Log_Levels::ERROR,
)
);
continue;
Expand Down Expand Up @@ -354,11 +370,13 @@ private static function get_target_filter(
return '';
}

// Return the JSON representation. It should look something like:
// {"and":[
// {"or":[{"retailer_id":{"eq":"retailer_id_1"}},{"retailer_id":{"eq":"retailer_id_2"}}]},
// {"and":[{"retailer_id":{"neq":"retailer_id_3"}},{"retailer_id":{"neq":"retailer_id_4"}}]}
// ]}
/**
* Return the JSON representation. It should look something like:
* {"and":[
* {"or":[{"retailer_id":{"eq":"retailer_id_1"}},{"retailer_id":{"eq":"retailer_id_2"}}]},
* {"and":[{"retailer_id":{"neq":"retailer_id_3"}},{"retailer_id":{"neq":"retailer_id_4"}}]}
* ]}
*/
return wp_json_encode( $final_filter );
}

Expand Down
8 changes: 7 additions & 1 deletion includes/Feed/ShippingProfiles/ShippingProfilesFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Automattic\WooCommerce\ActionSchedulerJobFramework\Proxies\ActionScheduler;
use WC_Shipping_Zones;
use WooCommerce\Facebook\Framework\Logger;

/**
* Ratings and Reviews Feed class
Expand Down Expand Up @@ -294,7 +295,7 @@ private static function get_flat_rate_shipping_method_data( array $zone, array $
}

private static function log_map_shipping_method_issue_to_meta( array $zone, array $shipping_method, string $message, string $flow_step ): void {
\WC_Facebookcommerce_Utils::log_to_meta(
Logger::log(
$message,
array(
'flow_name' => FeedUploadUtils::SHIPPING_PROFILES_SYNC_LOGGING_FLOW_NAME,
Expand All @@ -304,6 +305,11 @@ private static function log_map_shipping_method_issue_to_meta( array $zone, arra
'zone_name' => $zone['zone_name'],
'method_id' => $shipping_method['instance_id'],
],
),
array(
'should_send_log_to_meta' => true,
'should_save_log_in_woocommerce' => true,
'woocommerce_log_level' => \WC_Log_Levels::DEBUG,
)
);
}
Expand Down
8 changes: 7 additions & 1 deletion includes/Products/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use WooCommerce\Facebook\Framework\Helper;
use WooCommerce\Facebook\Utilities\Heartbeat;
use WooCommerce\Facebook\Framework\Plugin\Exception as PluginException;
use WooCommerce\Facebook\Framework\Logger;

/**
* The main product feed handler.
Expand Down Expand Up @@ -179,11 +180,16 @@ public function schedule_feed_generation() {
} elseif ( ! $store_allows_feed ) {
$message = 'Store does not allow feed.';
}
WC_Facebookcommerce_Utils::log_to_meta(
Logger::log(
sprintf( 'Product feed scheduling failed: %s', $message ),
array(
'flow_name' => 'product_feed',
'flow_step' => 'schedule_feed_generation',
),
array(
'should_send_log_to_meta' => true,
'should_save_log_in_woocommerce' => true,
'woocommerce_log_level' => \WC_Log_Levels::DEBUG,
)
);
return;
Expand Down