forked from matomo-org/plugin-QueuedTracking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
QueuedTracking.php
79 lines (66 loc) · 1.83 KB
/
QueuedTracking.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?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\Plugins\QueuedTracking;
use Piwik\Common;
use Piwik\Plugins\QueuedTracking\Queue\Backend\MySQL;
use Piwik\Plugins\QueuedTracking\Tracker\Handler;
class QueuedTracking extends \Piwik\Plugin
{
/**
* @see \Piwik\Plugin::registerEvents
*/
public function registerEvents()
{
return array(
'Tracker.newHandler' => 'replaceHandlerIfQueueIsEnabled',
'Db.getTablesInstalled' => 'getTablesInstalled'
);
}
/**
* Register the new tables, so Matomo knows about them.
*
* @param array $allTablesInstalled
*/
public function getTablesInstalled(&$allTablesInstalled)
{
$allTablesInstalled[] = Common::prefixTable('queuedtracking_queue');
}
public function install()
{
$mysql = new MySQL();
$mysql->install();
$configuration = new Configuration();
$configuration->install();
}
public function uninstall()
{
$mysql = new MySQL();
$mysql->uninstall();
$configuration = new Configuration();
$configuration->uninstall();
}
public function isTrackerPlugin()
{
return true;
}
public function replaceHandlerIfQueueIsEnabled(&$handler)
{
$useQueuedTracking = Common::getRequestVar('queuedtracking', 1, 'int');
if (!$useQueuedTracking) {
return;
}
$settings = Queue\Factory::getSettings();
if ($settings->queueEnabled->getValue()) {
$handler = new Handler();
if ($settings->processDuringTrackingRequest->getValue()) {
$handler->enableProcessingInTrackerMode();
}
}
}
}