diff --git a/includes/Core/Tags/First_Party_Mode/First_Party_Mode.php b/includes/Core/Tags/First_Party_Mode/First_Party_Mode.php index aa187795520..85463c7958b 100644 --- a/includes/Core/Tags/First_Party_Mode/First_Party_Mode.php +++ b/includes/Core/Tags/First_Party_Mode/First_Party_Mode.php @@ -11,6 +11,7 @@ namespace Google\Site_Kit\Core\Tags\First_Party_Mode; use Google\Site_Kit\Context; +use Google\Site_Kit\Core\Modules\Module_With_Debug_Fields; use Google\Site_Kit\Core\Storage\Options; use Google\Site_Kit\Core\Util\Method_Proxy_Trait; @@ -21,7 +22,7 @@ * @access private * @ignore */ -class First_Party_Mode { +class First_Party_Mode implements Module_With_Debug_Fields { use Method_Proxy_Trait; /** @@ -72,4 +73,23 @@ public function register() { $this->first_party_mode_settings->register(); $this->rest_controller->register(); } + + /** + * Gets an array of debug field definitions. + * + * @since n.e.x.t + * + * @return array + */ + public function get_debug_fields() { + $settings = $this->first_party_mode_settings->get(); + + return array( + 'first_party_mode_is_enabled' => array( + 'label' => __( 'First-Party Mode: Enabled', 'google-site-kit' ), + 'value' => $settings['isEnabled'] ? __( 'Yes', 'google-site-kit' ) : __( 'No', 'google-site-kit' ), + 'debug' => $settings['isEnabled'] ? 'yes' : 'no', + ), + ); + } } diff --git a/includes/Modules/Ads.php b/includes/Modules/Ads.php index 06c2b0f0a43..2247af589dd 100644 --- a/includes/Modules/Ads.php +++ b/includes/Modules/Ads.php @@ -28,6 +28,7 @@ use Google\Site_Kit\Core\Modules\Tags\Module_Tag_Matchers; use Google\Site_Kit\Core\Permissions\Permissions; use Google\Site_Kit\Core\Site_Health\Debug_Data; +use Google\Site_Kit\Core\Tags\First_Party_Mode\First_Party_Mode; use Google\Site_Kit\Modules\Ads\PAX_Config; use Google\Site_Kit\Modules\Ads\Settings; use Google\Site_Kit\Modules\Ads\Has_Tag_Guard; @@ -307,13 +308,24 @@ public function register_tag() { public function get_debug_fields() { $settings = $this->get_settings()->get(); - return array( + $debug_fields = array( 'ads_conversion_tracking_id' => array( 'label' => __( 'Ads: Conversion Tracking ID', 'google-site-kit' ), 'value' => $settings['conversionID'], 'debug' => Debug_Data::redact_debug_value( $settings['conversionID'] ), ), ); + + // Add fields from First-Party Mode. + // Note: fields are added in both Analytics and Ads so that the debug fields will show if either module is enabled. + if ( Feature_Flags::enabled( 'firstPartyMode' ) ) { + $first_party_mode = new First_Party_Mode( $this->context ); + $fields_from_first_party_mode = $first_party_mode->get_debug_fields(); + + $debug_fields = array_merge( $debug_fields, $fields_from_first_party_mode ); + } + + return $debug_fields; } /** diff --git a/includes/Modules/Analytics_4.php b/includes/Modules/Analytics_4.php index 094ab1e07a4..6d952a3cfc9 100644 --- a/includes/Modules/Analytics_4.php +++ b/includes/Modules/Analytics_4.php @@ -89,6 +89,7 @@ use Google\Site_Kit_Dependencies\Google_Service_TagManager_Container; use Google\Site_Kit_Dependencies\Psr\Http\Message\RequestInterface; use Google\Site_Kit\Core\REST_API\REST_Routes; +use Google\Site_Kit\Core\Tags\First_Party_Mode\First_Party_Mode; use Google\Site_Kit\Modules\Analytics_4\Conversion_Reporting\Conversion_Reporting_Cron; use Google\Site_Kit\Modules\Analytics_4\Conversion_Reporting\Conversion_Reporting_Events_Sync; use Google\Site_Kit\Modules\Analytics_4\Conversion_Reporting\Conversion_Reporting_Provider; @@ -593,6 +594,15 @@ public function get_debug_fields() { ); } + // Add fields from First-Party Mode. + // Note: fields are added in both Analytics and Ads so that the debug fields will show if either module is enabled. + if ( Feature_Flags::enabled( 'firstPartyMode' ) ) { + $first_party_mode = new First_Party_Mode( $this->context ); + $fields_from_first_party_mode = $first_party_mode->get_debug_fields(); + + $debug_fields = array_merge( $debug_fields, $fields_from_first_party_mode ); + } + return $debug_fields; }