Hi, for the sake of avoiding an if around every Analytics.trackEvent line we have in our code, I'd like to have a way to disable this module when a UA account is not defined (that's an option that our users will have to use or not).
Unfortunately disableAnalytics requires an account or gives a stack trace exception, so I worked it around like this:
mod.config(/*@ngInject*/ function (AnalyticsProvider, analyticsId) {
if (analyticsId)
AnalyticsProvider.setAccount(analyticsId);
else {
AnalyticsProvider.setAccount(''); // else fails on next line
AnalyticsProvider.disableAnalytics(true);
}
})
This works ok (and any page change and event tracking generate no errors), but is there a recommended way to achieve this?
Hi, for the sake of avoiding an
ifaround everyAnalytics.trackEventline we have in our code, I'd like to have a way to disable this module when a UA account is not defined (that's an option that our users will have to use or not).Unfortunately
disableAnalyticsrequires an account or gives a stack trace exception, so I worked it around like this:This works ok (and any page change and event tracking generate no errors), but is there a recommended way to achieve this?