Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
97.37% |
37 / 38 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
| Performance_History | |
97.37% |
37 / 38 |
|
75.00% |
3 / 4 |
4 | |
0.00% |
0 / 1 |
| setup | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| register_data_sync | |
100.00% |
35 / 35 |
|
100.00% |
1 / 1 |
1 | |||
| is_available | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_slug | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Automattic\Jetpack_Boost\Modules\Performance_History; |
| 4 | |
| 5 | use Automattic\Jetpack\Schema\Schema; |
| 6 | use Automattic\Jetpack\WP_JS_Data_Sync\Data_Sync; |
| 7 | use Automattic\Jetpack_Boost\Contracts\Feature; |
| 8 | use Automattic\Jetpack_Boost\Contracts\Has_Data_Sync; |
| 9 | use Automattic\Jetpack_Boost\Contracts\Is_Always_On; |
| 10 | use Automattic\Jetpack_Boost\Data_Sync\Performance_History_Entry; |
| 11 | use Automattic\Jetpack_Boost\Lib\Premium_Features; |
| 12 | |
| 13 | class Performance_History implements Feature, Is_Always_On, Has_Data_Sync { |
| 14 | |
| 15 | public function setup() { |
| 16 | // noop |
| 17 | } |
| 18 | |
| 19 | public function register_data_sync( Data_Sync $instance ) { |
| 20 | $performance_history_schema = Schema::as_assoc_array( |
| 21 | array( |
| 22 | 'periods' => Schema::as_array( |
| 23 | Schema::as_assoc_array( |
| 24 | array( |
| 25 | 'timestamp' => Schema::as_number(), |
| 26 | 'dimensions' => Schema::as_assoc_array( |
| 27 | array( |
| 28 | 'desktop_overall_score' => Schema::as_number(), |
| 29 | 'mobile_overall_score' => Schema::as_number(), |
| 30 | 'desktop_cls' => Schema::as_number(), |
| 31 | 'desktop_lcp' => Schema::as_number(), |
| 32 | 'desktop_tbt' => Schema::as_number(), |
| 33 | 'mobile_cls' => Schema::as_number(), |
| 34 | 'mobile_lcp' => Schema::as_number(), |
| 35 | 'mobile_tbt' => Schema::as_number(), |
| 36 | ) |
| 37 | ), |
| 38 | ) |
| 39 | ) |
| 40 | ), |
| 41 | 'annotations' => Schema::as_array( |
| 42 | Schema::as_assoc_array( |
| 43 | array( |
| 44 | 'timestamp' => Schema::as_number(), |
| 45 | 'text' => Schema::as_string(), |
| 46 | ) |
| 47 | ) |
| 48 | ), |
| 49 | 'startDate' => Schema::as_number(), |
| 50 | 'endDate' => Schema::as_number(), |
| 51 | ) |
| 52 | ); |
| 53 | |
| 54 | $instance->register( 'performance_history_toggle', Schema::as_boolean()->fallback( false ) ); |
| 55 | |
| 56 | $instance->register( 'performance_history', $performance_history_schema, new Performance_History_Entry() ); |
| 57 | } |
| 58 | |
| 59 | public static function is_available() { |
| 60 | return Premium_Features::has_feature( Premium_Features::PERFORMANCE_HISTORY ); |
| 61 | } |
| 62 | |
| 63 | public static function get_slug() { |
| 64 | return 'performance_history'; |
| 65 | } |
| 66 | } |