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?
  

Other properties that might be interesting to track here:

- `upload.progress.start`
- `upload.progress.finish`
- `upload.progress.count` (number of records uploaded)