AnalyticsEvents

analytics. AnalyticsEvents

new AnalyticsEvents()

Source:
See:

Analytics events class used to request analytics events data from Web API.

Extends

Methods

get(reqnon-null) → {Promise}

Source:
Inherited From:

Loads the analytics data and returns them as an object from the promise. Two parallel requests are made against the analytics api. One for getting only the metaData and one for getting the actual data. This is for caching purposes, as in many situations the metaData request changes while the data one will be the same and thus have the same response. This methods takes care of adding the default extra parameters to both requests.

Example
const req = new d2.analytics.request()
 .addDataDimension(['Uvn6LCg7dVU','OdiHJayrsKo'])
 .addPeriodDimension('LAST_4_QUARTERS')
 .addOrgUnitDimension(['lc3eMKXaEfw','PMa2VCrupOd']);

d2.analytics.aggregate
 .get(req)
 .then(analyticsData => console.log('Analytics data', analyticsData))

// { metaData: { ... }, rows: [ ... ], headers: [ ... ], height: 0, width: 0 }
Parameters:
Name Type Description
req AnalyticsRequest

Analytics request object with the request details

Returns:

Promise that resolves with the analytics data and metaData from the api.

Type
Promise

getAggregate(reqnon-null) → {Promise}

Source:
Example
const req = new d2.analytics.request()
 .withProgram('eBAyeGv0exc')
 .addDataDimension(['Uvn6LCg7dVU','OdiHJayrsKo'])
 .addPeriodDimension('LAST_4_QUARTERS')
 .addOrgUnitDimension(['lc3eMKXaEfw','PMa2VCrupOd'])
 .addOrgUnitFilter('O6uvpzGd5pu')
 .withStartDate('2017-10-01')
 .withEndDate('2017-10-31');

 d2.analytics.events.getAggregate(req)
 .then(console.log);
Parameters:
Name Type Description
req AnalyticsRequest

Request object

Returns:

Promise that resolves with the analytics aggregate data from the api.

Type
Promise

getCluster(reqnon-null) → {Promise}

Source:
Example
const req = new d2.analytics.request()
 .withProgram('eBAyeGv0exc')
 .addDataDimension(['Uvn6LCg7dVU','OdiHJayrsKo'])
 .addPeriodDimension('LAST_4_QUARTERS')
 .addOrgUnitDimension(['lc3eMKXaEfw','PMa2VCrupOd'])
 .addOrgUnitFilter('O6uvpzGd5pu')
 .withStartDate('2017-10-01')
 .withEndDate('2017-10-31')
 .withClusterSize(100000)
 .withBbox('-13.2682125,7.3721619,-10.4261178,9.904012');

 d2.analytics.events.getCluster(req)
 .then(console.log);
Parameters:
Name Type Description
req AnalyticsRequest

Request object Must contain clusterSize and bbox parameters.

Returns:

Promise that resolves with the analytics cluster data from the api.

Type
Promise

getCount(reqnon-null) → {Promise}

Source:
Example
const req = new d2.analytics.request()
 .withProgram('eBAyeGv0exc')
 .addDataDimension(['Uvn6LCg7dVU','OdiHJayrsKo'])
 .addPeriodDimension('LAST_4_QUARTERS')
 .addOrgUnitDimension(['lc3eMKXaEfw','PMa2VCrupOd'])
 .addOrgUnitFilter('O6uvpzGd5pu')
 .withStartDate('2017-10-01')
 .withEndDate('2017-10-31');

 d2.analytics.events.getCount(req)
 .then(console.log);
Parameters:
Name Type Description
req AnalyticsRequest

Request object

Returns:

Promise that resolves with the analytics count data from the api.

Type
Promise

getQuery(reqnon-null) → {Promise}

Source:
Example
const req = new d2.analytics.request()
 .withProgram('eBAyeGv0exc')
 .addDataDimension(['Uvn6LCg7dVU','OdiHJayrsKo'])
 .addPeriodDimension('LAST_4_QUARTERS')
 .addOrgUnitDimension(['lc3eMKXaEfw','PMa2VCrupOd'])
 .addOrgUnitFilter('O6uvpzGd5pu')
 .withStartDate('2017-10-01')
 .withEndDate('2017-10-31');

 d2.analytics.events.getQuery(req)
 .then(console.log);
Parameters:
Name Type Description
req AnalyticsRequest

Request object

Returns:

Promise that resolves with the analytics query data from the api.

Type
Promise