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
14 changes: 14 additions & 0 deletions facebook-commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ class WC_Facebookcommerce_Integration extends WC_Integration {
/** @var string the scheduled resync offset setting ID */
const SETTING_SCHEDULED_RESYNC_OFFSET = 'scheduled_resync_offset';

/** @var string the "meta diagnosis" setting ID */
const SETTING_ENABLE_META_DIAGNOSIS = 'wc_facebook_enable_meta_diagnosis';

/** @var string the "debug mode" setting ID */
const SETTING_ENABLE_DEBUG_MODE = 'wc_facebook_enable_debug_mode';

Expand Down Expand Up @@ -2741,6 +2744,17 @@ public function is_legacy_feed_file_generation_enabled() {
return 'yes' === get_option( self::OPTION_LEGACY_FEED_FILE_GENERATION_ENABLED, 'yes' );
}

/**
* Determines whether meta diagnosis is enabled.
*
* @return bool
* @since 3.4.4
*
*/
public function is_meta_diagnosis_enabled() {
return (bool) ( 'yes' === get_option( self::SETTING_ENABLE_META_DIAGNOSIS ) );
}

/**
* Determines whether debug mode is enabled.
*
Expand Down
3 changes: 3 additions & 0 deletions includes/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,9 @@ public function log( $facebook_external_merchant_settings_id, $message, $error )
}

public function log_to_meta( $context) {
if(!facebook_for_woocommerce()->get_integration()->is_meta_diagnosis_enabled()) {
return;
}
$request = new API\MetaLog\Request( $context );
$this->set_response_handler( API\MetaLog\Response::class );
return $this->perform_request( $request );
Expand Down
9 changes: 9 additions & 0 deletions includes/Admin/Settings_Screens/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,15 @@ public function get_settings() {
'type' => 'title',
),

array(
'id' => \WC_Facebookcommerce_Integration::SETTING_ENABLE_META_DIAGNOSIS,
'title' => __( 'Enable meta diagnosis', 'facebook-for-woocommerce' ),
'type' => 'checkbox',
'desc' => __( 'Upload plugin events to Meta', 'facebook-for-woocommerce' ),
'desc_tip' => sprintf( __( 'Allow Meta to monitor your logs and help fix issues. Personally identifiable information will not be collected.', 'facebook-for-woocommerce' ) ),
'default' => 'yes',
),

array(
'id' => \WC_Facebookcommerce_Integration::SETTING_ENABLE_DEBUG_MODE,
'title' => __( 'Enable debug mode', 'facebook-for-woocommerce' ),
Expand Down
9 changes: 7 additions & 2 deletions tests/Unit/Admin/Settings/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ public function testGetSettings(): void {
// Check that the settings array has the expected structure
$this->assertArrayHasKey('type', $settings[0]);
$this->assertEquals('title', $settings[0]['type']);

// Check meta diagnosis setting
$debug_setting = $settings[1];
$this->assertEquals('checkbox', $debug_setting['type']);
$this->assertEquals('yes', $debug_setting['default']);

// Check debug mode setting
$debug_setting = $settings[1];
$debug_setting = $settings[2];
$this->assertEquals('checkbox', $debug_setting['type']);
$this->assertEquals('no', $debug_setting['default']);

// Check feed generator setting
$feed_setting = $settings[2];
$feed_setting = $settings[3];
$this->assertEquals('checkbox', $feed_setting['type']);
$this->assertEquals('no', $feed_setting['default']);
}
Expand Down