Skip to content
Open
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
80 changes: 62 additions & 18 deletions includes/classes/SupportMonitor/Monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ public function send_daily_report() {
],
[
'key' => 'db_version',
'value' => ( isset( $wpdb->db_version ) ) ? $wpdb->db_version : '',
'value' => $wpdb->db_version() ? $wpdb->db_version() : '',
'group' => 'system',
],
[
Expand All @@ -469,12 +469,14 @@ public function send_daily_report() {
];

$body = [
'url' => TENUP_EXPERIENCE_IS_NETWORK ? network_home_url() : home_url(),
'platform' => 'wordpress',
'packages' => $this->get_packages(),
'activityLogs' => $logs,
'customData' => $custom_data,
'users' => $this->get_users(),
'url' => TENUP_EXPERIENCE_IS_NETWORK ? network_home_url() : home_url(),
'platform' => 'wordpress',
'hostingProvider' => $this->get_hosting_provider(),
'isMultisite' => is_multisite(),
'packages' => $this->get_packages(),
'activityLogs' => $logs,
'customData' => $custom_data,
'users' => $this->get_users(),
];

$this->send_request( $body );
Expand Down Expand Up @@ -706,7 +708,8 @@ public function get_php_version() {
* @return array
*/
public function get_users() {
$users = [];
$users = [];
$users_url = is_multisite() ? network_admin_url( 'users.php' ) : admin_url( 'users.php' );

$args = [
'search' => '*@get10up.com',
Expand All @@ -723,9 +726,10 @@ public function get_users() {

foreach ( $_users as $user ) {
$users[] = [
'email' => $user->user_email,
'name' => $user->display_name,
'role' => array_values( $user->roles ),
'email' => $user->user_email,
'name' => $user->display_name,
'role' => array_values( $user->roles ),
'profileUrl' => add_query_arg( 's', $user->user_email, $users_url ),
];
}

Expand All @@ -744,9 +748,10 @@ public function get_users() {

foreach ( $_users as $user ) {
$users[] = [
'email' => $user->user_email,
'name' => $user->display_name,
'role' => array_values( $user->roles ),
'email' => $user->user_email,
'name' => $user->display_name,
'role' => array_values( $user->roles ),
'profileUrl' => add_query_arg( 's', $user->user_email, $users_url ),
];
}

Expand All @@ -765,15 +770,54 @@ public function get_users() {

foreach ( $_users as $user ) {
$users[] = [
'email' => $user->user_email,
'name' => $user->display_name,
'role' => array_values( $user->roles ),
'email' => $user->user_email,
'name' => $user->display_name,
'role' => array_values( $user->roles ),
'profileUrl' => add_query_arg( 's', $user->user_email, $users_url ),
];
}

return $users;
}

/**
* Detect the hosting provider based on platform-specific PHP constants.
*
* @since 2.2
* @return string Hosting provider slug (e.g. 'vip', 'kinsta') or 'unknown'.
*/
public function get_hosting_provider() {
if ( defined( 'WPCOM_IS_VIP_ENV' ) || defined( 'VIP_GO_APP_ENVIRONMENT' ) ) {
return 'vip';
}

if ( defined( 'KINSTA_DEV_ENV' ) || defined( 'KINSTA_CACHE_ZONE' ) ) {
return 'kinsta';
}

if ( defined( 'WPE_APIKEY' ) || defined( 'IS_WPE' ) ) {
return 'wpengine';
}

if ( defined( 'PANTHEON_ENVIRONMENT' ) ) {
return 'pantheon';
}

if ( defined( 'STARTER_STARTER' ) || defined( 'JEEVES_ENV' ) ) {
return 'pagely';
}

if ( defined( 'FLYWHEEL_CONFIG_DIR' ) ) {
return 'flywheel';
}

if ( defined( 'CLOUDWAYS_SERVER_ID' ) ) {
return 'cloudways';
}

return 'unknown';
}

/**
* Check if the site is using an external object cache.
*
Expand All @@ -785,7 +829,7 @@ public function get_is_using_object_cache() {
}

// If this is a VIP site, we can assume they are using an object cache.
if ( defined( 'VIP_GO_APP_ENVIRONMENT' ) && 'local' !== VIP_GO_APP_ENVIRONMENT ) {
if ( 'vip' === $this->get_hosting_provider() ) {
return true;
}

Expand Down
Loading