Bug 982663: collect and transmit app usage metrics

I'd put this utility function at the end so it doesn't distract from the main point.