Skip to content

Commit

Permalink
Merge pull request #29 from DevDavido/development
Browse files Browse the repository at this point in the history
Bump to v1.1.4
  • Loading branch information
DevDavido committed Nov 5, 2020
2 parents dc7e1a2 + d57354e commit 1635df9
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
- Added: Support for Matomo 4 🎉
- Updated: Bumped the minimum PHP version to 7.2.5 for this new major plugin version, just as Matomo 4 itself

## 1.1.4
- Improved: Exception handling for failed audit due to too many requests response
- Fixed: One performance audit setting has been displayed after disabling audits for the site in settings
- Fixed: Disabled performance audits for site renders dashboard empty

## 1.1.3
- Added: Possibility to set extended audit timeout for each site
- Improved: Minor internal refactoring for site settings
Expand Down
27 changes: 27 additions & 0 deletions Exceptions/AuditFailedTooManyRequestsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

namespace Piwik\Plugins\PerformanceAudit\Exceptions;

require PIWIK_INCLUDE_PATH . '/plugins/PerformanceAudit/vendor/autoload.php';

use Exception;

class AuditFailedTooManyRequestsException extends Exception
{
/**
* AuditFailedTooManyRequestsException constructor.
*
* @param string $url
* @param null|string $output
*/
public function __construct(string $url, $output = null)
{
parent::__construct('Audit of ' . $url . ' failed due to too many requests: ' . $output);
}
}
4 changes: 4 additions & 0 deletions Lighthouse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Piwik\Plugins\PerformanceAudit\Exceptions\AuditFailedException;
use Piwik\Plugins\PerformanceAudit\Exceptions\AuditFailedMethodNotAllowedException;
use Piwik\Plugins\PerformanceAudit\Exceptions\AuditFailedNotFoundException;
use Piwik\Plugins\PerformanceAudit\Exceptions\AuditFailedTooManyRequestsException;
use Piwik\Plugins\PerformanceAudit\Exceptions\DependencyMissingException;
use Piwik\Plugins\PerformanceAudit\Exceptions\DependencyUnexpectedResultException;
use Symfony\Component\Process\Exception\ProcessSignaledException;
Expand Down Expand Up @@ -220,6 +221,7 @@ protected function setAudit($audit, $enable)
* @return void
* @throws AuditFailedAuthoriseRefusedException|AuditFailedNotFoundException
* @throws AuditFailedMethodNotAllowedException|AuditFailedException
* @throws AuditFailedTooManyRequestsException
*/
protected function throwAuditException($url, $errorOutput)
{
Expand All @@ -229,6 +231,8 @@ protected function throwAuditException($url, $errorOutput)
throw new AuditFailedNotFoundException($url, $errorOutput);
} elseif (stristr($errorOutput, 'Status code: 405')) {
throw new AuditFailedMethodNotAllowedException($url, $errorOutput);
} elseif (stristr($errorOutput, 'Status code: 429')) {
throw new AuditFailedTooManyRequestsException($url, $errorOutput);
}

throw new AuditFailedException($url, $errorOutput);
Expand Down
1 change: 1 addition & 0 deletions MeasurableSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ private function makeHasExtendedTimeoutSetting()
return $this->makeSetting('has_extended_timeout', false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = Piwik::translate('PerformanceAudit_Settings_HasExtendedTimeout_Title');
$field->inlineHelp = Piwik::translate('PerformanceAudit_Settings_HasExtendedTimeout_Help');
$field->condition = 'is_enabled';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
});
}
Expand Down
12 changes: 7 additions & 5 deletions Reports/GetPerformanceBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ protected function init()
}

