Jhbate/analytics

@jebeck @nicolashery 

addition of metrics calls and re-introduction of server logging of errors. I have updated the tests to check that we are actually calling these methods on the api also.

only query I have at this stage is on the device detection - it was very spammy as we keep trying to find devices so I added a check that we have one before logging to metrics for it. Now thinking about it it may still be very spammy once we have one as it will keep looking for more I assume. Thoughts - comments - suggestions?
  

Yeah, this is a tricky one. At this stage, I would recommend leaving it out. It's going to generate more "noise" than "signal" (it'll fire off every 500ms when a device is plugged in).

We don't have an easy way yet to tell if a *new* device was plugged in, maybe one day we'll do and we can add it back, but at the moment I wouldn't recommend it...

What do you think?