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
path: root/core
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2022-06-30 12:58:26 +0300
committerGitHub <noreply@github.com>2022-06-30 12:58:26 +0300
commit92896ae6d1814d8d084238e554c84836cfbb1b98 (patch)
treecefe9f6003e1b591cef2d5647a69b577daa2ee12 /core
parentd563063fe39b3275f7dba9a3bd194f3b8b44a056 (diff)
Provide possibility to configure referrer exclusion list (#19302)
* Adds database column to store referrer exclusion * Adds global setting for referrer exclusion * Adds measurable setting to configure excluded referrers * adjust SitesManager tests * Implement referrer exclusion * Make referrer exclusion code easier to understand * fix tests * Adds validation for referrer exclusion * fix test * Implement referrer exclusion in tracker js * rebuilt tracker js * Adds some javascript tests * ensure setIgnoredReferrers is executed before tracking * adjust wording to excluded referrers (instead of ignored) * ignore www subdomain in javascript * Included excluded referrer in tracking code generator * Don't require protocol for excluded referrers and add better description * built vue files * update expected test files * updates expected UI files * add changelog * removes unused variable * Allow wildcard subdomains * updates expected test files * apply review feedback * Fix typo Co-authored-by: sgiehl <sgiehl@users.noreply.github.com> Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com>
Diffstat (limited to 'core')
-rw-r--r--core/Db/Schema/Mysql.php1
-rw-r--r--core/Settings/Measurable/MeasurableProperty.php2
-rw-r--r--core/Settings/Storage/Backend/SitesTable.php5
-rw-r--r--core/Tracker/TrackerCodeGenerator.php18
-rw-r--r--core/Updates/4.12.0-b1.php49
-rw-r--r--core/Version.php2
6 files changed, 69 insertions, 8 deletions
diff --git a/core/Db/Schema/Mysql.php b/core/Db/Schema/Mysql.php
index 00fb8c31e9..71bd54f39e 100644
--- a/core/Db/Schema/Mysql.php
+++ b/core/Db/Schema/Mysql.php
@@ -105,6 +105,7 @@ class Mysql implements SchemaInterface
excluded_ips TEXT NOT NULL,
excluded_parameters TEXT NOT NULL,
excluded_user_agents TEXT NOT NULL,
+ excluded_referrers TEXT NOT NULL,
`group` VARCHAR(250) NOT NULL,
`type` VARCHAR(255) NOT NULL,
keep_url_fragment TINYINT NOT NULL DEFAULT 0,
diff --git a/core/Settings/Measurable/MeasurableProperty.php b/core/Settings/Measurable/MeasurableProperty.php
index a1c9fa5534..415bd6e73c 100644
--- a/core/Settings/Measurable/MeasurableProperty.php
+++ b/core/Settings/Measurable/MeasurableProperty.php
@@ -31,7 +31,7 @@ class MeasurableProperty extends \Piwik\Settings\Setting
private $allowedNames = array(
'ecommerce', 'sitesearch', 'sitesearch_keyword_parameters',
- 'sitesearch_category_parameters',
+ 'sitesearch_category_parameters', 'excluded_referrers',
'exclude_unknown_urls', 'excluded_ips', 'excluded_parameters',
'excluded_user_agents', 'keep_url_fragment', 'urls', 'group'
);
diff --git a/core/Settings/Storage/Backend/SitesTable.php b/core/Settings/Storage/Backend/SitesTable.php
index c81f42fcc2..ccfc494311 100644
--- a/core/Settings/Storage/Backend/SitesTable.php
+++ b/core/Settings/Storage/Backend/SitesTable.php
@@ -28,14 +28,15 @@ class SitesTable implements BackendInterface
'sitesearch_category_parameters',
'excluded_user_agents',
'excluded_parameters',
- 'excluded_ips'
+ 'excluded_ips',
+ 'excluded_referrers'
);
// these fields are standard fields of a site and cannot be adjusted via a setting
private $allowedNames = array(
'ecommerce', 'sitesearch', 'sitesearch_keyword_parameters',
'sitesearch_category_parameters', 'exclude_unknown_urls',
- 'excluded_ips', 'excluded_parameters',
+ 'excluded_ips', 'excluded_parameters', 'excluded_referrers',
'excluded_user_agents', 'keep_url_fragment', 'urls'
);
diff --git a/core/Tracker/TrackerCodeGenerator.php b/core/Tracker/TrackerCodeGenerator.php
index 6bfba7894d..f6989f305c 100644
--- a/core/Tracker/TrackerCodeGenerator.php
+++ b/core/Tracker/TrackerCodeGenerator.php
@@ -48,6 +48,7 @@ class TrackerCodeGenerator
* @param bool $trackNoScript
* @param bool $crossDomain
* @param bool $excludedQueryParams
+ * @param array $excludedReferrers
* @return string Javascript code.
*/
public function generate(
@@ -64,7 +65,8 @@ class TrackerCodeGenerator
$disableCookies = false,
$trackNoScript = false,
$crossDomain = false,
- $excludedQueryParams = false
+ $excludedQueryParams = false,
+ $excludedReferrers = []
) {
// changes made to this code should be mirrored in plugins/CoreAdminHome/javascripts/jsTrackingGenerator.js var generateJsCode
@@ -144,11 +146,19 @@ class TrackerCodeGenerator
// Add any excluded query parameters to the tracker options
if ($excludedQueryParams) {
-
if (!is_array($excludedQueryParams)) {
- $excludedQueryParams = explode(',',$excludedQueryParams);
+ $excludedQueryParams = explode(',', $excludedQueryParams);
}
- $options .= ' _paq.push(["setExcludedQueryParams", '.json_encode($excludedQueryParams).']);'."\n";
+ $options .= ' _paq.push(["setExcludedQueryParams", ' . json_encode($excludedQueryParams) . ']);' . "\n";
+ }
+
+ // Add any ignored referrer to the tracker options
+ if ($excludedReferrers) {
+ if (!is_array($excludedReferrers)) {
+ $excludedReferrers = explode(',', $excludedReferrers);
+ }
+
+ $options .= ' _paq.push(["setExcludedReferrers", ' . json_encode($excludedReferrers) . ']);' . "\n";
}
if ($disableCookies) {
diff --git a/core/Updates/4.12.0-b1.php b/core/Updates/4.12.0-b1.php
new file mode 100644
index 0000000000..aa4059de67
--- /dev/null
+++ b/core/Updates/4.12.0-b1.php
@@ -0,0 +1,49 @@
+<?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\Updates;
+
+use Piwik\Updater;
+use Piwik\Updates as PiwikUpdates;
+use Piwik\Updater\Migration;
+use Piwik\Updater\Migration\Factory as MigrationFactory;
+
+/**
+ * Update for version 4.12.0-b1
+ */
+class Updates_4_12_0_b1 extends PiwikUpdates
+{
+ /**
+ * @var MigrationFactory
+ */
+ private $migration;
+
+ public function __construct(MigrationFactory $factory)
+ {
+ $this->migration = $factory;
+ }
+
+ /**
+ * @param Updater $updater
+ *
+ * @return Migration[]
+ */
+ public function getMigrations(Updater $updater)
+ {
+ return [
+ $this->migration->db->addColumn('site', 'excluded_referrers', 'TEXT NOT NULL', 'excluded_user_agents')
+ ];
+ }
+
+ public function doUpdate(Updater $updater)
+ {
+ $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
+ }
+}
diff --git a/core/Version.php b/core/Version.php
index b4a96877dd..9a5e30e677 100644
--- a/core/Version.php
+++ b/core/Version.php
@@ -21,7 +21,7 @@ final class Version
* The current Matomo version.
* @var string
*/
- const VERSION = '4.11.0-rc1';
+ const VERSION = '4.12.0-b1';
const MAJOR_VERSION = 4;