segmentio/snippet — pull request #12 by yields (2014-05-22 16:21:17+00:00)
Title: V3

some users have ajax enabled, and they accidentally run the snippet twice, i fixed that in the latest version but it looks like `analytics.page()` will be called anyway, and it's really hard to debug why.

this pull-request:

- make sure the snippet is run only once.
- don't leak any globals like `i`. (good catch by @lancejpollard !)
- wrap the snippet in a function to allow uglify to produce a smaller snippet.
- add tests for queues (make sure `.page()` etc.. actually push to the queue).
- remove access to `.factory()` so that people never use it.
- remove linebreaks for `analytics.page()` and `analytics.load()` in minified snippet.

cc @ianstormtaylor @lancejpollard