Closed matcho closed 2 years ago
This would be really useful feature. Previously (before 1.0.0-rc.0) I used following construct and it worked well:
if (!isDevMode()) {
this.matomoInjector.init(url, id);
}
In 1.0.0-rc.0 init()
is not called by my own code anymore and some other way to achieve same behavior would be nice.
Thanks for having given a try to the RC :-)
I understand that in certain situation you would like to disable tracking in dev mode, however, in many other situations, you might still want to have tracking, especially if you have a dedicated site id, or even a dedicated instance.
In your situation, I think I'd :
export const environment = {
production: false,
matomoConfig: {
scriptUrl: '//some.server/matomo.js',
trackers: [],
}
};
MatomoModule.forRoot(environment.matomoConfig)
.That sould cleanly do the trick.
I was thinking of raising an exception if no tracker was provided, but I guess I'm going to change my mind.
Please tell me if it works for you.
With this setup matomo script is still initialized and tries to track pageviews and events etc. As it doesn't have correct tracking url, it just fails. Currently I solved the problem by creating an extra site in Matomo server just for development environments. It doesn't have any analytics value but at least everything works in local machines and doesn't throw errors.
OK, I'll check how to address nicely your issue very soon.
You can have a look at https://www.npmjs.com/package/ngx-matomo/v/1.0.0-rc.1
This new release is now built with Angular 12 (RC), but shall be a drop-in replacement.
You can have a look at the demo app (https://github.com/Arnaud73/ngx-matomo/tree/master/projects/demo), I've used several configurations, one of them disabling the tracking features.
Let me know if it works for you.
Release 1.0 finaly implemented what has been suggested in RC1 : if the Matomo script URL is not provided, then the tracker is in "dummy" mode.
Hi,
Could it be possible to add an option (or make it a default behaviour) that stops tracking when Angular app is in dev mode ? Of course all
trackPageView()
calls can be surrounded by a testif (! isDevMode())
but this impacts readability, and it seems quite natural not to track page views generated by the developer's work.What makes me ask for this feature is the following issue I ran into: running e2e tests with Protractor triggers hundreds of Matomo events. In such a case, IP / hostname filtering in Matomo settings is not always a good solution because it requires extra attention and frequent adjustments (since IP may change, especially when working at home), and may also be unavailable to the developer depending on who runs Matomo.
Thanks for your consideration, Mathias