libusermetrics
~20210319213227.1+ubports16.04~1.gbp0d7a6a_doc_pages_building_source Building the source

Getting libusermetrics

Libusermetrics is a project on Launchpad (https://launchpad.net/libusermetrics). To grab a copy use the command:

$ bzr branch lp:libusermetrics

Getting dependencies

To succesfully build libusermetrics there are a few packages required. The easiest way to get them is to use the packaging build dependencies:

$ sudo apt-get install devscripts equivs cmake
$ sudo mk-build-deps --install --tool "apt-get -y" --build-dep debian/control

Building libusermetrics

Libusermetrics is built using cmake. To make life simpler, you can use the included wrapper script:

$ ./build

This will run cmake in the directory

../${BRANCH_NAME}-build

You can also ask it to create an Eclipse project as follows:

$ ./build -e

The next step is to build the source and run the tests:

$ cd ../libusermetrics-build/make (-j8)
$ make check

Installing libusermetrics

To install libusermetrics just use the normal make install command:

$ make install

This will install the libusermetrics input / output libraries, storage service, and header files to the configured installation location (/usr/local by default). If you install to a non-standard location, keep in mind that you will probably need to properly set the PKG_CONFIG_PATH environment variable to allow other applications to build against libusermetrics, and LD_LIBRARY_PATH to allow applications to find the libusermetrics libraries at runtime.

  1. Install saucy if you haven' t done so already.
  2. Update your package list:
    sudo apt-get update
    
  3. Install libusermetrics output dev package (if you are planning to write a presentation application):
    sudo apt-get install libusermetricsoutput1-dev
    
  4. Install libusermetrics input dev package, (if you are planning to write a user metrics input source):
    sudo apt-get install libusermetricsoutput1-dev

Libusermetrics enables apps to locally store interesting numerical data for later presentation. For example in the Ubuntu Greeter "flower" infographic.

  • All data is stored locally in /var/usermetrics/.
  • No data is centrally collected via a web-serivice or otherwise, and no data is sent over the internet.

The only data that can be stored is numerical, for example "number of e-mails" or "number of pictures taken". No personally identifying information is stored using this library.

WARNING: This API should be considered private, and is only for use by first party applications at present. It may change or be removed at any time.

Getting and installing libusermetrics

Using pre-built packages

If you just want to try out libusermetrics, or write user metrics sources, then the easiest way is to use the pre-built packages.

Building and installing from source

If you are curious about libusermetrics's internals or intend to contribute to it, you should get the source and build it.

Getting involved

The best place to ask questions and discuss about libusermetrics is the #ubuntu-touch IRC channel on freenode.

The libusermetrics project is hosted on Launchpad: https://launchpad.net/libusermetrics

Please file bug reports at: http://bugs.launchpad.net/libusermetrics

Writing metric data sources

For simple metrics which only want to increment a counter, see the following examples:

For simple metrics which only want to update today's value, but cannot simply increment it, see the following examples:

For more sophisticated metrics, which wish to update the history of the metric, for example if the user has been offline for a week. Please see the following examples:

Writing a presentation application

To write a metric presentation application, there is a Qt API.