matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.91k stars 2.65k forks source link

Make it easier to figure out why JS tracker file is not updated with custom js trackers #18845

Open tsteur opened 2 years ago

tsteur commented 2 years ago

We've just been debugging an issue for a few days with various forth and back why Form tracking wasn't working. We noticed the tracking code wasn't added to the regular JS tracking code. This can have various reasons like not writable JS tracking file etc. It turned out that the CustomJsTracker wasn't activated.

We already have a check that shows when the tracker file is not writable in https://github.com/matomo-org/matomo/blob/4.x-dev/plugins/CustomJsTracker/Diagnostic/TrackerJsCheck.php but it doesn't show anything when the plugin is not activated.

How can we notice such an issue sooner / easier without devs needing to troubleshoot?

Maybe the diagnostics plugin could add a system check and show some information that the tracker file won't be updated when this plugin is not active. This would be "for your information" only as it is only needed when any custom JS tracker file exists. Meaning it's not a warning or an error or something.

Or maybe we could simply create an FAQ how to troubleshoot the issue and getting users to check if the CustomJsTracker plugin is listed in the activated or deactivated plugin list. Although people might not find the FAQ.

Or something else :)

I'll put this into 4.10 as it's an issue when people try our plugins, and they think the plugin isn't working but in reality its just that the CustomJsTracker plugin is deactivated.

sgiehl commented 2 years ago

@tsteur Can't we use plugin dependencies for that? In plugin.json It is already possible to define something like

    "require": {
        "matomo": ">=4.0.0-b5,<5.0.0-b1",
        "CustomJsTracker": "*"
    },

But our dependency check only checks if the plugin is installed in a correct version. We currently do not check if the plugin is also activated. This might be something we could change. It would make it impossible to activate the plugin and could be shown like a missing dependency at the moment: image

But we maybe should also consider to introduce a new check when disabling a plugin. So Matomo warns that disabling plugin X will also disable plugin Y (and Z) due to the dependencies. Otherwise users might disable CustomJsTracker without knowing that other plugins will automatically be disabled as well.

Related code:

https://github.com/matomo-org/matomo/blob/3b00013819863472afe30cc04de49c4365c22d21/core/Plugin/Dependency.php#L36-L63

https://github.com/matomo-org/matomo/blob/3b00013819863472afe30cc04de49c4365c22d21/core/Plugin/Dependency.php#L171-L196

tsteur commented 2 years ago

@sgiehl the plugin shouldn't be required as we also support loading the tracker file independent of the regular tracking code. Especially when the JS tracker files aren't writable. And there's a risk that it would automatically disable other plugins which would make things only worse.

It's such a rare case, I would say all we need is a quick system check to show that the plugin is disabled

sgiehl commented 2 years ago

@tsteur Ok. But guess it only makes sense to check that if a plugin is installed that provides a tracker.min.js file. Otherwise the plugin wouldn't be needed. right?

tsteur commented 2 years ago

Sounds good if it's easy to do 👍