From 6a1965b615bd8159ec4ebdd816939801013da7e0 Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Fri, 9 Oct 2015 14:37:44 +0700 Subject: [PATCH] Add number of MailChimp lists to tracked data. --- includes/admin/class-usage-tracking.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/includes/admin/class-usage-tracking.php b/includes/admin/class-usage-tracking.php index c7a25a01..69c2762e 100644 --- a/includes/admin/class-usage-tracking.php +++ b/includes/admin/class-usage-tracking.php @@ -75,8 +75,10 @@ public function track() { protected function get_tracking_data() { $data = array( - 'site' => home_url(), + // use md5 hash of home_url, we don't need/want to know the actual site url + 'site' => md5( home_url() ), 'options' => $this->get_tracked_options(), + 'number_of_mailchimp_lists' => $this->get_mailchimp_lists_count(), 'mc4wp_version' => MC4WP_LITE_VERSION, 'plugins' => (array) get_option( 'active_plugins', array() ), 'php_version' => PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, @@ -87,6 +89,15 @@ protected function get_tracking_data() { return $data; } + /** + * @return int + */ + protected function get_mailchimp_lists_count() { + $mailchimp = new MC4WP_MailChimp(); + $lists = $mailchimp->get_lists( false, true ); + return count( $lists ); + } + /** * @return array */ @@ -94,7 +105,9 @@ public function get_tracked_options( ) { $checkbox_options = mc4wp_get_options( 'checkbox' ); $form_options = mc4wp_get_options( 'form' ); - $ignored_options = array( 'api_key', 'license_key' ); + + // make sure these keys are always stripped + $ignored_options = array( 'api_key', 'license_key', 'lists' ); // filter options $checkbox_options = array_diff_key( $checkbox_options, array_flip( $ignored_options ) );