PREV CLASS NEXT CLASS FRAMES (opens in new window)
Class WL.Analytics
WL.Analytics
- Description:
The IBM® Worklight® Analytics API provides the ability to enable, disable, and log analytics data.
The default settings is enabled, meaning data passed to the WL.Analytics.log API call by both the framework code and your code are persisted. We can explicitly enable or disable persistent data capture by calling
WL.Analytics.enable orWL.Analytics.disable.Starting in IBM® Worklight® V6.2.0, the enabling of Analytics capture by declaring it in
initOptions.js is deprecated. For backward compatibility, when Analytics is enabled usinginitOptions.js, the eventWL/ANALYTICS/READY
is triggered. It is no longer necessary to wait for this event in order to use theWL.Analytics API.Starting with IBM® Worklight® V6.2.0, the
WL.Analytics API is available for use with no extra configuration or feature enablement required. Persistent collection ofWL.Analytics.log data is enabled by default, and sent to the IBM® Worklight® server by default on successful network init.Note: the data collected via the
WL.Analytics API, after sending it to the IBM Worklight server, is made available in the Operational Analytics engine console on the "Search" tab, and only the "Search" tab.
Method Summary Method Attributes Method Name and Description disable()
Turns off the capture of analytics data.
enable()
Turns on the capture of analytics data.
log(message, name)
Logs a message with additional contextual information.
restart()
send()
Send any analytics data collected up to this point to the IBM Worklight server.
state()
Get the current state of
WL.Analytics.disable
{Promise} disable()
Turns off the capture of analytics data.
- Returns:
- {Promise} Resolved with no parameters, rejected with an error object.
- Example:
WL.Analytics.disable() .then(function () { //Capture of analytics data is fully disabled. }) .fail(function (errObj) { //errObj.src = function that failed //errObj.res = error message });
enable
{Promise} enable()
Turns on the capture of analytics data.
The
Promise returned by enable must be resolved prior to anyWL.Analytics
API call.Starting with IBM® Worklight® V6.2.0,
WL.Analytics.enable no longer takes any parameter arguments and it is no longer necessary to wait for the returnedPromise to be resolved to continue using theWL.Analytics API.
- Returns:
- {Promise} Resolved with no parameters, rejected with an error object.
- Example:
WL.Analytics.enable() .then(function () { //Capture of analytics data is fully enabled. }) .fail(function (errObj) { //errObj.src = function that failed //errObj.res = error message });
log
{Promise} log(message, name)
Logs a message with additional contextual information.
Log messages are automatically added to a persistent queue. The accumulated data is automatically sent to IBM® Worklight® server on the next successful network init or explicit
WL.Analytics.send function call.
- Parameters:
- {string or object} message Optional - The message to log.
- {string} name Optional - The name of the message to log.
- Returns:
- {Promise} Resolved with no parameters, rejected with an error object.
- Example:
WL.Analytics.log('my record'); // or WL.Analytics.log({data: [1,2,3]}); // or WL.Analytics.log({data: [1,2,3]}, 'MyData');
restart
{Promise} restart()
- Returns:
- {Promise} Resolved with no parameters, rejected with an error object.
- Deprecated:
- since version 6.2. WL.Analytics.restart is now a NOP.
- Example:
WL.Analytics.restart() .then(function () { //nop }) .fail(function (errObj) { //errObj.src = function that failed //errObj.res = error message });
send
{Promise} send()
Send any analytics data collected up to this point to the IBM Worklight server.
- Returns:
- {Promise} Resolved with success status, rejected with an error message.
state
{Promise} state()
Get the current state of
WL.Analytics.The state object is kept by
WL.Analytics and contains the following key:
- enabled (boolean) - Value is true if capture is enabled, false otherwise.
Changing the state object that is returned does not affect the state object that is kept internally. WL.Analytics.state() .then(function (state) { // {enabled: true} }) .fail(function (errObj) { //errObj.src = function that failed //errObj.res = error message });
- Returns:
- {Promise} Resolved with state object parameters, rejected with an error object.
© Copyright IBM Corp. 2011, 2016.