GlobalAnalytics Library

These functions provide access to analytics across Basic Users.

As with Analytics Library, the bucketed functions (GlobalAnalytics.bin_by...) produce statistics where date is grouped into "buckets". Buckets are automatically selected depending on the DateRange size:

  • DateRange of less than a day: minute buckets
  • DateRange of a day to 2 months: hour buckets
  • DateRange of 2 months to 1 year: day buckets
  • DateRange of 1 year to 10 year: week buckets
  • Otherwise: month buckets

 

Import


To use this library and its functions, you must use the import line at the beginning of your Base Python code.

import GlobalAnalytics

 

Functions

 

GlobalAnalytics.events_by_stream

Usage: GlobalAnalytics.events_by_stream(stream_namefilters=None, date_range=None, limit=None, sort=None)

Returns the events in the specified stream, subject to filters, date_range, limit, and sort.

  • Credit cost: 1
  • Parameters:
    • stream_namestr name of stream from which to retrieve data
    • filtersFilter
    • date_rangeDateRange
    • limitint maximum number of values to return
    • sortlist|tuple pair of strings defining tag to sort by and sort order ('ASC' or 'DESC')
  • Returns: list List of dict of the form:
    [
    {
        "observed_at": "2015-04-11T21:36:53.832111+00:00",
        "stream_id": 4041905582898064089,
        "event_data": {
            "action": "Help Request",
            "sensor_id": "Kiosk_3",
            "type": "Kiosk"
        }
    },
    …
    ]




GlobalAnalytics.bin_by_time

Usage: GlobalAnalytics.bin_by_time(tag_namedate_rangepopulation=None)

Returns statistics for the population defined by population_time_series_filters and population_last_value_filters, for tag_name data filtered by filters. Tag name data is from the period specified by date_range and is bucketed based on the date_range window.

  • Credit cost: 1
  • Parameters:
    • tag_namestr tag name, including stream name (eg. "raw.score")
    • date_rangeDateRange
    • populationPopulationFilter
  • Returns: list List of dicts of the form:
    [
    {
        "observed_at": "2015-04-11T21:36:53.832111+00:00",
        "avg": 123,
        "min": 123,
        "max": 123,
        "count": 123
    },
    …
    ]




GlobalAnalytics.bin_by_value

Usage: GlobalAnalytics.bin_by_value(tag_namepopulation=None)

Returns the distribution of the last value per user of field tag_name, for all users in the population defined by population_time_series_filters and population_last_value_filters.

For each distinct value, the number of occurrences, its percentage of the whole, and its rank are returned. Note that ranks can occur multiple times in the case of ties.

  • Credit cost: 1
  • Parameters:
    • tag_namestr tag name, including stream name (eg. "raw.score")
    • populationPopulationFilter
  • Returns: list List of dicts of the form:
    [
    {
        "count": 30,
        "percent": 90.9090909090909,
        "rank": 1,
        "value": 5
    },
    ...
    ]




GlobalAnalytics.list_users

Usage: GlobalAnalytics.list_users(population=None)

Returns a list of users in the population defined by a population filter.

  • Credit cost: 1
  • Parameters:
    • populationPopulationFilter
  • Returns: list List of dicts of the form:
    [{u'login_id': u'user1', u'user': 352769716122759168L}, {u'login_id': u'user2', u'user': 352771148062351360L}]



GlobalAnalytics.check_user_exists

Usage: GlobalAnalytics.check_user_exists(login_id)

Returns True if the API Basic User already exists, False otherwise.

  • Credit cost: 1
  • Parameters:
    • login_idstr username of the user that is being checked
  • Returns: bool



Sample Code

 

import GlobalAnalytics
import Filter
import DateRange

x = GlobalAnalytics.events_by_stream(stream_name='raw', limit=10)
y = GlobalAnalytics.events_by_stream('processed', Filter.string_tag('raw.myoutkey').equal_to('hello world'), DateRange.this_hour(), 10, ('observed_at', 'ASC'))
Have more questions? Submit a request

0 Comments

Article is closed for comments.