MetricManagerIncrementTodayCAPI.c

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 do not already have a way of knowing the current value.

    #include<libusermetricsinput/usermetricsinput.h>

    intmain(intargc,char*argv[]){
    //Westartwithamanagerobject
    UserMetricsInputMetricManagermetricManager=
    usermetricsinput_metricmanager_new();

    //Createaparametersobject
    UserMetricsInputMetricParametersparameters=
    usermetricsinput_metricparameters_new("photo-app-photos");

    //Setitsattributes
    usermetricsinput_metricparameters_set_format_string(parameters,
    "<b>%1</b>photostakentoday");
    usermetricsinput_metricparameters_set_empty_data_string(parameters,
    "Nophotostoday");
    usermetricsinput_metricparameters_set_text_domain(parameters,APP_ID);

    //Youcanholdontothissharedobjectforaslongasyouwant
    UserMetricsInputMetricmetric=usermetricsinput_metricmanager_add(
    metricManager,parameters);

    //Remembertofreetheparametersobjectafteruse
    usermetricsinput_metricparameters_delete(parameters);

    //Providingablankusernamestringwillusethecurrent
    //useraccordingtotheUSERenvironmentvariable.
    usermetricsinput_metric_increment(metric,1,"");

    //Nowwe'redonewiththemanager
    usermetricsinput_metricmanager_delete(metricManager);

    return0;
    }