Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top