Record plugin api and install failures to coreprofiler_install_plugin_error track (#39899)
* Record plugin api and install failures to coreprofiler_install_plugin_error track * Add changefile(s) from automation for the following project(s): woocommerce * Change to trigger GH jobs --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
6e20ecb3bc
commit
9a75cec842
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: add
|
||||
|
||||
Records plugin API requests and installation errors to coreprofiler_install_plugin_error separately for the core profiler.
|
|
@ -148,6 +148,9 @@ class OnboardingPlugins extends WC_REST_Data_Controller {
|
|||
true
|
||||
);
|
||||
}
|
||||
|
||||
add_action( 'woocommerce_plugins_install_error', array( $this, 'log_plugins_install_error' ), 10, 4 );
|
||||
add_action( 'woocommerce_plugins_install_api_error', array( $this, 'log_plugins_install_api_error' ), 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -411,4 +414,41 @@ class OnboardingPlugins extends WC_REST_Data_Controller {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function log_plugins_install_error( $slug, $api, $result, $upgrader ) {
|
||||
$properties = array(
|
||||
'error_message' => sprintf(
|
||||
/* translators: %s: plugin slug (example: woocommerce-services) */
|
||||
__(
|
||||
'The requested plugin `%s` could not be installed.',
|
||||
'woocommerce'
|
||||
),
|
||||
$slug
|
||||
),
|
||||
'type' => 'plugin_info_api_error',
|
||||
'slug' => $slug,
|
||||
'api_version' => $api->version,
|
||||
'api_download_link' => $api->download_link,
|
||||
'upgrader_skin_message' => implode( ',', $upgrader->skin->get_upgrade_messages() ),
|
||||
'result' => is_wp_error( $result ) ? $result->get_error_message() : 'null',
|
||||
);
|
||||
wc_admin_record_tracks_event( 'coreprofiler_install_plugin_error', $properties );
|
||||
}
|
||||
|
||||
public function log_plugins_install_api_error( $slug, $api ) {
|
||||
$properties = array(
|
||||
'error_message' => sprintf(
|
||||
// translators: %s: plugin slug (example: woocommerce-services).
|
||||
__(
|
||||
'The requested plugin `%s` could not be installed. Plugin API call failed.',
|
||||
'woocommerce'
|
||||
),
|
||||
$slug
|
||||
),
|
||||
'type' => 'plugin_install_error',
|
||||
'api_error_message' => $api->get_error_message(),
|
||||
'slug' => $slug,
|
||||
);
|
||||
wc_admin_record_tracks_event( 'coreprofiler_install_plugin_error', $properties );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue