gregglind / micropilot

Lightweight event monitoring and observation in Firefox addons.
http://gregglind.github.com/micropilot/
4 stars 2 forks source link

review for awesomeness? #1

Closed gregglind closed 11 years ago

gregglind commented 11 years ago

@bwinton, What do you think about this?

GL

bwinton commented 11 years ago

Random nit-ish comments: 1) I prefer using "self" to "that", since it seems more like the same object as this… 2) I think it's easier to read: if (unwatch_list === undefined) unwatch_list = Object.keys(this._watched); than: unwatch_list === undefined ? unwatch_list = Object.keys(this._watched) : unwatch_list; 3) You really need the API docs to appear between the Example and the FAQ, so that the question "Why have a studyid?" makes sense to people.

I like the example, although I'm slightly unclear as to what data will send where. Hopefully the API docs will tell me that, although a sample add-on which used this code to log some data would be a good idea, too.

gregglind commented 11 years ago

1) Alas, "self" is a module in Jetpack terms. For now, I am going to leave these as is, to avoid confusion.

2) Done.

3) What do you suggest for "API docs"?

bwinton commented 11 years ago

For #3, the word "studyid" occurs only once in the readme, so "Why have a studyid?" is unlikely to be a frequently asked question (at least, not at that point in the user's interaction with this codebase ;).

For API docs, I'm thinking something like this:

require("micropilot")

returns:

uu

EventStore

methods:

Micropilot

methods:

If you were extra cool, you could automatically extract this from the code itself, and put a link to the API docs in the readme. ;) Does that all make sense?

Later, Blake.

bwinton commented 11 years ago

I think this looks pretty good, although there are some outstanding questions/requests.

  1. What is a topic? (I think it's just an event that the addon can send to log something, but it's not explained.)
  2. Since the most common case will be to have:
  .then(function (mtp) {
    mtp.upload(UPLOAD_URL);
    mtp.stop()
  })

it would be nice to have that either be the default, or have a convenience method to do that.

  1. Oh, actually, that reminds me, UPLOAD_URL should be on the monitor, so that people can type let monitor = require('micropilot').Micropilot('tabsmonitor');, and still have access to it for the upload. (Although, if you add the convenience method, this is less of a problem. :)
  2. It would be good to be able to customize the watch function, so that I can pre-parse the data before it gets stored in the EventStore. (i.e. If I want to log the number of clicks on the "help" button, but don't want to have a record for each click, I could write something like:
  .preprocess(function (topic, data) {
    if (topic === 'button.click') {
      this.get('button.click', function (storedData) {
        storedData.count += data.count;
        this.record(storedData);
      });
    }
  })

(That's obviously not actually going to work for a number of reasons, but you get the idea, I hope. ;)

Thanks, Blake.

gregglind commented 11 years ago

It is now awesome.