diff --git a/plugins/CustomPiwikJs/TrackerUpdater.php b/plugins/CustomPiwikJs/TrackerUpdater.php index d90d8c166dbdd5f0112b64a450cf730ee9caf5b6..a6fadbda4792109999285febcbde046fd036083e 100644 --- a/plugins/CustomPiwikJs/TrackerUpdater.php +++ b/plugins/CustomPiwikJs/TrackerUpdater.php @@ -12,7 +12,10 @@ use Piwik\Plugins\CustomPiwikJs\TrackingCode\PiwikJsManipulator; use Piwik\Plugins\CustomPiwikJs\TrackingCode\PluginTrackerFiles; /** - * Updates the Javascript file containing the Tracker. + * Updates the Piwik JavaScript Tracker "piwik.js" in case plugins extend the tracker. + * + * Usage: + * StaticContainer::get('Piwik\Plugins\CustomPiwikJs\TrackerUpdater')->update(); */ class TrackerUpdater { @@ -56,6 +59,12 @@ class TrackerUpdater $this->trackerFiles = $trackerFiles; } + /** + * Checks whether the Piwik JavaScript tracker file "piwik.js" is writable. + * @throws \Exception In case the piwik.js file is not writable. + * + * @api + */ public function checkWillSucceed() { $this->fromFile->checkReadable(); @@ -75,6 +84,15 @@ class TrackerUpdater return $newContent; } + /** + * Updates / re-generates the Piwik JavaScript tracker "piwik.js". + * + * It may not be possible to update the "piwik.js" tracker file if the file is not writable. It won't throw + * an exception in such a case and instead just to nothing. To check if the update would succeed, call + * {@link checkWillSucceed()}. + * + * @api + */ public function update() { if (!$this->toFile->hasWriteAccess() || !$this->fromFile->hasReadAccess()) {