libusermetrics: MetricManagerIncrementToday.cpp

libusermetrics

MetricManagerIncrementToday.cpp

A simple example of a metric that doesn't worry about updating history, and just increments a single value in response to an action. This is for apps that can simply increment by a fixed amount.

#include <libusermetricsinput/MetricManager.h>
#include <QtCore/QCoreApplication>
using namespace UserMetricsInput;
int main(int argc, char *argv[]) {
QCoreApplication application(argc, argv);
// We start with a manager object
MetricManagerPtr manager(MetricManager::getInstance());
// You can hold onto this shared pointer for as long as you want
MetricPtr metric(
manager->add(
MetricParameters("photo-app-photos").formatString(
"<b>%1</b> photos taken today").emptyDataString(
"No photos taken today").textDomain(APP_ID)));
// The default parameters for increment cause it to be incremented by 1.0,
// for the current user.
metric->increment();
return 0;
}
UserMetricsInput
The user metrics input library namespace.
Definition: Metric.h:29
UserMetricsInput::MetricParameters
Definition: MetricManager.h:41
UserMetricsInput::MetricPtr
QSharedPointer< Metric > MetricPtr
Definition: Metric.h:31
UserMetricsInput::MetricManager::getInstance
static MetricManager * getInstance()
Gets a new instance of the MetricManager.
MetricManager.h
UserMetricsInput::MetricManagerPtr
QScopedPointer< MetricManager > MetricManagerPtr
Shared pointer for the MetricManager.
Definition: MetricManager.h:34