I would use the “events” collection, as documented under:

https://usergrid.apache.org/docs/counters-and-events/creating-and-incrementing-counters.html

So your POST would look like:

curl -X POST https://api.usergrid.com/your-org/your-app/events -d
'{"timestamp":<timestamp>, "counters" : {<counter_name>:<increment_value>}}'

Assuming you have a collection of images, you want to track "views" as
follows:

curl -X POST https://api.usergrid.com/your-org/your-app/events -d
'{"timestamp":<timestamp>, "counters" : {imageviews.<unique_image_name>:1}}'

GET total views across all images:

curl -X GET
https://api.usergrid.com/my-org/my-app/counters?counter=imageviews

GET views for a specific image say "xyz.jpg"

curl -X GET
https://api.usergrid.com/my-org/my-app/counters?counter=imageviews.xyz.jpg

Design your “counter hierarchy” based on types of metrics/aggregations
relevant to your application.

https://usergrid.apache.org/docs/counters-and-events/creating-and-incrementing-counters.html#using-counters-hierarchically

For example if you needed to track "image views by category", the strategy
may look like:

imageviews.<category_name>.<unique_image_name>


On Mon, Jun 6, 2016 at 10:45 AM, Thành Vũ Trung <[email protected]>
wrote:

> Thank you very much for your response.
> I have considered using counters. But I'm not clear how to using it...
> Ex: I want to tracking views count of image entity:
> Increase counters:
> curl -X POST https://api.usergrid.com/your-org/your-app/images -d
> '{"timestamp":0, "counters" : {"views":1}}'
> Get counters:
> curl -X GET https://api.usergrid.com/my-org/my-app/counters?counter= views
> If I do above example, I can't tracking views of *a entity. *If you have
> any experience in this case, pls help me to clear...
> Thank you for your support.
>
> On Mon, Jun 6, 2016 at 10:29 AM, Deshbir Singh Dugal <
> [email protected]> wrote:
>
>> Have considered using counters
>> https://usergrid.apache.org/docs/counters-and-events/events-and-counters.html
>> ?
>>
>>
>> On Mon, Jun 6, 2016 at 7:44 AM, Thành Vũ Trung <[email protected]>
>> wrote:
>>
>>> Hi Usergrid Communication,
>>> I'm making a social apps and using usergrid as back-end. I want to
>>> tracking views count of entity when user request it. Ex: views count of
>>> post, views count of image... Which is the best solution to implement it on
>>> usergrid back-end?
>>>
>>> Many thanks.
>>>
>>> --
>>> Thanh.
>>>
>>>
>>
>
>
> --
>
> *---------------------------------------------------------------------------------------------*
> *Thanh Vu*
>
> *Information Technology Engineer*
> *Mobile:* +84903298791
> *Skype:* v2t_nd |* Email:* maito:[email protected]
>
>

Reply via email to