$siteSettings = new MeasurableSettings(Common::getRequestVar('idSite'));
if (!$siteSettings->isAuditEnabled()) {
return;
}
$defaultMetrics = [
new MinSeconds(),
new MedianSeconds(),
Expand Down Expand Up @@ -78,14 +75,19 @@ protected function init()
*/
public function isEnabled()
{
if (!Common::getRequestVar('idSite', false)) {
$idSite = Common::getRequestVar('idSite', false);
if (!$idSite) {
return false;
}
// Disable report if initialised as instance of itself
if ((new ReflectionClass($this))->getShortName() === 'GetPerformanceBase') {
return false;
}
$idSite = Common::getRequestVar('idSite');

$siteSettings = new MeasurableSettings($idSite);
if (!$siteSettings->isAuditEnabled()) {
return false;
}

return Piwik::isUserHasViewAccess($idSite);
}
Expand Down
4 changes: 3 additions & 1 deletion Tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
use Piwik\Plugins\PerformanceAudit\Columns\Metrics\Audit;
use Piwik\Plugins\PerformanceAudit\Exceptions\AuditFailedAuthoriseRefusedException;
use Piwik\Plugins\PerformanceAudit\Exceptions\AuditFailedException;
use Piwik\Plugins\PerformanceAudit\Exceptions\AuditFailedMethodNotAllowedException;
use Piwik\Plugins\PerformanceAudit\Exceptions\AuditFailedNotFoundException;
use Piwik\Plugins\PerformanceAudit\Exceptions\AuditFailedTooManyRequestsException;
use Piwik\Site;
use Piwik\Tracker\Action;
use Piwik\Tracker\Db\DbException;
Expand Down Expand Up @@ -425,7 +427,7 @@ private function performAudits(int $idSite, array $urls, array $emulatedDevices,
->setEmulatedDevice($emulatedDevice)
->audit($url);
$this->runGarbageCollection();
} catch (AuditFailedAuthoriseRefusedException | AuditFailedNotFoundException $exception) {
} catch (AuditFailedAuthoriseRefusedException | AuditFailedNotFoundException | AuditFailedMethodNotAllowedException | AuditFailedTooManyRequestsException $exception) {
$this->logWarning($exception->getMessage());
} catch (AuditFailedException | ProcessTimedOutException | RuntimeException $exception) {
$this->logError($exception->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "PerformanceAudit",
"description": "Daily performance audits of all your sites in Matomo.",
"version": "1.1.3",
"version": "1.1.4",
"theme": false,
"require": {
"php": ">=7.1.3",
Expand Down
Binary file modified screenshots/WebsiteSettings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\AuditFailedException' => $baseDir . '/Exceptions/AuditFailedException.php',
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\AuditFailedMethodNotAllowedException' => $baseDir . '/Exceptions/AuditFailedMethodNotAllowedException.php',
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\AuditFailedNotFoundException' => $baseDir . '/Exceptions/AuditFailedNotFoundException.php',
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\AuditFailedTooManyRequestsException' => $baseDir . '/Exceptions/AuditFailedTooManyRequestsException.php',
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\DependencyMissingException' => $baseDir . '/Exceptions/DependencyMissingException.php',
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\DependencyNpmMisconfigurationException' => $baseDir . '/Exceptions/DependencyNpmMisconfigurationException.php',
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\DependencyOfChromeMissingException' => $baseDir . '/Exceptions/DependencyOfChromeMissingException.php',
Expand Down
1 change: 1 addition & 0 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\AuditFailedException' => __DIR__ . '/../..' . '/Exceptions/AuditFailedException.php',
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\AuditFailedMethodNotAllowedException' => __DIR__ . '/../..' . '/Exceptions/AuditFailedMethodNotAllowedException.php',
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\AuditFailedNotFoundException' => __DIR__ . '/../..' . '/Exceptions/AuditFailedNotFoundException.php',
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\AuditFailedTooManyRequestsException' => __DIR__ . '/../..' . '/Exceptions/AuditFailedTooManyRequestsException.php',
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\DependencyMissingException' => __DIR__ . '/../..' . '/Exceptions/DependencyMissingException.php',
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\DependencyNpmMisconfigurationException' => __DIR__ . '/../..' . '/Exceptions/DependencyNpmMisconfigurationException.php',
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\DependencyOfChromeMissingException' => __DIR__ . '/../..' . '/Exceptions/DependencyOfChromeMissingException.php',
Expand Down

0 comments on commit 1635df9

Please sign in to comment.