Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Analytics JavaScript API exposes WSO2 DAS analytics functionalities as JavaScript functions. You can use this JavaScript this JavaScript API in your Web apps to perform analytics operations when creating when creating Web apps or Dashboard gadgets. You  You can find the JavaScript API in the <DAS_HOME>/repository/deployment/server/jaggeryapps/portal/js carbonjs carbon-analytics.js file. This can be exposed as follows: <DAS_URL>:<DAS_PORT>/portal/js/carbon-analytics.js

Table of Contents
maxLevel3

Creating the analytics client for the JS API

You need to first create a client to use the JavaScript API. Create Create an instance of the the AnalyticsClient module  module as follows. 

NoteImport
  1.  Import jquery.js
first to use
  1.  and carbon-analytics.js.
  2. Create the connection object with the following details.

    Code Block
    languagejava
    var client = new AnalyticsClient().init();
    
    
default
  1. var username
:
  1.  = "admin";
    
default
  1. var password
:
  1.  = "admin";
    var server_url 
:
  1. = "https://localhost:9443/portal
/controllers
  1. /apis/analytics
.jag
  1. ";

Above constructor creates an object of the AnalyticsClient module with default parameters. If you want to create an analytics client with your own parameters, use the below constructor.

Code Block
languagejava
var client = new AnalyticsClient().init(username, password, server_url);
Note

Currently due to a limitation, client applications should be deployed in the same domain as the Dashboard server. i.e - DAS_HOME/repository/deployment/server/webapps

Success callback function and error callback functions of the JS API

All methods of the Analytics JS API have a success function and an error function as callbacks representing successful invocations and erroneous invocations. Success callback has one argument which will contain the response it returns if the invocation is successful. It represents a JSON String of the following format.

Code Block
languagetext
{
  "status" : <RESPONSE_STATUS>,
  "message" : <RESPONSE_DATA_OR_MESSAGE>
}

Error callback has one argument which will contain an error message if the invocation is failed. Its JSON representation is as follows.

Code Block
languagetext
{
  "status" : <RESPONSE_STATUS>,
  "message" : <ERROR_MESSAGE>
}

The methods exposed by the Analytics JavaScript API are as follows.

Child pages (Children Display)