1
votes

I have made an application in C++ and would like to know how to go about implementing a usage statistics system so that I may gather some data regarding how users use the program.

Eg. IP Address, Number of hours spent in application, and OS used.

In theory I know I can code this myself if I must, but I was wondering if there is a framework available to make this easier to do. Unfortunately I was unable to find anything on google.

3
What kind of application? Querying the OS can range from trivial to moderately tricky.moshbear
If you do that, be sure to ask the user if he accepts to send the collected data. I know I would stop using any software that sends data about my computer without my consent.ereOn
+1 to ereOn, and to add: collection without permission is almost certainly illegal in some jurisdictions.paxdiablo
@ereOn Thanks for the pointer, I most likely will mention this in the Terms and Agreements, and in addition to this I will make it something the user can un-check during the installation if he wishes to not have any data about him collected.JosephG
*most defenantly will add it to the terms and agreements and privacy policy. And now that I give it some thought, I will make the user have to check a box saying that they wish to send usage statistics, instead of having to un-check a box if they don't wish to send statisticsJosephG

3 Answers

1
votes

Though there is no any kind of such framework, you could reduce the work you have to do (in order to retrieve all these information) by using some approaches and techniques, which I tried describe below. Please, anybody feel free to correct me.

Let's summarise, what groups of information do we need to complete the task:

  • User Environment Information. I suggest you to look at Microsoft's WMI infrastructure, in particular to WMI classes: Desktop, File System, Networking, etc. Using this classes in your application can help you retrieve almost all kind of system information. But if you don't satisfy with this, see #2.
  • Application and System Performance. Under these terms I mean overall system performance, processor's count, processes running in OS, etc. To retrieve these data you can use the NtQuerySystemInformation function. With its help, you will get an access to detailed SystemProcessInformation, SystemProcessorPerformanceInformation (retrieves info about each processor) information, and much more.
  • User Related Information. It's hard to find a framework to do such things, so I suggest you simply start writing code, having in mind your requirements:
    • counting how many times each button was pressed, each text field was changes, etc.
    • measuring delay time between consecutive actions in some kind of predefined sequences (for example, if you have a settings gui form and you expect from the user to fill very fast all required text fields, so using a time delay measuments can give you an information if the user acted as we expected from him or delayed after TextBox2 for a 5 minutes).
    • anything that could be interested to you.

So, how you could implement the last item (User Related Information) requirements? As for me, I'd do something like folowing (some may seem very hard to implement or too pointless): - creating a kind of base Counter class and derive from it some controls (buttons, edits, etc). - using a windows hooks for mouse or keybord while getting a child handle (to recognize a control, for example). - using Callback class, which can do all "dirty" work (counting, measuring, performing additional actions).

You could store all this information either in a textfile or an SQLite database or there wherever you prefer.

1
votes

I would recommend taking a look at DeskMetrics. This StackOverflow post summarizes the issue.

1
votes

Building your own framework could take you months of development (apart from maintenance). With something like Trackerbird Software Analytics you can integrate a DLL with your app and start tracking in 30 minutes and you get all the cool real-time visualizations.

Disclaimer: I am affiliated with company.