Giter VIP home page Giter VIP logo

performance-audit-plugin's Introduction

Performance Audit Plugin for Matomo

Stable Version GPL Licensed Tests Badge

Description

Daily performance audits of all your sites in Matomo for the following metrics based on Google Lighthouse:

  • First Contentful Paint
  • Speed Index
  • Largest Contentful Paint
  • Time To Interactive
  • Total Blocking Time
  • Cumulative Layout Shift
  • Overall Score

Continuously monitor those Web Vital metrics over time, allowing detection of underlying problems before they have an adverse effect for users or simply track changes made to the web application, allowing you to establish a baseline for comparison too.

Note: Requires minimum NPM v10.x (part of Node.js 20.x LTS) to be installed on your server, otherwise plugin cannot be activated.

Support me

If you installed this plugin and it was useful for you or your business, please don't hesitate to make a donation, I would highly appreciate it. Thank you!

Buy me a coffee

Installation

Preferably you install this plugin automatically by:

  1. Login to Matomo as Super User
  2. Navigate in your Matomo Installation to AdministrationMarketplace (categorized under Platform)
  3. Search for Performance Audit
  4. Click on Install and wait up to 5 minutes for the installation to finish

You can also install this plugin manually by:

  1. downloading the latest plugin zip file
  2. Login to Matomo as Super User
  3. Navigate in your Matomo Installation to AdministrationMarketplace (categorized under Platform)
  4. Click on upload a Plugin and upload the zip file from step 1
  5. Activate this plugin PerformanceAudit and wait up to 5 minutes for the process to finish

Note: If plugin upload is disabled, enable it in your config/config.ini.php like that:

[General]
enable_plugin_upload = 1

If any errors occur during activation, please follow the instruction or information of the error message.

Minimum requirements

Impact on server

Please keep in mind that Performance Audit uses Lighthouse internally in order to perform performance audits in the background for every Matomo tracked URL within the last 1 month. If the Matomo installation has more than 10,000 tracked unique URLs within the last 1 month, it's suggested to either reduce the number of performed audit iterations in the website settings, group URLs in website settings or increase the server resources. For Matomo installations with over 100,000 tracked unique URLs within the last 1 month, this plugin architecture is rather unsuitable and therefor not recommended.

Screenshots

Dashboard

Dashboard

Overall Scores

Overall Scores

First Contentful Paint

First Contentful Paint

For more screenshots, check out the screenshot overview.

Testing

Run the integration and unit tests with:

./console tests:run PerformanceAudit

Changelog

Please see the CHANGELOG for more information on what has changed recently.

Contact

If you have any questions or inquiries, you can contact github{at}diskoboss{døt}de.

Security

If you discover any security related issues, please contact github{at}diskoboss{døt}de instead of using the issue tracker.

Please note that the performance audits will be performed with Chromium which renders Matomo-tracked web pages on your server without the sandbox mode of Chromium. You can find more information about this possible issue on the lighthouse-cli repository.

License

Licensed under the GPLv3 License.

performance-audit-plugin's People

Contributors

devdavido avatar touxten avatar weblate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

performance-audit-plugin's Issues

Uncontrolled spawning of chrome

Activated this plugin. The next day my matomo server was on its knees. Took several minutes to shell into the server. Once in I discovered all memory was consumed (12GB, 6 core VM) with a load average of 15.9.

There were 500+ chrome processes spun up in parallel! None of the processes were background or running at a nice priority.

