AnalyticsAggregate

analytics. AnalyticsAggregate

new AnalyticsAggregate()

Source:
See:

Analytics aggregate class used to request aggregate analytics 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

getDataValueSet(reqnon-null) → {Promise}

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

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

Request object

Returns:

Promise that resolves with the analytics data value set data from the API.

Type
Promise

getDebugSql(reqnon-null) → {Promise}

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

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

Request object

Returns:

Promise that resolves with the SQL statement used to query the database.

Type
Promise

getRawData(reqnon-null) → {Promise}

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

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

Request object

Returns:

Promise that resolves with the raw data from the API.

Type
Promise