diff --git a/projects/plugins/jetpack/_inc/lib/plugins.php b/projects/plugins/jetpack/_inc/lib/plugins.php index 78b3861593665..0bffc5299c10b 100644 --- a/projects/plugins/jetpack/_inc/lib/plugins.php +++ b/projects/plugins/jetpack/_inc/lib/plugins.php @@ -11,6 +11,8 @@ require_once 'class.jetpack-automatic-install-skin.php'; +use Automattic\Jetpack\A8c_Mc_Stats; + /** * Plugins management tools. */ @@ -41,7 +43,6 @@ public static function install_and_activate_plugin( $slug ) { if ( ! current_user_can( 'activate_plugins' ) ) { return new WP_Error( 'not_allowed', __( 'You are not allowed to activate plugins on this site.', 'jetpack' ) ); } - $activated = activate_plugin( $plugin_id ); if ( is_wp_error( $activated ) ) { return $activated; @@ -67,10 +68,12 @@ public static function install_plugin( $slug ) { $skin = new Jetpack_Automatic_Install_Skin(); $upgrader = new Plugin_Upgrader( $skin ); $zip_url = self::generate_wordpress_org_plugin_download_link( $slug ); + $mc_stats = new A8c_Mc_Stats(); $result = $upgrader->install( $zip_url ); if ( is_wp_error( $result ) ) { + $mc_stats->add( 'install-plugin', "fail-$slug" ); return $result; } @@ -92,9 +95,11 @@ public static function install_plugin( $slug ) { $error_code = 'no_package'; } + $mc_stats->add( 'install-plugin', "fail-$slug" ); return new WP_Error( $error_code, $error, 400 ); } + $mc_stats->add( 'install-plugin', "success-$slug" ); return (array) $upgrader->skin->get_upgrade_messages(); } diff --git a/projects/plugins/jetpack/changelog/update-install-plugins-mc-stats b/projects/plugins/jetpack/changelog/update-install-plugins-mc-stats new file mode 100644 index 0000000000000..ac3d7801bd53b --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-install-plugins-mc-stats @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +Bump stat on plugin installs.