| 1 |
<?php |
| 2 |
|
| 3 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure. |
| 4 |
namespace Yoast\WP\SEO\Dashboard\Application\Tracking; |
| 5 |
|
| 6 |
use Yoast\WP\SEO\Dashboard\Infrastructure\Tracking\Setup_Steps_Tracking_Repository_Interface; |
| 7 |
|
| 8 |
/** |
| 9 |
* Tracks the setup steps. |
| 10 |
*/ |
| 11 |
class Setup_Steps_Tracking { |
| 12 |
|
| 13 |
/** |
| 14 |
* The setup steps tracking repository. |
| 15 |
* |
| 16 |
* @var Setup_Steps_Tracking_Repository_Interface |
| 17 |
*/ |
| 18 |
private $setup_steps_tracking_repository; |
| 19 |
|
| 20 |
/** |
| 21 |
* Constructs the class. |
| 22 |
* |
| 23 |
* @param Setup_Steps_Tracking_Repository_Interface $setup_steps_tracking_repository The setup steps tracking repository. |
| 24 |
*/ |
| 25 |
public function __construct( Setup_Steps_Tracking_Repository_Interface $setup_steps_tracking_repository ) { |
| 26 |
$this->setup_steps_tracking_repository = $setup_steps_tracking_repository; |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* If the Site Kit setup widget has been loaded. |
| 31 |
* |
| 32 |
* @return string "yes" on "no". |
| 33 |
*/ |
| 34 |
public function get_setup_widget_loaded(): string { |
| 35 |
return $this->setup_steps_tracking_repository->get_setup_steps_tracking_element( 'setup_widget_loaded' ); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Gets the stage of the first interaction. |
| 40 |
* |
| 41 |
* @return string The stage name. |
| 42 |
*/ |
| 43 |
public function get_first_interaction_stage(): string { |
| 44 |
return $this->setup_steps_tracking_repository->get_setup_steps_tracking_element( 'first_interaction_stage' ); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Gets the stage of the last interaction. |
| 49 |
* |
| 50 |
* @return string The stage name. |
| 51 |
*/ |
| 52 |
public function get_last_interaction_stage(): string { |
| 53 |
return $this->setup_steps_tracking_repository->get_setup_steps_tracking_element( 'last_interaction_stage' ); |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* If the setup widget has been temporarily dismissed. |
| 58 |
* |
| 59 |
* @return string "yes" on "no". |
| 60 |
*/ |
| 61 |
public function get_setup_widget_temporarily_dismissed(): string { |
| 62 |
return $this->setup_steps_tracking_repository->get_setup_steps_tracking_element( 'setup_widget_temporarily_dismissed' ); |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* If the setup widget has been permanently dismissed. |
| 67 |
* |
| 68 |
* @return string "yes" on "no". |
| 69 |
*/ |
| 70 |
public function get_setup_widget_permanently_dismissed(): string { |
| 71 |
return $this->setup_steps_tracking_repository->get_setup_steps_tracking_element( 'setup_widget_permanently_dismissed' ); |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Return this object represented by a key value array. |
| 76 |
* |
| 77 |
* @return array<string> The tracking data |
| 78 |
*/ |
| 79 |
public function to_array(): array { |
| 80 |
return [ |
| 81 |
'setupWidgetLoaded' => $this->get_setup_widget_loaded(), |
| 82 |
'firstInteractionStage' => $this->get_first_interaction_stage(), |
| 83 |
'lastInteractionStage' => $this->get_last_interaction_stage(), |
| 84 |
'setupWidgetTemporarilyDismissed' => $this->get_setup_widget_temporarily_dismissed(), |
| 85 |
'setupWidgetPermanentlyDismissed' => $this->get_setup_widget_permanently_dismissed(), |
| 86 |
]; |
| 87 |
} |
| 88 |
} |
| 89 |
|