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:
Diffstat (limited to 'core/Tracker/TrackerCodeGenerator.php')
-rw-r--r--core/Tracker/TrackerCodeGenerator.php45
1 files changed, 44 insertions, 1 deletions
diff --git a/core/Tracker/TrackerCodeGenerator.php b/core/Tracker/TrackerCodeGenerator.php
index 5870f09800..1585186291 100644
--- a/core/Tracker/TrackerCodeGenerator.php
+++ b/core/Tracker/TrackerCodeGenerator.php
@@ -9,6 +9,8 @@
namespace Piwik\Tracker;
use Piwik\Common;
+use Piwik\DbHelper;
+use Piwik\Option;
use Piwik\Piwik;
use Piwik\Plugins\CustomVariables\CustomVariables;
use Piwik\Plugins\SitesManager\API as APISitesManager;
@@ -21,6 +23,17 @@ use Piwik\View;
class TrackerCodeGenerator
{
/**
+ * whether matomo.js|php should be forced over piwik.js|php
+ * @var bool
+ */
+ private $shouldForceMatomoEndpoint = false;
+
+ public function forceMatomoEndpoint()
+ {
+ $this->shouldForceMatomoEndpoint = true;
+ }
+
+ /**
* @param int $idSite
* @param string $piwikUrl http://path/to/piwik/site/
* @param bool $mergeSubdomains
@@ -134,7 +147,9 @@ class TrackerCodeGenerator
'optionsBeforeTrackerUrl' => $optionsBeforeTrackerUrl,
'protocol' => '//',
'loadAsync' => true,
- 'trackNoScript' => $trackNoScript
+ 'trackNoScript' => $trackNoScript,
+ 'matomoJsFilename' => $this->getJsTrackerEndpoint(),
+ 'matomoPhpFilename' => $this->getPhpTrackerEndpoint(),
);
if (SettingsPiwik::isHttpsForced()) {
@@ -191,6 +206,34 @@ class TrackerCodeGenerator
return $jsCode;
}
+ public function getJsTrackerEndpoint()
+ {
+ $name = 'matomo.js';
+ if ($this->shouldPreferPiwikEndpoint()) {
+ $name = 'piwik.js';
+ }
+ return $name;
+ }
+
+ public function getPhpTrackerEndpoint()
+ {
+ $name = 'matomo.php';
+ if ($this->shouldPreferPiwikEndpoint()) {
+ $name = 'piwik.php';
+ }
+ return $name;
+ }
+
+ public function shouldPreferPiwikEndpoint()
+ {
+ if ($this->shouldForceMatomoEndpoint) {
+ return false;
+ }
+
+ // only since 3.7.0 we use the default matomo.js|php... for all other installs we need to keep BC
+ return DbHelper::wasMatomoInstalledBeforeVersion('3.7.0-b1');
+ }
+
private function getJavascriptTagOptions($idSite, $mergeSubdomains, $mergeAliasUrls)
{
try {