Was this helpful?

See all application entities

Events are typically used for event logging in your application. For example, they could be used to log error messages that a system administrator might review at a later time. The event mechanism is optimized to handle large numbers of events, so it is an ideal mechanism for logging in your application.

You can link events to specific users, groups, or custom-defined categories. When created with these links, events offer a powerful tool for running highly targeted, custom reports.

Events are also the primary way to store custom counter data for analytics. See Counters (below) for further details.

Note: Although not shown in the API examples below, you need to provide a valid access token with each API call. See Authenticating users and application clients for details.

Using the API Services BaaS, you can create an event.

Creating a new event

Use the POST method to create a new event in the events collection.

Request URI

POST /{org_id}/{app_id}/events {request body}

Parameters

Parameter Description
arg uuid|string org_id Organization UUID or organization name
arg uuid|string app_id Application UUID or application name
request body

One or more sets of event properties. You must provide a timestamp property, but if you set it to 0 it is assigned by the system.

{
  "timestamp":0,
  "category" : "advertising",
  "counters" : {
    "ad_clicks" : 5
  }
}

Example - Request

curl -X POST "https://api.usergrid.com/my-org/my-app/events" -d '{"timestamp":0, "category" : "advertising", "counters" : {"ad_clicks" : 5}}'

The example assumes use of the JavaScript (HTML5) SDK.

var options = {
    method:'POST',
    endpoint:'events',
    body:{timestamp:0, category:'advertising', counters:{ad_clicks : 5}}
};
client.request(options, function (err, data) {
    if (err) {
        //error
    } else {
        //success - data will contain raw results from API call
    }
});

The example assumes use of the Ruby SDK.

app = Usergrid::Application.new 'https://api.usergrid.com/my-org/my-app/'
result = app.create_event timestamp: '0', category: 'advertising', counters: { ad_clicks: 5 }
mynewevent = result.entity   

The example assumes use of the Node.js module.

var options = {
    method:'POST',
    endpoint:'events',
    body:{timestamp:0, category:'advertising', counters:{ad_clicks : 5}}
};
client.request(options, function (err, data) {
    if (err) {
        //error
    } else {
        //success - data will contain raw results from API call
    }
});

Example - Response

{
      "action": "post",
      "application": "7fb8d891-477d-11e1-b2bd-22000a1c4e22",
      "params": {},
      "path": "/events",
      "uri": "https://api.usergrid.com/22000a1c4e22-7fb8d891-477d-11e1-b2bd/7fb8d891-477d-11e1-b2bd-22000a1c4e22/events",
      "entities": [
        {
          "uuid": "ce07ea3c-68b5-11e1-a586-9227e40e3559",
          "type": "event",
          "created": 1331166585282,
          "modified": 1331166585282,
          "counters": {
            "ad_clicks": 5
          },
          "metadata": {
            "path": "/events/ce07ea3c-68b5-11e1-a586-9227e40e3559"
          },
          "timestamp": 1331166585282
        }
      ],
      "timestamp": 1331166585018,
      "duration": 919,
      "organization": "my-org",
      "applicationName": "my-app"
}

Categorizing events

As mentioned previously, you can link an event to a user or a group. This enables you to categorize and qualify event data for use in tracking and analysis. For example, linking events to users and groups, enables you to track how often people use a feature. Not only can you determine the total number of users that used the feature, but also which groups contain users that made the most use of the feature. Or, you could provide a location with the event, so you could see how often a feature was used by people in San Francisco versus Los Angeles.

Comments

If I have registered many event app_invoke.user.1, app_invoke.user.2, ... ... app_invoke.user.245
how I retreive individual users invoke app daily count ?
I want to know my users app invoke daily count.

Hi Taeho

You will do a time series GET on the counters endpoint in this format:

GET /<your-org>/<your-app>/counters?start_time=<UTC timestamp>&end_time=<UTC timestamp>&resolution=day&counter=<counter name>

Add new comment

Provide your email address if you wish to be contacted offline about your comment.
We will not display your email address as part of your comment.

We'd love your feedback and perspective! Please be as specific as possible.
Type the characters you see in this picture. (verify using audio)

Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.