Getting the tracker version

Hi,

I develop the Angular integration plugin for Matomo and I have a small issue with Matomo 4: setGenerationTimeMS is no longer supported and must not be invoked if one does not want to have errors in the console.

In the latest features I’m adding to the plugin are automations of some generic functions, such as tracking route modifications. In this code I used to call setGenerationTimeMS which works great with Matomo 3- trackers, but no longer with Matomo 4+ trackers. Since the user provides the plugin with the URL of the JS Matomo tracker, I do not know which version of the tracker is going to be used.

I could ask the user to indicate which version of the tracker is going to be provided in the URL, however, this is an obvious source of possible discrepencies if Matomo is updated on the server side, thus ending in future useless issues created on my side.

Is there any way to know which version is the tracker or is a feature is supported by the tracker?

Hi,

Maybe one way to find out this specific issue would be to check something like tracker.setGenerationTimeMs.toString().indexOf('logConsoleError') !== -1 before calling the function.
(The suggestion is by @diosmosis, maybe try it out first).

Update: logConsoleError might not work if the matomo.js is minified, but another part of the error message should work.