angulartics / angulartics-google-analytics

Google Analytics plugin for Angulartics
MIT License
133 stars 86 forks source link

Silently skip eventTrack when action is empty #81

Closed odedniv closed 7 years ago

odedniv commented 7 years ago

Sometimes the event is conditional, and setting the analytics-event directive to empty is the only way to do that. Either way, the previous message didn't lead to angulartics, thus starting a long research as to where this pops up from.

timelf123 commented 7 years ago

perhaps this should be noted in the readme as well?

odedniv commented 7 years ago

This probably needs to be done on angulartics repo, and should stay consistent across the other platforms.

The main thing is just not to do anything if received an empty event, including not writing anything to console. Writing to console is a bad habit anyway... You should either throw an exception if the argument is invalid or decide on how the edge case works and document it if it's not obvious. Writing to console with no stack trace is a pain for the package's users.

DanWilkerson commented 7 years ago

Agreed; we should probably fail silently on everything. I believe logs are in place to help devs who are having issues when implementing specific features; we should make a .debug version for that use case and delegate logging there, then strip logs from prod when building.

odedniv commented 7 years ago

Yup, console is only for debugging and nothing else. Once debugging is complete console writes should be removed. If something should fail, throw an exception (so the user can see where it's from and will hopefully not ignore it).