From fa57639a16c6a5e332fd71e712352b184a756661 Mon Sep 17 00:00:00 2001 From: Gael Robin <“robin.gael@gmail.com”> Date: Tue, 26 Sep 2023 14:06:29 +0200 Subject: [PATCH 1/3] Closes #6152: Add license type to what is reported to Mixpanel Adds the license type to data sent to Mixpanel. --- inc/Engine/Admin/Settings/Page.php | 20 +---------- inc/admin/admin.php | 5 +++ inc/functions/admin.php | 35 +++++++++++++++++++ .../functions/admin/rocketGetLicenseType.php | 28 +++++++++++++++ .../functions/admin/rocketGetLicenseType.php | 24 +++++++++++++ 5 files changed, 93 insertions(+), 19 deletions(-) create mode 100644 tests/Fixtures/inc/functions/admin/rocketGetLicenseType.php create mode 100644 tests/Unit/inc/functions/admin/rocketGetLicenseType.php diff --git a/inc/Engine/Admin/Settings/Page.php b/inc/Engine/Admin/Settings/Page.php index acabdad83f..8650cdebe6 100644 --- a/inc/Engine/Admin/Settings/Page.php +++ b/inc/Engine/Admin/Settings/Page.php @@ -260,25 +260,7 @@ public function customer_data() { 'is_from_one_dot_com' => false, ]; - if ( - false === $user - || - ! isset( $user->licence_account, $user->licence_expiration ) - ) { - return $data; - } - - if ( - 1 <= $user->licence_account - && - $user->licence_account < 3 - ) { - $data['license_type'] = 'Single'; - } elseif ( -1 === (int) $user->licence_account ) { - $data['license_type'] = 'Infinite'; - } else { - $data['license_type'] = 'Plus'; - } + $data['license_type'] = rocket_get_license_type( $user ); $data['license_class'] = time() < $user->licence_expiration ? 'wpr-isValid' : 'wpr-isInvalid'; $data['license_expiration'] = date_i18n( get_option( 'date_format' ), (int) $user->licence_expiration ); diff --git a/inc/admin/admin.php b/inc/admin/admin.php index 7feb5e536c..22f9162f1a 100644 --- a/inc/admin/admin.php +++ b/inc/admin/admin.php @@ -323,6 +323,11 @@ function rocket_analytics_data() { $data['cdn_cnames'] = 0; } + $customer_data = get_transient( 'wp_rocket_customer_data' ); + if ( false !== $customer_data ) { + $data['license_type'] = rocket_get_license_type( $customer_data ); + } + return $data; } diff --git a/inc/functions/admin.php b/inc/functions/admin.php index f190c1e462..31543dadea 100755 --- a/inc/functions/admin.php +++ b/inc/functions/admin.php @@ -428,6 +428,15 @@ function rocket_data_collection_preview_table() { $html .= ''; $html .= ''; + $html .= '
%s
', $data['license_type'] );
+ $html .= '%s
', $data['web_server'] );
+ $html .= sprintf( '%s', $data['web_server'] );
$html .= '%s
', $data['php_version'] );
+ $html .= sprintf( '%s', $data['php_version'] );
$html .= '%s
', $data['wordpress_version'] );
+ $html .= sprintf( '%s', $data['wordpress_version'] );
$html .= '%s
', $data['multisite'] ? 'true' : 'false' );
+ $html .= sprintf( '%s', $data['multisite'] ? 'true' : 'false' );
$html .= '%s
', $data['current_theme'] );
+ $html .= sprintf( '%s', $data['current_theme'] );
$html .= '%s
', $data['locale'] );
+ $html .= sprintf( '%s', $data['locale'] );
$html .= '%s
', $data['license_type'] );
+ $html .= sprintf( '%s', $data['license_type'] );
$html .= '