diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | plugins/Live/Controller.php | 35 |
2 files changed, 34 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index de60a62dd6..227606f039 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The Product Changelog at **[piwik.org/changelog](https://piwik.org/changelog)** ### New APIs * Themes can now customize the header text color using `@theme-color-header-text` * New event `Widgetize.shouldEmbedIframeEmpty` added so plugins can optionally define the output of the widgetized HTML themselves + * New events added to add and filter visitor details: `Live.addProfileSummaries` and `Live.filterProfileSummaries` ## Piwik 3.2.0 diff --git a/plugins/Live/Controller.php b/plugins/Live/Controller.php index de76e6736a..5ad68b809b 100644 --- a/plugins/Live/Controller.php +++ b/plugins/Live/Controller.php @@ -228,11 +228,42 @@ class Controller extends \Piwik\Plugin\Controller if (!$cache->contains($cacheId)) { $instances = []; + /** + * Triggered to add new live profile summaries. + * + * **Example** + * + * public function addProfileSummary(&$profileSummaries) + * { + * $profileSummaries[] = new MyCustomProfileSummary(); + * } + * + * @param ProfileSummaryAbstract[] $profileSummaries An array of profile summaries + */ + Piwik::postEvent('Live.addProfileSummaries', array(&$instances)); + foreach (self::getAllProfileSummaryClasses() as $className) { - $instance = new $className(); - $instances[] = $instance; + $instances[] = new $className(); } + /** + * Triggered to filter / restrict profile summaries. + * + * **Example** + * + * public function filterProfileSummary(&$profileSummaries) + * { + * foreach ($profileSummaries as $index => $profileSummary) { + * if ($profileSummary->getId() === 'myid') {} + * unset($profileSummaries[$index]); // remove all summaries having this ID + * } + * } + * } + * + * @param ProfileSummaryAbstract[] $profileSummaries An array of profile summaries + */ + Piwik::postEvent('Live.filterProfileSummaries', array(&$instances)); + $cache->save($cacheId, $instances); } |