Skip to content

Commit

Permalink
Renames CustomPiwikJs plugin to CustomJsTracker (matomo-org#15505)
Browse files Browse the repository at this point in the history
* Renames CustomPiwikJs plugin to CustomTrackerJs

* adds bc for old api class name

* adds update to rename plugin in exisiting config

* update ui tests

* rename again

* remove old events

* improve changelog

* remove bc fallback

* Improve migration

* use tagmanager submodule

* updates UI files
  • Loading branch information
sgiehl authored Feb 11, 2020
1 parent 4f2292b commit ab1e700
Show file tree
Hide file tree
Showing 74 changed files with 289 additions and 611 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The Product Changelog at **[matomo.org/changelog](https://matomo.org/changelog)*
* The deprecated Platform API method `\Piwik\Updates::getMigrationQueries()` has been removed. Use `\Piwik\Updates::getMigrations()` instead
* The deprecated Platform API method `\Piwik\Updates::executeMigrationQueries()` has been removed. Use `\Piwik\Updates::executeMigrations()` instead
* The deprecated Platform API method `\Piwik\Updates::update()` has been removed. Use `\Piwik\Updates::doUpdate()` instead
* Matomo no longer polyills the `JSON` object in the JavaScript tracker. This means IE7 and older, Firefox 3 and older will be no longer suppported in the tracker.
* Matomo no longer polyfills the `JSON` object in the JavaScript tracker. This means IE7 and older, Firefox 3 and older will be no longer suppported in the tracker.
* The deprecated Platform API method `\Piwik\Common::json_encode()` has been removed. Use `json_encode()` instead
* The deprecated Platform API method `\Piwik\Common::json_decode()` has been removed. Use `json_decode()` instead
* The deprecated Platform API method `\Piwik\Common::getContinentsList()` has been removed. Use `\Piwik\Intl\Data\Provider\RegionDataProvider::getContinentList()` instead
Expand All @@ -32,6 +32,11 @@ The Product Changelog at **[matomo.org/changelog](https://matomo.org/changelog)*
* The deprecated Platform API class `\Piwik\DeviceDetectorFactory` has been removed. Use `\Piwik\DeviceDetector\DeviceDetectorFactory` instead
* The JavaScript tracker now uses `sendBeacon` by default if supported by the browser. You can disable this by calling the tracker method `disableAlwaysUseSendBeacon`. As a result, callback parameters won't work anymore and a tracking request might not appear in the developer tools.
* The console option `--piwik-domain` has been removed. Use `--matomo-domain` instead
* The core plugin `CustomPiwikJs` has been renamed to `CustomJsTracker`
* The event `CustomPiwikJs.piwikJsChanged` has been renamed to `CustomJsTracker.trackerJsChanged`
* The event `CustomPiwikJs.shouldAddTrackerFile` has been renamed to `CustomJsTracker.shouldAddTrackerFile`
* Public API class `Piwik\Plugins\CustomPiwikJs\TrackerUpdater` has been renamed to `Piwik\Plugins\CustomJsTracker\TrackerUpdater`
* API method `CustomPiwikJs.doesIncludePluginTrackersAutomatically` has been renamed to `CustomJsTracker.doesIncludePluginTrackersAutomatically`

## Matomo 3.13.1

Expand Down
2 changes: 1 addition & 1 deletion config/global.ini.php
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@
Plugins[] = Marketplace
Plugins[] = ProfessionalServices
Plugins[] = UserId
Plugins[] = CustomPiwikJs
Plugins[] = CustomJsTracker
Plugins[] = Tour

[PluginsInstalled]
Expand Down
8 changes: 4 additions & 4 deletions core/FileIntegrity.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
namespace Piwik;

use Piwik\Container\StaticContainer;
use Piwik\Plugins\CustomPiwikJs\Exception\AccessDeniedException;
use Piwik\Plugins\CustomPiwikJs\TrackerUpdater;
use Piwik\Plugins\CustomJsTracker\Exception\AccessDeniedException;
use Piwik\Plugins\CustomJsTracker\TrackerUpdater;

class FileIntegrity
{
Expand Down Expand Up @@ -372,7 +372,7 @@ protected static function isModifiedPathValid($path)
// as trivial because piwik.js might be already updated, or updated on the next request. We cannot define
// 2 or 3 different filesizes and md5 hashes for one file so we check it here.

if (Plugin\Manager::getInstance()->isPluginActivated('CustomPiwikJs')) {
if (Plugin\Manager::getInstance()->isPluginActivated('CustomJsTracker')) {
$trackerUpdater = new TrackerUpdater();

if ($trackerUpdater->getCurrentTrackerFileContent() === $trackerUpdater->getUpdatedTrackerFileContent()) {
Expand All @@ -383,7 +383,7 @@ protected static function isModifiedPathValid($path)

try {
// the piwik.js tracker file was not updated yet, but may be updated just after the update by
// one of the events CustomPiwikJs is listening to or by a scheduled task.
// one of the events CustomJsTracker is listening to or by a scheduled task.
// In this case, we check whether such an update will succeed later and if it will, the file is
// valid as well as it will be updated on the next request
$trackerUpdater->checkWillSucceed();
Expand Down
15 changes: 15 additions & 0 deletions core/Updater/Migration/Plugin/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,19 @@ public function deactivate($pluginName)
'pluginName' => $pluginName
));
}

/**
* Uninstalls the given plugin during an update.
*
* If the plugin is still active or if any other error occurs it will be ignored.
*
* @param string $pluginName
* @return Uninstall
*/
public function uninstall($pluginName)
{
return $this->container->make('Piwik\Updater\Migration\Plugin\Uninstall', array(
'pluginName' => $pluginName
));
}
}
53 changes: 53 additions & 0 deletions core/Updater/Migration/Plugin/Uninstall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Updater\Migration\Plugin;

use Piwik\Config;
use Piwik\Plugin;
use Piwik\Updater\Migration;

/**
* Uninstalls the given plugin during the update
*/
class Uninstall extends Migration
{
/**
* @var string
*/
private $pluginName;

/**
* @var Plugin\Manager
*/
private $pluginManager;

public function __construct(Plugin\Manager $pluginManager, $pluginName)
{
$this->pluginManager = $pluginManager;
$this->pluginName = $pluginName;
}

public function __toString()
{
$domain = Config::getLocalConfigPath() == Config::getDefaultLocalConfigPath() ? '' : Config::getHostname();
$domainArg = !empty($domain) ? "--matomo-domain=\"$domain\" " : '';

return sprintf('./console %splugin:uninstall "%s"', $domainArg, $this->pluginName);
}

public function shouldIgnoreError($exception)
{
return true;
}

public function exec()
{
$this->pluginManager->uninstallPlugin($this->pluginName);
}

}
2 changes: 1 addition & 1 deletion core/Updates/2.16.3-b2.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Updates_2_16_3_b2 extends PiwikUpdates
public function doUpdate(Updater $updater)
{
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('CustomPiwikJs');
\Piwik\Plugin\Manager::getInstance()->activatePlugin('CustomJsTracker');
} catch (\Exception $e) {
}
}
Expand Down
25 changes: 17 additions & 8 deletions core/Updates/4.0.0-b1.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Piwik\Updates;

use Piwik\Config;
use Piwik\Updater;
use Piwik\Updates as PiwikUpdates;
use Piwik\Updater\Migration\Factory as MigrationFactory;
Expand All @@ -30,16 +31,24 @@ public function __construct(MigrationFactory $factory)

public function getMigrations(Updater $updater)
{
$migration1 = $this->migration->db->changeColumnType('log_action', 'name', 'VARCHAR(4096)');
$migration2 = $this->migration->db->changeColumnType('log_conversion', 'url', 'VARCHAR(4096)');
$migrations = [];
$migrations[] = $this->migration->db->changeColumnType('log_action', 'name', 'VARCHAR(4096)');
$migrations[] = $this->migration->db->changeColumnType('log_conversion', 'url', 'VARCHAR(4096)');

$migration3 = $this->migration->plugin->activate('BulkTracking');
$customTrackerPluginActive = false;
if (in_array('CustomPiwikJs', Config::getInstance()->Plugins['Plugins'])) {
$customTrackerPluginActive = true;
}

return array(
$migration1,
$migration2,
$migration3
);
$migrations[] = $this->migration->plugin->activate('BulkTracking');
$migrations[] = $this->migration->plugin->deactivate('CustomPiwikJs');
$migrations[] = $this->migration->plugin->uninstall('CustomPiwikJs');

if ($customTrackerPluginActive) {
$migrations[] = $this->migration->plugin->activate('CustomJsTracker');
}

return $migrations;
}

public function doUpdate(Updater $updater)
Expand Down
2 changes: 1 addition & 1 deletion plugins/CorePluginsAdmin/Commands/DeactivatePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function configure()
{
$this->setName('plugin:deactivate');
$this->setDescription('Deactivate a plugin.');
$this->addArgument('plugin', InputArgument::IS_ARRAY, 'The plugin name you want to activate. Multiple plugin names can be specified separated by a space.');
$this->addArgument('plugin', InputArgument::IS_ARRAY, 'The plugin name you want to deactivate. Multiple plugin names can be specified separated by a space.');
}

protected function execute(InputInterface $input, OutputInterface $output)
Expand Down
46 changes: 46 additions & 0 deletions plugins/CorePluginsAdmin/Commands/UninstallPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

namespace Piwik\Plugins\CorePluginsAdmin\Commands;

use Piwik\Plugin\ConsoleCommand;
use Piwik\Plugin\Manager;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
* plugin:deactivate console command.
*/
class UninstallPlugin extends ConsoleCommand
{
protected function configure()
{
$this->setName('plugin:uninstall');
$this->setDescription('Uninstall a plugin.');
$this->addArgument('plugin', InputArgument::IS_ARRAY, 'The plugin name you want to uninstall. Multiple plugin names can be specified separated by a space.');
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$pluginManager = Manager::getInstance();

$plugins = $input->getArgument('plugin');

foreach ($plugins as $plugin) {
if ($pluginManager->isPluginLoaded($plugin)) {
$output->writeln(sprintf('<comment>The plugin %s is still active.</comment>', $plugin));
continue;
}

$pluginManager->uninstallPlugin($plugin);

$output->writeln("Uninstalled plugin <info>$plugin</info>");
}
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

namespace Piwik\Plugins\CustomPiwikJs;
namespace Piwik\Plugins\CustomJsTracker;

use Piwik\Container\StaticContainer;
use Piwik\Piwik;
use Piwik\Plugins\CustomPiwikJs\Exception\AccessDeniedException;
use Piwik\Plugins\CustomJsTracker\Exception\AccessDeniedException;

/**
* API for plugin CustomPiwikJs
* API for plugin CustomJsTracker
*
* @method static \Piwik\Plugins\CustomPiwikJs\API getInstance()
* @method static \Piwik\Plugins\CustomJsTracker\API getInstance()
*/
class API extends \Piwik\Plugin\API
{
Expand All @@ -29,7 +29,7 @@ public function doesIncludePluginTrackersAutomatically()
Piwik::checkUserHasSomeAdminAccess();

try {
$updater = StaticContainer::get('Piwik\Plugins\CustomPiwikJs\TrackerUpdater');
$updater = StaticContainer::get('Piwik\Plugins\CustomJsTracker\TrackerUpdater');
$updater->checkWillSucceed();
return true;
} catch (AccessDeniedException $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

namespace Piwik\Plugins\CustomPiwikJs\Commands;
namespace Piwik\Plugins\CustomJsTracker\Commands;

use Piwik\Container\StaticContainer;
use Piwik\Plugin\ConsoleCommand;
use Piwik\Plugins\CustomPiwikJs\TrackerUpdater;
use Piwik\Plugins\CustomPiwikJs\TrackingCode\PluginTrackerFiles;
use Piwik\Plugins\CustomJsTracker\TrackerUpdater;
use Piwik\Plugins\CustomJsTracker\TrackingCode\PluginTrackerFiles;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -46,7 +46,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

public function updateTracker($sourceFile, $targetFile, $ignoreMinified)
{
$pluginTrackerFiles = StaticContainer::get('Piwik\Plugins\CustomPiwikJs\TrackingCode\PluginTrackerFiles');
$pluginTrackerFiles = StaticContainer::get('Piwik\Plugins\CustomJsTracker\TrackingCode\PluginTrackerFiles');

if ($ignoreMinified) {
if (empty($sourceFile) || $sourceFile === $this->getPathOriginalPiwikJs()) {
Expand All @@ -56,7 +56,7 @@ public function updateTracker($sourceFile, $targetFile, $ignoreMinified)
$pluginTrackerFiles->ignoreMinified();
}

$updater = StaticContainer::getContainer()->make('Piwik\Plugins\CustomPiwikJs\TrackerUpdater', array(
$updater = StaticContainer::getContainer()->make('Piwik\Plugins\CustomJsTracker\TrackerUpdater', array(
'fromFile' => $sourceFile, 'toFile' => $targetFile
));
$updater->setTrackerFiles($pluginTrackerFiles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

namespace Piwik\Plugins\CustomPiwikJs;
namespace Piwik\Plugins\CustomJsTracker;

use Piwik\Container\StaticContainer;
use Piwik\Log;
use Piwik\Plugin;

class CustomPiwikJs extends Plugin
class CustomJsTracker extends Plugin
{
public function registerEvents()
{
Expand All @@ -30,8 +30,8 @@ public function registerEvents()
public function updateTracker()
{
try {
if (Plugin\Manager::getInstance()->isPluginActivated('CustomPiwikJs')) {
$trackerUpdater = StaticContainer::get('Piwik\Plugins\CustomPiwikJs\TrackerUpdater');
if (Plugin\Manager::getInstance()->isPluginActivated('CustomJsTracker')) {
$trackerUpdater = StaticContainer::get('Piwik\Plugins\CustomJsTracker\TrackerUpdater');
$trackerUpdater->update();
}
} catch (\Exception $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\CustomPiwikJs\Diagnostic;
namespace Piwik\Plugins\CustomJsTracker\Diagnostic;

use Piwik\Filechecks;
use Piwik\Filesystem;
use Piwik\Plugins\CustomPiwikJs\File;
use Piwik\Plugins\CustomJsTracker\File;
use Piwik\Plugins\Diagnostics\Diagnostic\Diagnostic;
use Piwik\Plugins\Diagnostics\Diagnostic\DiagnosticResult;
use Piwik\SettingsPiwik;
Expand All @@ -20,7 +20,7 @@
/**
* Check Piwik JS is writable
*/
class PiwikJsCheck implements Diagnostic
class TrackerJsCheck implements Diagnostic
{
/**
* @var Translator
Expand Down Expand Up @@ -54,21 +54,21 @@ public function execute()
}
}

$label = $this->translator->translate('CustomPiwikJs_DiagnosticPiwikJsWritable', $this->makeFilesTitles($filesToCheck));
$label = $this->translator->translate('CustomJsTracker_DiagnosticPiwikJsWritable', $this->makeFilesTitles($filesToCheck));

if (empty($notWritableFiles)) {
return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK, ''));
}

$comment = $this->translator->translate('CustomPiwikJs_DiagnosticPiwikJsNotWritable', $this->makeFilesTitles($notWritableFiles));
$comment = $this->translator->translate('CustomJsTracker_DiagnosticPiwikJsNotWritable', $this->makeFilesTitles($notWritableFiles));

if (!SettingsServer::isWindows()) {
$command = '';
foreach ($notWritableFiles as $notWritableFile) {
$realpath = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/' . $notWritableFile);
$command .= "<br/><code> chmod +w $realpath<br/> chown ". Filechecks::getUserAndGroup() ." " . $realpath . "</code><br />";
}
$comment .= $this->translator->translate('CustomPiwikJs_DiagnosticPiwikJsMakeWritable', array($this->makeFilesTitles($notWritableFiles), $command));
$comment .= $this->translator->translate('CustomJsTracker_DiagnosticPiwikJsMakeWritable', array($this->makeFilesTitles($notWritableFiles), $command));
}

return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

namespace Piwik\Plugins\CustomPiwikJs\Exception;
namespace Piwik\Plugins\CustomJsTracker\Exception;

use Exception;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

namespace Piwik\Plugins\CustomPiwikJs;
namespace Piwik\Plugins\CustomJsTracker;

use Piwik\Plugins\CustomPiwikJs\Exception\AccessDeniedException;
use Piwik\Plugins\CustomJsTracker\Exception\AccessDeniedException;

class File
{
Expand Down
Loading

0 comments on commit ab1e700

Please sign in to comment.