Skip to content

Commit

Permalink
use matomo/matomo-php-tracker instead of piwik/piwik-php-tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Jan 13, 2020
1 parent 8bd9671 commit 0d4030f
Show file tree
Hide file tree
Showing 35 changed files with 122 additions and 134 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
"matomo/referrer-spam-blacklist": "~1.0",
"matomo/searchengine-and-social-list": "~1.0",
"tecnickcom/tcpdf": "~6.0",
"piwik/piwik-php-tracker": "^1.0.0",
"composer/semver": "~1.3.0",
"szymach/c-pchart": "^2.0",
"geoip2/geoip2": "^2.8",
"davaxi/sparkline": "dev-multiple-series",
"matomo-org/jshrink": "1.3.1",
"matomo/network": "~2.0"
"matomo/network": "~2.0",
"matomo/matomo-php-tracker": "~2.0"
},
"require-dev": {
"aws/aws-sdk-php": "2.7.1",
Expand Down
83 changes: 42 additions & 41 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions core/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,7 @@ public static function convertVisitorIdToBin($id)
*/
public static function convertUserIdToVisitorIdBin($userId)
{
require_once PIWIK_INCLUDE_PATH . '/libs/PiwikTracker/PiwikTracker.php';
$userIdHashed = \PiwikTracker::getUserIdHashed($userId);
$userIdHashed = \MatomoTracker::getUserIdHashed($userId);

return self::convertVisitorIdToBin($userIdHashed);
}
Expand Down
2 changes: 1 addition & 1 deletion core/Tracker/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ private function truncateIdAsVisitorId($idVisitor)
}

/**
* Matches implementation of PiwikTracker::getUserIdHashed
* Matches implementation of MatomoTracker::getUserIdHashed
*
* @param $userId
* @return string
Expand Down
2 changes: 1 addition & 1 deletion libs/PiwikTracker/PiwikTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// code, this file has been left as a redirect to its new location in the
// vendor directory.
if (!class_exists('PiwikTracker')) {
require_once __DIR__ . '/../../vendor/piwik/piwik-php-tracker/PiwikTracker.php';
require_once __DIR__ . '/../../vendor/matomo/matomo-php-tracker/PiwikTracker.php';
}

if (PiwikTracker::VERSION !== 1) {
Expand Down
17 changes: 17 additions & 0 deletions misc/others/ExampleMatomoTracker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
// Example file to demonstrate MatomoTracker.php
// See https://matomo.org/docs/tracking-api/
require_once '../../vendor/matomo/matomo-php-tracker/MatomoTracker.php';
MatomoTracker::$URL = 'http://localhost/trunk/';

$matomoTracker = new MatomoTracker($idSite = 1);
// You can manually set the Visitor details (resolution, time, plugins)
// See all other ->set* functions available in the MatomoTracker class
$matomoTracker->setResolution(1600, 1400);

// Sends Tracker request via http
$matomoTracker->doTrackPageView('Document title of current page view');
// You can also track Goal conversions
$matomoTracker->doTrackGoal($idGoal = 1, $revenue = 42);

echo 'done';
17 changes: 0 additions & 17 deletions misc/others/ExamplePiwikTracker.php

This file was deleted.

8 changes: 4 additions & 4 deletions misc/others/tracker_simpleImageTracker.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
// -- Piwik Tracking API init --
require_once "../../libs/PiwikTracker/PiwikTracker.php";
PiwikTracker::$URL = 'http://localhost/matomo-master/';
// -- Matomo Tracking API init --
require_once '../../vendor/matomo/matomo-php-tracker/MatomoTracker.php';
MatomoTracker::$URL = 'http://localhost/matomo-master/';
// Example 1: Tracks a pageview for Website id = {$IDSITE}
$trackingURL = Piwik_getUrlTrackPageView($idSite = 16, $customTitle = 'This title will appear in the report Actions > Page titles');
$trackingURL = Matomo_getUrlTrackPageView($idSite = 16, $customTitle = 'This title will appear in the report Actions > Page titles');

?>
<html>
Expand Down
2 changes: 1 addition & 1 deletion plugins/BulkTracking/tests/System/TrackerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TrackerTest extends SystemTestCase
public static $fixture = null;

/**
* @var \PiwikTracker
* @var \MatomoTracker
*/
private $tracker;

Expand Down
6 changes: 3 additions & 3 deletions plugins/Contents/tests/Fixtures/TwoVisitsWithContents.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Piwik\Date;
use Piwik\Plugins\Goals\API as APIGoals;
use Piwik\Tests\Framework\Fixture;
use PiwikTracker;
use MatomoTracker;

/**
* Tracks contents
Expand Down Expand Up @@ -56,13 +56,13 @@ public function trackVisits()
$this->trackContentImpressionsAndInteractions($vis2);
}

private function moveTimeForward(PiwikTracker $vis, $minutes)
private function moveTimeForward(MatomoTracker $vis, $minutes)
{
$hour = $minutes / 60;
$vis->setForceVisitDateTime(Date::factory($this->dateTime)->addHour($hour)->getDatetime());
}

protected function trackContentImpressionsAndInteractions(PiwikTracker $vis)
protected function trackContentImpressionsAndInteractions(MatomoTracker $vis)
{
$vis->setUrl('http://www.example.org/page');
$vis->setGenerationTime(333);
Expand Down
2 changes: 1 addition & 1 deletion plugins/CoreHome/tests/Integration/Column/UserIdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private function trackPageviewsWithDifferentUsers($userIds)
}
}

private function trackPageview(\PiwikTracker $tracker, $userId, $url = null)
private function trackPageview(\MatomoTracker $tracker, $userId, $url = null)
{
if (null !== $url) {
$tracker->setUrl('http://www.example.org' . $url);
Expand Down
6 changes: 2 additions & 4 deletions plugins/CustomVariables/Archiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
use Piwik\Tracker\GoalManager;
use Piwik\Tracker;

require_once PIWIK_INCLUDE_PATH . '/libs/PiwikTracker/PiwikTracker.php';

class Archiver extends \Piwik\Plugin\Archiver
{
const LABEL_CUSTOM_VALUE_NOT_DEFINED = "Value not defined";
Expand Down Expand Up @@ -109,7 +107,7 @@ protected function aggregateCustomVariable($slot)
// then we also query the "Product page view" price which was possibly recorded.
$additionalSelects = false;

if (in_array($slot, array(\PiwikTracker::CVAR_INDEX_ECOMMERCE_ITEM_SKU, \PiwikTracker::CVAR_INDEX_ECOMMERCE_ITEM_NAME, \PiwikTracker::CVAR_INDEX_ECOMMERCE_ITEM_CATEGORY))) {
if (in_array($slot, array(\MatomoTracker::CVAR_INDEX_ECOMMERCE_ITEM_SKU, \MatomoTracker::CVAR_INDEX_ECOMMERCE_ITEM_NAME, \MatomoTracker::CVAR_INDEX_ECOMMERCE_ITEM_CATEGORY))) {
$additionalSelects = array($this->getSelectAveragePrice());
}
$query = $this->getLogAggregator()->queryActionsByDimension($dimensions, $where, $additionalSelects);
Expand All @@ -121,7 +119,7 @@ protected function aggregateCustomVariable($slot)

protected function getSelectAveragePrice()
{
$field = "custom_var_v" . \PiwikTracker::CVAR_INDEX_ECOMMERCE_ITEM_PRICE;
$field = "custom_var_v" . \MatomoTracker::CVAR_INDEX_ECOMMERCE_ITEM_PRICE;
return LogAggregator::getSqlRevenue("AVG(log_link_visit_action." . $field . ")") . " as `" . Metrics::INDEX_ECOMMERCE_ITEM_PRICE_VIEWED . "`";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private function setUpWebsites()
}
}

private function configureSameDevice(\PiwikTracker $t)
private function configureSameDevice(\MatomoTracker $t)
{
// to make purpose of test more clear we configure the device partially...
$t->setIp('56.11.55.70');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function tearDown()
// empty
}

private function trackVisitSmartphone(\PiwikTracker $t, $dateTime)
private function trackVisitSmartphone(\MatomoTracker $t, $dateTime)
{
$t->setForceVisitDateTime($dateTime);
$t->setUserAgent('Mozilla/5.0 (Linux; U; Android 4.4.2; fr-fr; HTC One_M8 Build/KOT49H) AppleWebKit/537.16 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.16');
Expand Down Expand Up @@ -147,7 +147,7 @@ private function trackVisitSmartphone(\PiwikTracker $t, $dateTime)
self::checkResponse($t->doTrackAction('http://vendor.site', 'link'));
}

private function trackVisitTablet(\PiwikTracker $t, $dateTime)
private function trackVisitTablet(\MatomoTracker $t, $dateTime)
{
$t->setForceVisitDateTime($dateTime);
$t->setUserAgent('Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.8 Safari/535.19 Silk-Accelerated=true');
Expand Down Expand Up @@ -187,7 +187,7 @@ private function trackVisitTablet(\PiwikTracker $t, $dateTime)
$t->doTrackContentImpression('product slider', 'product_16.jpg', 'http://example.org/product16');
}

private function trackVisitMediaPlayer(\PiwikTracker $t, $dateTime)
private function trackVisitMediaPlayer(\MatomoTracker $t, $dateTime)
{
$t->setForceVisitDateTime($dateTime);
$t->setUserAgent('Mozilla/5.0 (iPod; U; CPU iPhone OS 4_2_1 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8C148');
Expand All @@ -213,7 +213,7 @@ private function trackVisitMediaPlayer(\PiwikTracker $t, $dateTime)
self::checkResponse($t->doTrackPageView('Action without url'));
}

private function trackDeviceVisit(\PiwikTracker $t, $dateTime, $useragent)
private function trackDeviceVisit(\MatomoTracker $t, $dateTime, $useragent)
{
$t->setForceVisitDateTime($dateTime);
$t->setUserAgent($useragent);
Expand Down
6 changes: 2 additions & 4 deletions plugins/Monolog/tests/System/TrackerLoggingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@

use Piwik\Config;
use Piwik\Date;
use Piwik\Plugins\Monolog\Handler\EchoHandler;
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\SystemTestCase;
use Piwik\Tests\Framework\TestingEnvironmentVariables;
use PiwikTracker;
use Psr\Container\ContainerInterface;
use MatomoTracker;

/**
* @group Monolog
Expand Down Expand Up @@ -72,7 +70,7 @@ private function buildTracker()
return $t;
}

private function assertTrackerResponseContainsLogOutput(PiwikTracker $t)
private function assertTrackerResponseContainsLogOutput(MatomoTracker $t)
{
$response = $t->doTrackPageView('incredible title!');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class MultipleSitesMultipleVisitsFixture extends Fixture
public $idSite = 1;
public $numVisitsPerIteration = 32;
/**
* @var \PiwikTracker
* @var \MatomoTracker
*/
private $tracker;

Expand Down
2 changes: 2 additions & 0 deletions plugins/SitesManager/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public function setGlobalSettings()

/**
* User will download a file called PiwikTracker.php that is the content of the actual script
*
* @deprecated seems unused and PiwikTracker is now MatomoTracker
*/
function downloadPiwikTracker()
{
Expand Down
2 changes: 0 additions & 2 deletions plugins/TestRunner/Commands/TestsSetupFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ private function createFixture(InputInterface $input, $allowSave)

private function requireFixtureFiles(InputInterface $input)
{
require_once PIWIK_INCLUDE_PATH . '/libs/PiwikTracker/PiwikTracker.php';

$file = $input->getOption('file');
if ($file) {
if (is_file($file)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private function trackPageviewsWithDifferentUsers($userIds)
}
}

private function trackPageview(\PiwikTracker $tracker, $userId, $url)
private function trackPageview(\MatomoTracker $tracker, $userId, $url)
{
$tracker->setUrl('http://www.example.org' . $url);
$tracker->setUserId($userId);
Expand Down
4 changes: 2 additions & 2 deletions tests/LocalTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
require_once PIWIK_INCLUDE_PATH . '/core/Tracker/Visit.php';
require_once PIWIK_INCLUDE_PATH . '/core/Tracker/GoalManager.php';
require_once PIWIK_INCLUDE_PATH . '/core/Tracker/Action.php';
require_once PIWIK_INCLUDE_PATH . '/libs/PiwikTracker/PiwikTracker.php';

/**
* Tracker that uses core/Tracker.php directly.
*/
class Piwik_LocalTracker extends PiwikTracker
class Matomo_LocalTracker extends MatomoTracker
{
protected function sendRequest($url, $method = 'GET', $data = null, $force = false)
{
Expand Down Expand Up @@ -125,3 +124,4 @@ private function parseUrl($url)
}
}

class_alias('Matomo_LocalTracker', 'Piwik_LocalTracker');
Loading

0 comments on commit 0d4030f

Please sign in to comment.