Cleanup default analytics function #113
Reference in New Issue
Block a user
Delete Branch "cleanup/analytics"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A very small cleanup of the default analytics functionality -- moved a check that did nothing to somewhere more useful and deleted a comment that didn't reflect what the function actually does.
I don't understand how this is better than the original. The check was in case a user set
options.analyticsto a truthy value that wasn't a function, in which case it was replaced by a dummy function, so it wouldn't throw an error when we try calling it. Why is it better to have the check later on?IMO it's more useful to have the check right before we try and call the function to make certain that it's not going to throw an error -- when dealing with variables that could be set by a user, I always like to code defensively.
It would be even more useful though if the options check also assigned the default analytics function if the user supplied a truthy value that wasn't a function, so that all bases are covered. I will make it so.
What if I want to disable Pjax from handling analytics? I could set
options.analyticsto a void function, but I think it would be better to set it tofalsein that situation, and add a truthy check first, instead of just checking for a function. Then, if the user sets it to a truthy value that's not a function, you can just set it tofalseornull.That's a good point, I will implement as you have described.
@robinnorth Can you resolve the merge conflicts?
Certainly, will rebase and resolve once #114 is merged
I think the conflict is with the current master/HEAD, because of
e7935d9c74. So you can resolve it without waiting for #114, as long as you rebase on the current master and incorporate the changes from that commit.LGTM. Is this ready to be merged?