New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@iapps/function-analytics

Package Overview
Dependencies
Maintainers
10
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iapps/function-analytics

Produce universal library with webpack and es6

  • 1.0.0-beta.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13
increased by116.67%
Maintainers
10
Weekly downloads
 
Created
Source

Fn

Build Status Greenkeeper badge Maintainability Test Coverage Commitizen friendly

Function Analytics Library

Library to aid in the development of functions. Built with best practices in mind from the experience on function maintenance. This is to make it easy for developers to concentrate on the business logic of their functions while also considering the best way to perform operations with out of the box performance execution strategy.

Features

  • Fetching data for analytics.
  • Fetching DHIS Identifiable objects.
  • Perform execution of functions with optimization

Quickstart Guide

Install

Start with adding d2 to your project:

npm install @iapps/function-analytics

After installing you will be able to import the library into your project by using the files in the lib folder:

// Using ES2015 imports
import { Fn } from '@iapps/function-analytics';

// Using CommonJS imports
var Fn = require('@iapps/function-analytics').Fn;

Initializing the library

To be able to use d2 you will first need to initialise the library. This is required to let the library know where it should load its data from.

Fn.init({
  baseUrl: 'api_url_to_dhis_server',
  username: 'username', //Optional if in a DHIS app
  pasword: 'password' //Optional if in a DHIS app
});

Fetch analytics

You can fetch analytic with a few lines of code

new Fn.Analytics()
  .setData('dx')
  .setOrgUnit('ou')
  .setPeriod('pe')
  .postProcess(function(analyticsResult) {
    // This adds post processing after fetching is done
    return analyticsResult;
  })
  .get()
  .progress(function(value) {
    // Do something with the progress value
  })
  .then(function(analyticsResult) {
    //The result after fetching and processing with the post process callback
  });

Dependency

You can put together dependencies if calls depend on one another

var orgunit = new Fn.IdentifiableObject('organisationUnits'); // Example of an organisation fetcher

orgunit.where('id', 'in', ['Rp268JB6Ne4', 'Rp268JB6Ne2']);
//Declare business process to run after orgunit results
var bussinessAfterOrgunitProcess = (orgUnitResult, analytics) => {
  // Adds dependency
  let ous = orgUnitResult.organisationUnits
    .map(organisationUnit => {
      return organisationUnit.id;
    })
    .join(';');

  analytics.setPeriod('2016').setOrgUnit(ous);
};
var analytics = new Fn.Analytics();

analytics.preProcess(new Fn.Dependency(orgunit, bussinessAfterOrgunitProcess));
analytics.get().then(results => {});

Multiple Processing

You can invoke multiple processes

var orgunit = new Fn.IdentifiableObject('organisationUnits');

orgunit.where('id', 'in', ['Rp268JB6Ne4', 'Rp268JB6Ne2']);

var analytics = new Fn.Analytics();

analytics.setPeriod('2016').setOrgUnit('Rp268JB6Ne4;Rp268JB6Ne2');

var multiProcesses = Fn.all([orgunit, analytics]);
multiProcesses.postProcess(res => {
  //res[0] is from orgunit
  //res[1] is from analytics
  return [res[1], res[0]];
});
multiProcesses.get().then(results => {});

For detailed documentation please visit the documentation page.

Keywords

FAQs

Package last updated on 26 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc