Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2022-02-01 12:49:08 +0300
committerGitHub <noreply@github.com>2022-02-01 12:49:08 +0300
commitaa66aca8e0e98267515fe1204f2d47dbb1785e67 (patch)
treeb3293cb03cec5246049b53ff6e60c2c4b2ef7f44
parent4b59d5f56af5eb40e04bed7fdeb795f14d09554c (diff)
Add new event Segment.filterSegments (#18713)
* Add new event Segment.filterSegments For many other `*.add*` events we also have matching `.filter*` events. However, it doesn't seem to be the case for segments. Eg we have this for `Access.Capability.filterCapabilities`, `Dimension.filterDimensions`, `Metric.filterMetrics`, `Report.filterReports`. * Update CHANGELOG.md
-rw-r--r--CHANGELOG.md4
-rw-r--r--core/Segment/SegmentsList.php14
2 files changed, 18 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f3a804c20e..201cf994f4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,10 @@ The Product Changelog at **[matomo.org/changelog](https://matomo.org/changelog)*
* The config setting `enable_default_location_provider` in `Tracker` has been added. By setting this option to 0, you can disable the default location provider. This can be used to prevent the geolocator to guess the country based on the users language, if the configured provider doesn't provide any results.
+#### New PHP events
+
+* Added new event `Segment.filterSegments`. Plugins can use this to filter segment definitions.
+
## Matomo 4.7.0
### Deprecated APIs
diff --git a/core/Segment/SegmentsList.php b/core/Segment/SegmentsList.php
index 82ea86065e..448a4f1593 100644
--- a/core/Segment/SegmentsList.php
+++ b/core/Segment/SegmentsList.php
@@ -132,6 +132,20 @@ class SegmentsList
$dimension->configureSegments($list, new DimensionSegmentFactory($dimension));
}
+ /**
+ * Triggered to filter segment definitions.
+ *
+ * **Example**
+ *
+ * public function filterSegments(&$segmentList)
+ * {
+ * $segmentList->remove('Category');
+ * }
+ *
+ * @param SegmentsList $list An instance of the SegmentsList.
+ */
+ Piwik::postEvent('Segment.filterSegments', array($list));
+
$cache->save($cacheKey, $list);
return $list;