yeoman / insight

Node.js module to help you understand how your tool is being used by anonymously reporting usage metrics to Google Analytics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docs

sindresorhus opened this issue · comments

Need more docs when the Analytics API is public.

  • How does it work.
  • Where in Analytics can you find the metrics
  • Use cases of where it could be useful to have metrics
  • ...

Braindump

I choose to split it up into two processes. The first one handles the user-side of things, tracking, permission, etc. When a user wants to track a path, they call .track() which then parses and adds it to the queue, and then calls ._save which is responsible for messaging the record to the second process push.js. The reason for the queue is to be able to handle bursts of consecutive track() calls by combining the queue with debouncing.

The second process is responsible for getting messages with queues and handling them. It does this by reading the saved queue, merging it with the live queue, then deleting the saved queue, and then trying to send the whole queue out. If it fail, in case of eg. offline, it will save the queue again.

The reason for the split is separation of concern and the benefit that the sending of stats will never influence the application using the lib. If I hadn't done that, a slow internet connection could potentially slow down parts of the app.

Records are saved in a YAML file using our own configstore module.

Use cases of where it could be useful to have metrics

Currently thinking this module is great, but still don’t get how can I apply it to my own modules