Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
5e9fc85
Translated using Weblate (Irish)
weblate Jul 13, 2024
5d9db27
Merge pull request #149 from weblate/weblate-matomo-plugin-visitorgen…
snake14 Jul 21, 2024
8081d24
Translated using Weblate (Czech)
weblate Aug 18, 2024
0d8b6b4
Merge pull request #150 from weblate/weblate-matomo-plugin-visitorgen…
snake14 Aug 18, 2024
f11a46c
Use Symfony/Process from core (#151)
mneudert Sep 2, 2024
cae677f
Bumped version to 5.1.0
AltamashShaikh Sep 9, 2024
d41c510
Merge pull request #154 from matomo-org/bump-version-5.1.0
AltamashShaikh Sep 9, 2024
3c600ba
Adds test for PHPCS
AltamashShaikh Oct 11, 2024
1f02a32
Updated screenshot
AltamashShaikh Oct 17, 2024
d44c923
Merge pull request #155 from matomo-org/PG-3945-update-screenshot
snake14 Oct 17, 2024
a71d5e0
Merge branch '5.x-dev' into spice-psr
snake14 Oct 20, 2024
aed1d06
Making PHPCS changes
snake14 Oct 20, 2024
b20704c
Merge pull request #156 from matomo-org/spice-psr
snake14 Oct 20, 2024
1ca3bd5
Updated tests to run on php 8.4 from 8.3, #PG-3957
AltamashShaikh Oct 30, 2024
0efce66
Merge pull request #157 from matomo-org/PG-3957-php-8.4-upgrade
snake14 Nov 3, 2024
90a7945
Translated using Weblate (Spanish)
weblate Nov 26, 2024
0effd67
Merge pull request #158 from weblate/weblate-matomo-plugin-visitorgen…
AltamashShaikh Nov 26, 2024
ab0aa48
Translated using Weblate (Finnish)
weblate Dec 10, 2024
1c9a836
Merge pull request #159 from weblate/weblate-matomo-plugin-visitorgen…
snake14 Dec 10, 2024
6030120
Translated using Weblate (Albanian)
weblate Dec 11, 2024
d56ee41
Merge pull request #160 from weblate/weblate-matomo-plugin-visitorgen…
snake14 Dec 11, 2024
45e5074
Translated using Weblate (Tamil)
weblate Jan 15, 2025
3743fd8
Merge pull request #161 from weblate/weblate-matomo-plugin-visitorgen…
AltamashShaikh Jan 15, 2025
5aedb57
Translated using Weblate (Tamil) (#162)
weblate Jan 17, 2025
4192651
Translated using Weblate (French)
weblate Jan 29, 2025
b87aafd
Merge pull request #163 from weblate/weblate-matomo-plugin-visitorgen…
snake14 Jan 29, 2025
5ba7eb1
Updating dependency to eliminate deprecation warning
snake14 Feb 3, 2025
e0581c8
Translated using Weblate (French)
weblate Feb 8, 2025
4e63a2b
Merge pull request #166 from weblate/weblate-matomo-plugin-visitorgen…
snake14 Feb 9, 2025
b576fd7
Used Rector to downgrade Faker library to PHP 7
snake14 Feb 17, 2025
79fc0f1
Adjusting a couple things to allow older PHP version
snake14 Feb 17, 2025
2ce7487
Removing platform check
snake14 Feb 17, 2025
6041fe8
Merge branch '5.x-dev' into PG-4119-deprecation-warning
snake14 Feb 17, 2025
700023e
Removing platform check
snake14 Feb 17, 2025
15ab8ee
Updating readme and trying to fix parse error
snake14 Feb 17, 2025
8394149
Downgrading further to remove trailing commas from function calls
snake14 Feb 17, 2025
f85704e
Revert workflow file now that platform check has been removed
snake14 Feb 17, 2025
4ed6953
Revert "Revert workflow file now that platform check has been removed"
snake14 Feb 17, 2025
252bf9f
Bumping version
snake14 Feb 17, 2025
266b522
Merge pull request #165 from matomo-org/PG-4119-deprecation-warning
snake14 Feb 17, 2025
e165ae6
Translated using Weblate (Finnish)
weblate Feb 18, 2025
2ada560
Merge pull request #167 from weblate/weblate-matomo-plugin-visitorgen…
AltamashShaikh Feb 18, 2025
8bc3720
Updated matomo-tests.yml to run on ubuntu-24.04
AltamashShaikh Mar 6, 2025
007687e
Merge pull request #168 from matomo-org/update-gh-os
snake14 Mar 6, 2025
c2c7ab0
Adds pull request template to stop bouncing review questions
AltamashShaikh Mar 18, 2025
1796a9b
Merge pull request #169 from matomo-org/add-pr-template
snake14 Mar 21, 2025
20e7562
Translated using Weblate (Spanish)
weblate May 7, 2025
44ae1d2
Merge pull request #170 from weblate/weblate-matomo-plugin-visitorgen…
snake14 May 7, 2025
9a1a58d
Translated using Weblate (Tamil)
weblate Jun 23, 2025
df11e90
Merge pull request #171 from weblate/weblate-matomo-plugin-visitorgen…
snake14 Jun 23, 2025
d6995a1
Translated using Weblate (Chinese (Simplified Han script))
weblate Jul 14, 2025
17e2eb5
Merge pull request #172 from weblate/weblate-matomo-plugin-visitorgen…
snake14 Jul 14, 2025
96126f2
Generate AI referrer URLs (#173)
sgiehl Aug 6, 2025
4c36df4
Bumped version to 5.1.2
AltamashShaikh Aug 18, 2025
57b52d3
Merge pull request #174 from matomo-org/bump-version-5.1.2
AltamashShaikh Aug 18, 2025
d7d3226
Fix: orderId=0 invalid
james-hill-matomo Aug 25, 2025
9ba583e
Bumped version after orderId 0 bugfix
james-hill-matomo Aug 25, 2025
33fb191
Merge pull request #175 from matomo-org/order_id_not_zero
AltamashShaikh Aug 26, 2025
1964c7a
Translated using Weblate (Croatian)
weblate Oct 7, 2025
9c1fbee
Merge pull request #177 from weblate/weblate-matomo-plugin-visitorgen…
snake14 Oct 7, 2025
52be152
Mark visits randomly as coming from ChatGPT Agent (#176)
sgiehl Oct 23, 2025
74e75eb
Translations update from Hosted Weblate (#179)
weblate Nov 2, 2025
e1b55ef
PG-4669 test with matomo5_[max|min]_php [ignore_release]
snake14 Nov 2, 2025
6f8bc7f
Merge pull request #180 from matomo-org/PG-4669-use-min-max
james-hill-matomo Nov 3, 2025
1be1927
Randomly mark visits as NovaAct agent also (#181)
sgiehl Nov 3, 2025
5404e46
Adds new command to send fake AI Bot Requests (#182)
sgiehl Nov 6, 2025
358a673
Bumped version to 5.1.4
AltamashShaikh Nov 10, 2025
34ea20c
Merge pull request #183 from matomo-org/bump-version-5.1.4
AltamashShaikh Nov 11, 2025
7c30ff3
Add optional word prefix to order ID since they don't have to be just…
michalkleiner Nov 12, 2025
af36dcd
Bump version and update changelog
michalkleiner Nov 12, 2025
7745dd4
Merge pull request #184 from matomo-org/string-order-id
AltamashShaikh Nov 12, 2025
51880ee
Translated using Weblate (Indonesian)
Dec 2, 2025
2ecbb2d
Translated using Weblate (Hebrew)
Dec 2, 2025
ece8bfd
Merge pull request #186 from weblate/weblate-matomo-plugin-visitorgen…
AltamashShaikh Dec 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .github/workflows/matomo-tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Action for running tests
# This file has been automatically created.
# To recreate it you can run this command
# ./console generate:test-action --plugin="VisitorGenerator" --php-versions="7.2,8.3" --schedule-cron="30 2 * * 6"
# ./console generate:test-action --plugin="VisitorGenerator" --php-versions="matomo5_min_php,matomo5_max_php" --schedule-cron="30 2 * * 6"

name: Plugin VisitorGenerator Tests

Expand Down Expand Up @@ -33,11 +33,11 @@ concurrency:

jobs:
PluginTests:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
php: [ '7.2', '8.3' ]
php: [ 'matomo5_min_php', 'matomo5_max_php' ]
target: ['minimum_required_matomo', 'maximum_supported_matomo']
steps:
- uses: actions/checkout@v3
Expand All @@ -54,4 +54,4 @@ jobs:
test-type: 'PluginTests'
matomo-test-branch: ${{ matrix.target }}
artifacts-pass: ${{ secrets.ARTIFACTS_PASS }}
upload-artifacts: ${{ matrix.php == '7.2' && matrix.target == 'maximum_supported_matomo' }}
upload-artifacts: ${{ matrix.php == 'matomo5_min_php' && matrix.target == 'maximum_supported_matomo' }}
42 changes: 42 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: PHPCS check

on: pull_request

permissions:
actions: read
checks: read
contents: read
deployments: none
issues: read
packages: none
pull-requests: read
repository-projects: none
security-events: none
statuses: read

jobs:
phpcs:
name: PHPCS
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: false
persist-credentials: false
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: cs2pr
- name: Install dependencies
run:
composer --no-plugins config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true -n;
composer config repositories.matomo-coding-standards vcs https://github.com/matomo-org/matomo-coding-standards -n;
composer require matomo-org/matomo-coding-standards:dev-master;
composer install --dev --prefer-dist --no-progress --no-suggest
- name: Check PHP code styles
id: phpcs
run: ./vendor/bin/phpcs --report-full --standard=phpcs.xml --report-checkstyle=./phpcs-report.xml
- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr ./phpcs-report.xml --prepend-filename
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,16 @@
* Updated README url in UI
- 5.0.3
* Added plugin category for Marketplace
- 5.1.0 - 2024-09-09
* Replaced Symfony\Process with Piwik\Process
- 5.1.1 - 2025-02-17
* Fixed deprecation warning from dependency
- 5.1.2 - 2025-08-18
* Started generating AI referrer URLs
- 5.1.3 - 2025-09-01
* Fix for generation of ecommerce order ID 0
- 5.1.4 - 2025-11-10
* Randomly mark visits as NovaAct agent also
* Added new command to send fake AI Bot Requests
- 5.1.5 - 2025-11-24
* Generate string order IDs occasionally
3 changes: 1 addition & 2 deletions Commands/AnonymizeLog.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down Expand Up @@ -136,7 +137,6 @@ private function anonymizeDomains($line)
$url = parse_url($log['url']);

if (!empty($url['query'])) {

$params = array();
parse_str($url['query'], $params);

Expand All @@ -147,7 +147,6 @@ private function anonymizeDomains($line)
$line = str_replace(urlencode($params[$param]), urlencode($newUrl), $line);
}
}

}

$referrer = $log['referrer'];
Expand Down
2 changes: 1 addition & 1 deletion Commands/GenerateAnnotation.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down Expand Up @@ -44,5 +45,4 @@ protected function doExecute(): int

return self::SUCCESS;
}

}
132 changes: 132 additions & 0 deletions Commands/GenerateBotRequests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?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\VisitorGenerator\Commands;

use Piwik\Access;
use Piwik\Date;
use Piwik\Plugin\ConsoleCommand;
use Piwik\Plugins\VisitorGenerator\Generator\BotRequestsFake;
use Piwik\Site;
use Piwik\Timer;
use Piwik\UrlHelper;

class GenerateBotRequests extends ConsoleCommand
{
protected function configure()
{
$this->setName('visitorgenerator:generate-bot-requests');
$this->setDescription('Generates many bot requests for a given amount of days in the past. This command is intended for developers.');
$this->addRequiredValueOption('idsite', null, 'Defines the site the requests should be generated for');
$this->addRequiredValueOption('days', null, 'Defines for how many days in the past requests should be generated', 1);
$this->addRequiredValueOption('start-date', null, 'Date to start generating on.');
$this->addRequiredValueOption('limit-fake-requests', null, 'Limits the number of fake requests', null);
$this->addRequiredValueOption('custom-matomo-url', null, "Defines an alternate Matomo URL, e.g. if Matomo is installed behind a Load-Balancer.");
}

/**
* @return int
*/
protected function doExecute(): int
{
$input = $this->getInput();
$output = $this->getOutput();
$timer = new Timer();
$days = $this->checkDays();
$customMatomoUrl = $this->checkCustomMatomoUrl();
$limit = $this->getLimitFakeRequests();
$idSite = $this->getIdSite();

$startDate = $input->getOption('start-date');
if (empty($startDate) || $startDate === 'now') {
$startTime = time();
} else {
$startTime = strtotime($startDate);
}

$time = $startTime - ($days - 1) * 86400;

$nbActionsTotal = 0;
while ($time <= $startTime) {
$output->writeln([
sprintf("Generating requests for %s...", Date::factory($time)->toString()),
]);

Access::doAsSuperUser(function () use ($time, $idSite, &$nbActionsTotal, $customMatomoUrl, $limit) {
$fakeRequests = new BotRequestsFake($customMatomoUrl);
$nbActionsTotal += $fakeRequests->generate($time, $idSite, $limit);
});

$time += 86400;
}

$this->writeSuccessMessage([
'idsite = ' . $idSite,
$nbActionsTotal . ' Requests generated',
round($nbActionsTotal / $timer->getTime(), 0) . ' requests per second',
]);

return self::SUCCESS;
}

private function getLimitFakeRequests(): int
{
$input = $this->getInput();

if ($input->getOption('limit-fake-requests')) {
return $input->getOption('limit-fake-requests');
}

return rand(400, 1000);
}

protected function checkDays(): int
{
$days = (int)$this->getInput()->getOption('days');

if ($days < 1) {
throw new \InvalidArgumentException('Days to compute must be greater or equal to 1.');
}

return $days;
}

private function checkCustomMatomoUrl(): ?string
{
if (!$customMatomoUrl = $this->getInput()->getOption('custom-matomo-url')) {
return null;
}

if (!UrlHelper::isLookLikeUrl($customMatomoUrl)) {
throw new \Exception("The Custom Matomo Tracker Url you entered doesn't seem to be valid.");
}

return $customMatomoUrl;
}

protected function getIdSite(): int
{
$idSite = $this->getInput()->getOption('idsite');

if ($idSite === null) {
$idSite = $this->ask('ID of the site in which to generate the visits: ');
}

$idSite = (int)$idSite;

return Access::doAsSuperUser(function () use ($idSite) {
if (!Site::getSite($idSite)) {
throw new \InvalidArgumentException('idsite is not a valid, no such site found');
}

return $idSite;
});
}
}
2 changes: 1 addition & 1 deletion Commands/GenerateGoals.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down Expand Up @@ -46,5 +47,4 @@ protected function doExecute(): int

return self::SUCCESS;
}

}
31 changes: 22 additions & 9 deletions Commands/GenerateLiveVisits.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down Expand Up @@ -26,15 +27,24 @@ protected function configure()
$this->setDescription('Continuously generates visits from a single log file to make it seem like there is real time traffic.');
$this->addRequiredValueOption('idsite', null, '(required) The ID of the site to track to.');
$this->addRequiredValueOption('stop-after', null, 'If supplied, the command will exit after this many seconds.');
$this->addRequiredValueOption('log-file', null,
'(required) The log file to track visits from. This file MUST have visits in order of time.');
$this->addRequiredValueOption('day-of-month', null,
$this->addRequiredValueOption(
'log-file',
null,
'(required) The log file to track visits from. This file MUST have visits in order of time.'
);
$this->addRequiredValueOption(
'day-of-month',
null,
'By default this command starts with visits for the current day of the month. Use this option to force an override. '
. 'Specify 0 to ignore day of the month and use every log.',
Date::now()->toString('j'));
$this->addRequiredValueOption('time-of-day', null,
Date::now()->toString('j')
);
$this->addRequiredValueOption(
'time-of-day',
null,
'The time of day to start replaying logs for. Defaults to now, specify a value here to override.',
time() % LiveVisitsFromLog::SECONDS_IN_DAY);
time() % LiveVisitsFromLog::SECONDS_IN_DAY
);
$this->addRequiredValueOption('custom-matomo-url', null, 'Custom Matomo URL to track to.');
$this->addRequiredValueOption('timeout', null, "Sets how long, in seconds, the timeout should be for the request.", 10);
$this->addRequiredValueOption('token-auth', null, 'Use custom token auth instead of system generated one. If running this '
Expand Down Expand Up @@ -83,7 +93,8 @@ protected function doExecute(): int

// nextWaitTime can be large if the next visit happens in an hour. no sense in
// waiting if it'll be after stopAfter
if ($stopAfter > 0
if (
$stopAfter > 0
&& (time() + $nextWaitTime) - $startTime > $stopAfter
) {
$output->writeln("$stopAfter seconds reached, exiting.");
Expand All @@ -93,7 +104,8 @@ protected function doExecute(): int
$output->writeln(" sleeping {$nextWaitTime}s.");
sleep($nextWaitTime);

if ($stopAfter > 0
if (
$stopAfter > 0
&& time() - $startTime > $stopAfter
) {
$output->writeln("$stopAfter seconds reached, exiting.");
Expand All @@ -107,7 +119,8 @@ protected function doExecute(): int
private function getPostiveIntegerOption($optionName)
{
$value = $this->getInput()->getOption($optionName);
if (!empty($value)
if (
!empty($value)
&& (!is_numeric($value)
|| $value < 0)
) {
Expand Down
2 changes: 1 addition & 1 deletion Commands/GenerateUsers.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down Expand Up @@ -39,5 +40,4 @@ protected function doExecute(): int

return self::SUCCESS;
}

}
4 changes: 2 additions & 2 deletions Commands/GenerateVisits.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down Expand Up @@ -104,7 +105,6 @@ private function getLimitFakeVisits()
$input = $this->getInput();

if ($input->getOption('limit-fake-visits')) {

return $input->getOption('limit-fake-visits');
}

Expand Down Expand Up @@ -153,4 +153,4 @@ protected function getIdSite()
return $idSite;
});
}
}
}
Loading
Loading