| 1 |
<?php |
| 2 |
/** |
| 3 |
* Responsible for gathering analytics data for the AntiBot feature. |
| 4 |
* |
| 5 |
* @package WP_Defender\Helper\Analytics |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace WP_Defender\Helper\Analytics; |
| 9 |
|
| 10 |
use WP_Defender\Event; |
| 11 |
use WP_Defender\Traits\Defender_Dashboard_Client; |
| 12 |
use WP_Defender\Component\IP\Antibot_Global_Firewall; |
| 13 |
use WP_Defender\Model\Setting\Antibot_Global_Firewall_Setting; |
| 14 |
|
| 15 |
/** |
| 16 |
* Gather analytics data required for AntiBot feature. |
| 17 |
*/ |
| 18 |
class Antibot extends Event { |
| 19 |
use Defender_Dashboard_Client; |
| 20 |
|
| 21 |
/** |
| 22 |
* Provides data for the frontend. |
| 23 |
* |
| 24 |
* @return array An array of data for the frontend. |
| 25 |
*/ |
| 26 |
public function data_frontend(): array { |
| 27 |
return array(); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Converts the current state of the object to an array. |
| 32 |
* |
| 33 |
* @return array Returns an associative array of object properties. |
| 34 |
*/ |
| 35 |
public function to_array(): array { |
| 36 |
return array(); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Imports data into the model. |
| 41 |
* |
| 42 |
* @param array $data Data to be imported into the model. |
| 43 |
*/ |
| 44 |
public function import_data( array $data ) { |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Removes settings for all submodules. |
| 49 |
*/ |
| 50 |
public function remove_settings() { |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Delete all the data & the cache. |
| 55 |
*/ |
| 56 |
public function remove_data() { |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Exports strings. |
| 61 |
* |
| 62 |
* @return array |
| 63 |
*/ |
| 64 |
public function export_strings() { |
| 65 |
return array(); |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Track feature. |
| 70 |
* |
| 71 |
* @param bool $enabled Feature is enabled or not. |
| 72 |
* @param string $location Options: Feature Page, Dashboard, Onboarding, Hub and Welcome-modal. |
| 73 |
* |
| 74 |
* @return void |
| 75 |
*/ |
| 76 |
public function track_antibot( bool $enabled, string $location ) { |
| 77 |
$event = $enabled ? 'def_antibot_deactivated' : 'def_antibot_activated'; |
| 78 |
$data = array( |
| 79 |
'Triggered From' => $location, |
| 80 |
'State' => 'plugin' === wd_di()->get( Antibot_Global_Firewall::class )->get_managed_by() |
| 81 |
? 'Managed by Defender Plugin' |
| 82 |
: 'Managed by WPMU DEV Hosting', |
| 83 |
'Mode' => wd_di()->get( Antibot_Global_Firewall_Setting::class )->get_mode_label(), |
| 84 |
); |
| 85 |
if ( 'Hub' !== $location ) { |
| 86 |
$data['Connection Method'] = $this->is_dash_activated() |
| 87 |
? 'Dashboard Plugin' |
| 88 |
: 'Hub Connector'; |
| 89 |
} |
| 90 |
|
| 91 |
$this->track_feature( $event, $data ); |
| 92 |
} |
| 93 |
} |
| 94 |
|