1 | <?php |
||
2 | /** |
||
3 | * Webperf plugin for Craft CMS 3.x |
||
4 | * |
||
5 | * Monitor the performance of your webpages through real-world user timing data |
||
6 | * |
||
7 | * @link https://nystudio107.com |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
8 | * @copyright Copyright (c) 2019 nystudio107 |
||
0 ignored issues
–
show
|
|||
9 | */ |
||
0 ignored issues
–
show
|
|||
10 | |||
11 | namespace nystudio107\webperf\models; |
||
12 | |||
13 | use Craft; |
||
0 ignored issues
–
show
The type
Craft was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
14 | use craft\base\Model; |
||
0 ignored issues
–
show
The type
craft\base\Model was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
15 | use craft\validators\ColorValidator; |
||
0 ignored issues
–
show
The type
craft\validators\ColorValidator was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
16 | |||
17 | use putyourlightson\blitz\Blitz; |
||
0 ignored issues
–
show
The type
putyourlightson\blitz\Blitz was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
18 | |||
19 | /** |
||
0 ignored issues
–
show
|
|||
20 | * @author nystudio107 |
||
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
![]() |
|||
21 | * @package Webperf |
||
0 ignored issues
–
show
|
|||
22 | * @since 1.0.0 |
||
0 ignored issues
–
show
|
|||
23 | */ |
||
0 ignored issues
–
show
|
|||
24 | class Settings extends Model |
||
25 | { |
||
26 | // Constants |
||
27 | // ========================================================================= |
||
28 | |||
29 | const BLITZ_PLUGIN_HANDLE = 'blitz'; |
||
30 | |||
31 | // Public Properties |
||
32 | // ========================================================================= |
||
33 | |||
34 | /** |
||
0 ignored issues
–
show
|
|||
35 | * @var string The public-facing name of the plugin |
||
36 | */ |
||
37 | public $pluginName = 'Webperf'; |
||
38 | |||
39 | /** |
||
0 ignored issues
–
show
|
|||
40 | * @var bool Whether or not to include the beacon on the page |
||
41 | */ |
||
42 | public $includeBeacon = true; |
||
43 | |||
44 | /** |
||
0 ignored issues
–
show
|
|||
45 | * @var bool Whether or not to include the Craft profiling of pages |
||
46 | */ |
||
47 | public $includeCraftProfiling = true; |
||
48 | |||
49 | /** |
||
0 ignored issues
–
show
|
|||
50 | * @var bool If the site is static cached, turn this option on to prevent Webperf from generating a unique beacon token |
||
51 | */ |
||
52 | public $staticCachedSite = false; |
||
53 | |||
54 | /** |
||
0 ignored issues
–
show
|
|||
55 | * @var int The number of data samples to store |
||
56 | */ |
||
57 | public $dataSamplesStoredLimit = 100000; |
||
58 | |||
59 | /** |
||
0 ignored issues
–
show
|
|||
60 | * @var bool Whether the DataSamples should be trimmed after each new DataSample is added |
||
61 | */ |
||
62 | public $automaticallyTrimDataSamples = true; |
||
63 | |||
64 | /** |
||
0 ignored issues
–
show
|
|||
65 | * @var bool Whether outlier data samples that are 10x the mean should be deleted |
||
66 | */ |
||
67 | public $trimOutlierDataSamples = true; |
||
68 | |||
69 | /** |
||
0 ignored issues
–
show
|
|||
70 | * @var int The number of milliseconds required between recording of frontend beacon data samples |
||
71 | */ |
||
72 | public $rateLimitMs = 500; |
||
73 | |||
74 | /** |
||
0 ignored issues
–
show
|
|||
75 | * @var string API Key for WebPageTest.org |
||
76 | */ |
||
77 | public $webpageTestApiKey = ''; |
||
78 | |||
79 | /** |
||
0 ignored issues
–
show
|
|||
80 | * @var bool Whether Craft `warning` messages should be recorded in addition to `error` messages |
||
81 | */ |
||
82 | public $includeCraftWarnings = false; |
||
83 | |||
84 | /** |
||
0 ignored issues
–
show
|
|||
85 | * @var int The number of error samples to store |
||
86 | */ |
||
87 | public $errorSamplesStoredLimit = 1000; |
||
88 | |||
89 | /** |
||
0 ignored issues
–
show
|
|||
90 | * @var bool Whether the ErrorSamples should be trimmed after each new ErrorSample is added |
||
91 | */ |
||
92 | public $automaticallyTrimErrorSamples = true; |
||
93 | |||
94 | /** |
||
0 ignored issues
–
show
|
|||
95 | * @var bool Whether to filter bot user agents from generating profile hits or not |
||
96 | * NOT visible in the GUI currently |
||
97 | */ |
||
98 | public $filterBotUserAgents = true; |
||
99 | |||
100 | /** |
||
0 ignored issues
–
show
|
|||
101 | * @var bool Whether the performance summary sidebar should be shown on entry, category, and product pages |
||
102 | */ |
||
103 | public $displaySidebar = true; |
||
104 | |||
105 | /** |
||
0 ignored issues
–
show
|
|||
106 | * @var string The dashboard 'fast' color for charts |
||
107 | */ |
||
108 | public $dashboardFastColor = '#00C800'; |
||
109 | |||
110 | /** |
||
0 ignored issues
–
show
|
|||
111 | * @var string The dashboard 'average' color for charts |
||
112 | */ |
||
113 | public $dashboardAverageColor = '#FFFF00'; |
||
114 | |||
115 | /** |
||
0 ignored issues
–
show
|
|||
116 | * @var string The dashboard 'slow' color for charts |
||
117 | */ |
||
118 | public $dashboardSlowColor = '#C80000'; |
||
119 | |||
120 | // Public Methods |
||
121 | // ========================================================================= |
||
122 | |||
123 | public function init() |
||
0 ignored issues
–
show
|
|||
124 | { |
||
125 | parent::init(); |
||
126 | // If Blitz is installed & enabled, flip the $staticCachedSite on |
||
127 | $blitz = Craft::$app->getPlugins()->getPlugin(self::BLITZ_PLUGIN_HANDLE); |
||
128 | if ($blitz && Blitz::$plugin->getSettings()->cachingEnabled) { |
||
129 | $this->staticCachedSite = true; |
||
130 | } |
||
131 | } |
||
132 | |||
133 | /** |
||
0 ignored issues
–
show
|
|||
134 | * @inheritdoc |
||
135 | */ |
||
0 ignored issues
–
show
|
|||
136 | public function rules() |
||
137 | { |
||
138 | return [ |
||
139 | ['pluginName', 'string'], |
||
140 | ['pluginName', 'default', 'value' => 'Webperf'], |
||
141 | ['includeBeacon', 'boolean'], |
||
142 | ['includeCraftProfiling', 'boolean'], |
||
143 | ['staticCachedSite', 'boolean'], |
||
144 | ['dataSamplesStoredLimit', 'integer'], |
||
145 | ['dataSamplesStoredLimit', 'default', 'value' => 100000], |
||
146 | ['automaticallyTrimDataSamples', 'boolean'], |
||
147 | ['trimOutlierDataSamples', 'boolean'], |
||
148 | ['rateLimitMs', 'integer'], |
||
149 | ['rateLimitMs', 'default', 'value' => 500], |
||
150 | ['webpageTestApiKey', 'string'], |
||
151 | ['includeCraftWarnings', 'boolean'], |
||
152 | ['errorSamplesStoredLimit', 'integer'], |
||
153 | ['errorSamplesStoredLimit', 'default', 'value' => 1000], |
||
154 | ['automaticallyTrimErrorSamples', 'boolean'], |
||
155 | ['filterBotUserAgents', 'boolean'], |
||
156 | ['displaySidebar', 'boolean'], |
||
157 | ['dashboardFastColor', 'default', 'value' => '#00C800'], |
||
158 | ['dashboardAverageColor', 'default', 'value' => '#FFA500'], |
||
159 | ['dashboardSlowColor', 'default', 'value' => '#C80000'], |
||
160 | [ |
||
161 | [ |
||
162 | 'dashboardFastColor', |
||
163 | 'dashboardAverageColor', |
||
164 | 'dashboardSlowColor', |
||
165 | ], |
||
166 | ColorValidator::class |
||
167 | ], |
||
168 | ]; |
||
169 | } |
||
170 | } |
||
171 |