Analytics

The Analytics tab on each system is used to display the actions of users on that particular system.

Scope

The scope component is a part of every analytics query. It has a special shape we’ll outline here:

Platform scope is the largest scope. It covers every resource contained by a platform instance, regardless of the developer.
The section looks like:
{"platform":"adminEmailHere"}

The second largest scope is the Organization Scope. When a developer registers, they provide an organization they work with. This scope uses that information to find every developer and their resources associated with that organization:
{"organization":"orgName"}

The Developer scope is the next largest scope. Using it focuses the analytics reporting to systems owned by that developer:
{"developer":"developerID"} //generally look something like aabfe1d20aeedaeae1cf9dc7a4a301. That ID can be acquired by calling /admin/userinfo on a logged in developer

The last is the system level, which is the smallest scope. A system is a grouping of collections, roles, users, an MQTT namespace, and code services.
{"system":"SystemKey"}

Storage

This endpoint is somewhat unique amongst the endpoints in that it doesn’t apply to all requests, and isn’t time series. It allows the developer to request the size of existing collections. (Note that Connect collections are not included)

Endpoint: /api/v/2/analytics/storage
      ?query = {"scope":{"platform":"platform email"}}

Count

The count endpoint returns a count of items in currently in collections.

Endpoint: /api/v/2/analytics/count

      ?query = {"scope":{"system":"d29bf3be0ac0d3faa1eebbedc6c401"},
      "filter":["login","logout"]  //the query is composed of the actions listed in the "About" page
      }

Event Totals

The totals of events for a given period of time.

Endpoint: /api/v/2/analytics/eventtotals
      ?query = {"scope":{"organization":"ClearBlade"},
      "filter":{
        "module":"messaging" //the module being requested. The choices are "messaging", "code","data","push" (if available), "message history", "users".
        "id": "mycollection", //the name of the resource, putting "*" implies all resources
        "action":"connection", //from the list of actions mentioned in about.
        "interval":500, //the interval you want the data to be grouped into in seconds.
        "limit":20, //the total number of event points you want to collect. this keeps the queries from being too large.
        "range": {"start":1439574288, //the start date in epoch time.
             "end":1439575288, //the end date in epoch time
             }
        }
      }

List of Events

The list of events for the duration. It uses the same filter object as event totals

Endpoint: /api/v/2/analytics/eventlist
      ?query = {"scope":{"developer":"e8c2eacb0a8ca68a8d859780b82c"}
            "filter":{
            "module":"code",
            "id":"*",
            "action":"execute",
            "interval":5000,
            "limit":2000,
            "range":{"start":1439574288,"end":1439584288}
            }
           }

User Events

A list of events delineated per user.

Endpoint: /api/v/2/analytics/userevents
      ?query = {"scope":{"system":"d29bf3be0ac0d3faa1eebbedc6c401"},
            "filter":{
            "users":["e8c2eacb0a8ca68a8d859780b82c"], //an array of userids
            "module":"data",//as with the events object
            "id":"fe96a6c00ab8c8aef7e88cb2f051", //here a collection id
            "action":"delete", //as with events
            "range":{"start":1439574288,"end":1439584288},//as with events
            "limit":2345, //see events
            }
           }