After deactivating the plugin, after about 10 minutes the load on the server returned to a normal level, however there are 500+
/var/www/html/plugins/PerformanceAudit/node_modules/puppeterr/* idling in the process listing.

Love the concept of this plugin, however there should be a warning in the description that using it on non-trivial web sites (there will be well over 1/4 million pages under my matomo installation) will need significant planning. Information on system requirements and would be helpful (based on site size, etc.)

Believe much of what was experienced could be mitigated with additional configuration options that are pre-set at low defaults that will prevent runaway process spawning.

For example:

  • maximum # of pages crawled
  • throttle - how many chrome/lighthouse processes will be spun up in parallel
  • niceness priority for plugin background processes
  • regex configuration options to specify/limit which site pages will be crawled - this could be used to limit the # of pages that will be crawled
  • time that plugin will launch the crawl process
  • estimate of the # of pages that will get crawled
  • kill switch - ability to immediately terminate any background processes
  • status page

Update:
Received a massive error email from my matomo server. Haven't had time to fully review but I can see urls that post only and listed in the robots.txt do not crawl list, along with pages of searches that pass in queries.

This means that the plugin was trying to lighthouse many of the same endpoints repeatedly each with different search query parameters. If that is the case my estimate of 1/4 million pages to be crawled will be in the multi-millions! Can see searches, filtering of results, pagination, sign-up forms; it was even hitting sign-up email validation links!

PerformanceAudit kills my server

At first great plugin and after correct setup the audit works really good. My problem was after setup that my server gets killed a day after installing the plugin. The problem looks like that all matomo sites starts the audit at the same time. This kills my server.

Is it possible to run the audit one by one and not all sites at the same time. Ideally it would be nice to run it for example at 3.00 o'clock in the night?

Server: 8 core / 16gb ram

PerformanceAudit - Functions deprecated

Hi,

I'm currently using Matomo 4.13.1 and I'm having an issue while enabling the plugin, it seems to prevent the cron tasks to work properly, here is the error when I navigate to the "Plugin check" section :

WARNING: /plugins/PerformanceAudit/vendor/symfony/process/Process.php(612): Deprecated - Return type of Symfony\Component\Process\Process::getIterator($flags = 0) should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice - Matomo 4.13.1 - Please report this message in the Matomo forums: https://forum.matomo.org/ (please do a search first as it might have been reported already) (Module: PerformanceAudit, Action: pluginCheck, In CLI mode: false)

Did someone run into this issue before ? How to solve it ?

Thanks.

Translations using Weblate

Hello,

Lukas from Matomo team here. We are currently in the process of moving our translations from Transifex to Weblate (matomo-org/matomo#17907).
As Weblate makes it easier to add a git repository as a component and merge back updated translations via pull requests, I thought it would be great if more plugins in Matomo were available in the users languages if someone is interested in translating them.

If you are interested in adding your plugin, simply comment here, and I'll help you with the setup.

Activation failed, because of missing npm dependency

In PerformanceAudit.php line 94:

PerformanceAudit plugin activation failed due to the following error:
Node.js dependency installation failed due to the following error:
npm dependency not found.
Searched in the following directories for the dependency: /var/www/html/plugins/PerformanceAudit/composer/bin, /var/www/html/plugins/PerformanceAudit/node_modules/.bin,
/usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /opt/plesk/node/24/bin, /opt/plesk/node/22/bin, /opt/plesk/node/20/bin, /opt/plesk/node/18/bin, /opt/pl
esk/node/16/bin, /opt/plesk/node/14/bin, /opt/plesk/node/12/bin, /opt/plesk/node/10/bin, /home/wodby/.composer/vendor/bin, /var/www/html/vendor/bin, /var/www/html/bin.

I upgraded from Matomo 4 to 5 and tried to enable the module.

Audit's report are created but never commit to database

Hi

I'm using PerformanceAudit since a while now but I was never able to commit data to the database.
I'm facing several "problems" which might be interesting to discuss with you, and maybe, help you to add those functionality.
I'm not a developper but I could help in some way maybe !

Let me explain :) !

  1. I have 2016 urls scanned by PerformanceAudit (Number of uniq id from "Audit" folder).

I don't really know how to determine which url has been scanned. Is there any way to control which url will be "available" to PerformanceAudit ?
While reading the code i could understand that it takes all url from last 30days right ? Can we configure, for example, "run audit for last 7 days urls only" ? This might be interesting ?

  1. Many times i have this error in my logs :
Audit of https://mywebsite/withmyarticle failed: Runtime error encountered: Lighthouse was unable to reliably load the page you requested. Make sure you are testing the correct URL and that the server is properly responding to all requests. (Details: net::ERR_INSUFFICIENT_RESOURCES

I'm not sure what to do. And i can't see any "errors" in PerformanceAudit plugins. Is there any way to retrieve those errors and be able to "notify" someone if failed ?

  1. Because it works but i don't have reports commited to the database. Is there any way to manually run the job to read all json and send them to the database ?

Bonus question, do you think it's possible to add button close to a "pages" from "pages" view of Matomo to trigger a "single" scan ?

Thanks for your awesome work so far.

Assorted Feedback

First of all, many thanks for creating such a useful and ambitious plugin for Matomo.

During install I noticed that chromium depends on libgbm1, so you might want to mention this in the docs.

Apart from that the plugin seems to be doing its job well. I tested it with the following:

sudo -u www-data php7.3 /var/www/matomo/console  scheduled-tasks:run "Piwik\Plugins\PerformanceAudit\Tasks.auditSite_2"

and the task seems to be running well (even though checking every single URL might take some time now).

One thing I noticed: The library seems to be setting --no-sandbox for all chromium processes.

$this->setChromeFlags(['--headless', '--disable-gpu', '--no-sandbox']);

While this is probably needed (I never got lighthouse-cli to work without it on Debian), I am wondering if this might be some security issue if the Matomo administrator doesn't control the tracked sites and should therefore also be documented.

One more thing:
It seems like the archiving throws errors on every 404, which could maybe just be a warning or info as there could be no longer existing sites tracked.

Plugin API Integration Test fails with SQL error

Currently, the Plugin API Integration Test fails with SQL error:

[20-Dec-2023 12:34:03 UTC] [localhost] Error in Matomo (tracker): Error query: Error query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'idaction_url' in 'field list' In query:
INSERT INTO log_link_visit_action (idvisit, idsite, idvisitor, idaction_url, idaction_url_ref, idaction_name_ref, server_time, idpageview, pageview_position, time_spent_ref_action, idaction_name) VALUES (?,?,?,?,?,?,?,?,?,?,?)
Parameters: array (   0 => '1',   1 => 1,   2 => '����m?��',   3 => '2',   4 => 0,   5 => 0,   6 => '2020-06-14 23:00:00',   7 => 'd7c98e',   8 => 1,   9 => 0,   10 => '1', )
In query: INSERT INTO log_link_visit_action (idvisit, idsite, idvisitor, idaction_url, idaction_url_ref, idaction_name_ref, server_time, idpageview, pageview_position, time_spent_ref_action, idaction_name) VALUES (?,?,?,?,?,?,?,?,?,?,?)
Parameters: array (   0 => '1',   1 => 1,   2 => '����m?��',   3 => '2',   4 => 0,   5 => 0,   6 => '2020-06-14 23:00:00',   7 => 'd7c98e',   8 => 1,   9 => 0,   10 => '1', )

Tested with Matomo 4.x and the column supposed to exist, so potentially an issue of the test environment.

Add user agent for matomo

I track the user with the php api of matomo. It would be nice if I could identify the performance audit by the user agent.

Remove anchor in url

Hi,

First, thank you for your excellent work.

What do you think of removing anchors ( Fragment ) from urls ?

Before push a PR i ask you ?

Sorry for my english.

Matomo 5 compatibility

Dear Matomo Plugin Author,
We are excited that Matomo 5.0.0 is on the horizon, and we would greatly appreciate your assistance in ensuring that your plugin remains compatible with this upcoming release. Maintaining compatibility will enable Matomo users to seamlessly use your plugin after they upgrade to Matomo 5. (If the plugin is not updated to be compatible with Matomo 5, then whenever a user will upgrade to Matomo 5, the plugin would be automatically disabled to prevent issues.)

Updating your plugin to be Matomo 5 compatible is a straightforward process and should not require a significant time investment. You can find more information about updating your plugin at: https://developer.matomo.org/guides/migrate-matomo-4-to-5

Thank you for your ongoing support and commitment to the Matomo community.
Your contribution is really appreciated!

The Matomo Team

PS: we’re also available to help if you have any question about making the plugin compatible.

tests:run PerformanceAudit fails

I try to test if the plugin works :

1/ Running the Plugin Check

[debug] Debug mode enabled
[info] Performance Audit task for site 1 will be started now
[debug] Mark task as running now
[debug] Mark task for site 1 as started today
[debug] Performing audit for (site ID, URLs, URL count, emulated devices, runs): [1,["https://www.dadall.info/article629/installer-grafana-prometheus-et-node-exporter"],1,["mobile"],[1]]
[info] Performing scheduled audit [1/1] of site 1 (device: mobile) for URL: https://www.dadall.info/article629/installer-grafana-prometheus-et-node-exporter
[debug] Audit file count: 1
[debug] Process Audit files: {"/var/www/html/matomo/plugins/PerformanceAudit/Audits/1-mobile-8bb0898f43b90fbb7bbc5863ffc67c96257ef20b-1.json":{}}
[debug] Audit files processed as: {"1":{"8bb0898f43b90fbb7bbc5863ffc67c96257ef20b":{"mobile":{"firstContentfulPaint":{"0":974},"largestContentfulPaint":{"0":1558},"interactive":{"0":7688},"speedIndex":{"0":2147},"totalBlockingTime":{"0":304},"cumulativeLayoutShift":{"0":0.4890625},"score":{"0":84}}}}}
[debug] Final audit values: {"1":{"8bb0898f43b90fbb7bbc5863ffc67c96257ef20b":{"mobile":{"firstContentfulPaint":[974,974,974],"largestContentfulPaint":[1558,1558,1558],"interactive":[7688,7688,7688],"speedIndex":[2147,2147,2147],"totalBlockingTime":[304,304,304],"cumulativeLayoutShift":[0,0,0],"score":[84,84,84]}}}}
[debug] Action IDs lookup table with URLs: [{"8bb0898f43b90fbb7bbc5863ffc67c96257ef20b":"39927"},["8bb0898f43b90fbb7bbc5863ffc67c96257ef20b"]]
[info] Skipping database storing of results
[debug] Mark task as finished now
[info] Performance Audit task for site 1 has finished 

Is it correct ?

2/ Using the console

  [InvalidArgumentException]                               
  There are no commands defined in the "tests" namespace.

I don't understand :(

successful installation - no data - no error message

We have successfully installed the module in the current stable Matomo version. Even after several days we do not get any data and there are no error messages, neither in the Matomo logs nor in the server logs.

PHP version is 7.2.32-1+ubuntu18.04.1+deb.sury.org+1

Node.js & NPM are installed and my PHP configuration allows to execute commands via proc_open" and cromimum is also installed

hat could be the reason that we do not get any data?

Matomo 4.0

Would be cool, this plugin gets compatible with Matomo 4!

Unable to install

Hi we got:

An error occurred
PerformanceAudit plugin activation failed due to the following error: Node.js dependency installation failed due to the following error: NPM has the following unexpected output: npm WARN using --force I sure hope you know what you are doing.npm ERR! code EACCESnpm ERR! syscall mkdirnpm ERR! path /var/www/.npmnpm ERR! errno -13npm ERR! npm ERR! Your cache folder contains root-owned files, due to a bug innpm ERR! previous versions of npm which has since been addressed.npm ERR! npm ERR! To permanently fix this problem, please run:npm ERR! sudo chown -R 33:33 "/var/www/.npm"npm ERR! code EACCESnpm ERR! syscall mkdirnpm ERR! path /var/www/.npmnpm ERR! errno -13npm ERR! npm ERR! Your cache folder contains root-owned files, due to a bug innpm ERR! previous versions of npm which has since been addressed.npm ERR! npm ERR! To permanently fix this problem, please run:npm ERR! sudo chown -R 33:33 "/var/www/.npm"
root@trace:/home/cosmic# sudo chown -R 33:33 "/var/www/.npm"
chown: cannot access '/var/www/.npm': No such file or directory

Timeout exceeded

An error occurred
PerformanceAudit plugin activation failed due to the following error: Node.js dependency installation failed due to the following error: The process "'/usr/bin/npm' 'install' '--quiet' '--no-progress' '--no-audit' '--force' '--only=production' '--prefix=/var/www/matomo/plugins/PerformanceAudit' 'puppeteer@^3.0' 'lighthouse@^6.0'" exceeded the timeout of 60 seconds.

I get this error while trying to install this plugin. I have already installed lighthouse package by running sudo npm install lighthouse

Plugin activation failing - npm ERR! cause: [Error: EACCES: permission denied, mkdir '/var/www']

Here is the error I get:

screenshot_2020-08-12_21-00-06@2x

PerformanceAudit plugin activation failed due to the following error:
NPM has the following unexpected output: 
npm WARN using --force I sure hope you know what you are doing.
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /var/www
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/var/www'
npm ERR! [OperationalError: EACCES: permission denied, mkdir '/var/www'] {
npm ERR! cause: [Error: EACCES: permission denied, mkdir '/var/www'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/var/www'
npm ERR! },
npm ERR! isOperational: true,
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/var/www'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /var/www
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/var/www'
npm ERR! [OperationalError: EACCES: permission denied, mkdir '/var/www'] {
npm ERR! cause: [Error: EACCES: permission denied, mkdir '/var/www'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/var/www'
npm ERR! },
npm ERR! isOperational: true,
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/var/www'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

However, my matomo is in /srv/matomo. Not sure what NPM is trying to do here.

Let me know if I can provide more info!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.