|
13 | 13 | use ThemeIsle\HyveLite\Threads;
|
14 | 14 | use ThemeIsle\HyveLite\API;
|
15 | 15 | use ThemeIsle\HyveLite\Qdrant_API;
|
| 16 | +use ThemeIsle\HyveLite\Logger; |
16 | 17 |
|
17 | 18 | /**
|
18 | 19 | * Class Main
|
@@ -57,6 +58,11 @@ public function __construct() {
|
57 | 58 | add_action( 'admin_menu', [ $this, 'register_menu_page' ] );
|
58 | 59 | add_action( 'save_post', [ $this, 'update_meta' ] );
|
59 | 60 | add_action( 'delete_post', [ $this, 'delete_post' ] );
|
| 61 | + add_action( 'hyve_weekly_stats', [ $this, 'log_stats' ] ); |
| 62 | + |
| 63 | + if ( Logger::has_consent() && ! wp_next_scheduled( 'hyve_weekly_stats' ) ) { |
| 64 | + wp_schedule_event( time(), 'weekly', 'hyve_weekly_stats' ); |
| 65 | + } |
60 | 66 |
|
61 | 67 | $settings = self::get_settings();
|
62 | 68 |
|
@@ -156,11 +162,7 @@ public function enqueue_options_assets() {
|
156 | 162 | 'assets' => [
|
157 | 163 | 'images' => HYVE_LITE_URL . 'assets/images/',
|
158 | 164 | ],
|
159 |
| - 'stats' => [ |
160 |
| - 'threads' => Threads::get_thread_count(), |
161 |
| - 'messages' => Threads::get_messages_count(), |
162 |
| - 'totalChunks' => $this->table->get_count(), |
163 |
| - ], |
| 165 | + 'stats' => $this->get_stats(), |
164 | 166 | 'docs' => 'https://docs.themeisle.com/article/2009-hyve-documentation',
|
165 | 167 | 'qdrant_docs' => 'https://docs.themeisle.com/article/2066-integrate-hyve-with-qdrant',
|
166 | 168 | 'pro' => 'https://themeisle.com/plugins/hyve/',
|
@@ -283,6 +285,40 @@ public function enqueue_assets() {
|
283 | 285 | );
|
284 | 286 | }
|
285 | 287 |
|
| 288 | + /** |
| 289 | + * Get stats. |
| 290 | + * |
| 291 | + * @since 1.3.0 |
| 292 | + * |
| 293 | + * @return array |
| 294 | + */ |
| 295 | + public function get_stats() { |
| 296 | + return [ |
| 297 | + 'threads' => Threads::get_thread_count(), |
| 298 | + 'messages' => Threads::get_messages_count(), |
| 299 | + 'totalChunks' => $this->table->get_count(), |
| 300 | + ]; |
| 301 | + } |
| 302 | + |
| 303 | + /** |
| 304 | + * Log stats. |
| 305 | + * |
| 306 | + * @since 1.3.0 |
| 307 | + * |
| 308 | + * @return void |
| 309 | + */ |
| 310 | + public function log_stats() { |
| 311 | + Logger::track( |
| 312 | + [ |
| 313 | + [ |
| 314 | + 'feature' => 'system', |
| 315 | + 'featureComponent' => 'stats', |
| 316 | + 'featureValue' => $this->get_stats(), |
| 317 | + ], |
| 318 | + ] |
| 319 | + ); |
| 320 | + } |
| 321 | + |
286 | 322 | /**
|
287 | 323 | * Update meta.
|
288 | 324 | *
|
|
0 commit comments