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?
  

These might be redundant, you're already tracking them with `UPLOAD_FAILED` and `UPLOAD_SUCCESS`, and `type: 'carelink'`...