Skip to content

Commit

Permalink
fix(ads): gam api availability according to error type (#2289)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelpeixe authored Feb 27, 2023
1 parent 23caa1d commit 024fe08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion assets/wizards/advertising/views/providers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ const Providers = ( { services, fetchAdvertisingData, toggleService } ) => {
] );
}

if ( google_ad_manager.enabled && ! google_ad_manager.status.connected ) {
if (
google_ad_manager.enabled &&
google_ad_manager.available &&
! google_ad_manager.status.connected
) {
notifications.push(
<Button key="gam-connect-account" isLink onClick={ () => setIsOnboarding( true ) }>
{ __( 'Click here to connect your account.', 'newspack' ) }
Expand Down
9 changes: 7 additions & 2 deletions includes/wizards/class-advertising-wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,14 +436,19 @@ private function get_services() {
$services = array();
foreach ( $this->services as $service => $data ) {
$services[ $service ] = array(
'label' => $data['label'],
'enabled' => $configuration_manager->is_service_enabled( $service ),
'label' => $data['label'],
'enabled' => $configuration_manager->is_service_enabled( $service ),
'available' => true,
);
}

// Verify GAM connection and run initial setup.
$gam_connection_status = $configuration_manager->get_gam_connection_status();
if ( \is_wp_error( $gam_connection_status ) ) {
$error_type = $gam_connection_status->get_error_code();
if ( 'newspack_ads_gam_api_fatal_error' === $error_type ) {
$services['google_ad_manager']['available'] = false;
}
$services['google_ad_manager']['status']['error'] = $gam_connection_status->get_error_message();
} else {
$services['google_ad_manager']['status'] = $gam_connection_status;
Expand Down

0 comments on commit 024fe08

Please sign in to comment.