Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tsteur opened this issue Feb 24, 2022 · 4 comments
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. c: Tracking For issues related to getting tracking data into Matomo. Easier debugging For issues that make troubleshooting issues for developers easier. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.

Comments

@tsteur
Copy link
Member

tsteur commented Feb 24, 2022

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.

@tsteur tsteur added Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Easier debugging For issues that make troubleshooting issues for developers easier. labels Feb 24, 2022
@tsteur tsteur added this to the 4.10.0 milestone Feb 24, 2022
@sgiehl
Copy link
Member

sgiehl commented Apr 4, 2022

@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:

public function getMissingDependencies($requires)
{
$missingRequirements = array();
if (empty($requires)) {
return $missingRequirements;
}
foreach ($requires as $name => $requiredVersion) {
$currentVersion = $this->getCurrentVersion($name);
if (in_array(strtolower($name), ['piwik', 'matomo'])) {
$requiredVersion = $this->markPluginsWithoutUpperBoundMatomoRequirementAsIncompatible($requiredVersion);
}
$missingVersions = $this->getMissingVersions($currentVersion, $requiredVersion);
if (!empty($missingVersions)) {
$missingRequirements[] = array(
'requirement' => $name,
'actualVersion' => $currentVersion,
'requiredVersion' => $requiredVersion,
'causedBy' => implode(', ', $missingVersions)
);
}
}
return $missingRequirements;

private function getCurrentVersion($name)
{
switch (strtolower($name)) {
case 'matomo':
case 'piwik':
return $this->piwikVersion;
case 'php':
return $this->phpVersion;
default:
try {
$pluginNames = PluginManager::getAllPluginsNames();
if (!in_array($name, $pluginNames) || !PluginManager::getInstance()->isPluginLoaded($name)) {
return '';
}
$plugin = PluginManager::getInstance()->loadPlugin(ucfirst($name));
if (!empty($plugin)) {
return $plugin->getVersion();
}
} catch (\Exception $e) {
}
}
return '';

@tsteur
Copy link
Member Author

tsteur commented Apr 4, 2022

@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
Copy link
Member

sgiehl commented Apr 5, 2022

@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
Copy link
Member Author

tsteur commented Apr 5, 2022

Sounds good if it's easy to do 👍

@mattab mattab added c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. c: Tracking For issues related to getting tracking data into Matomo. labels Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. c: Tracking For issues related to getting tracking data into Matomo. Easier debugging For issues that make troubleshooting issues for developers easier. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

4 participants