new AppStatsObject()
This AppStatsObject class is responsible for handling the corresponding plugin js to interact with the native App Statistics
class. To set and get the properties, and to access the instance methods, corresponding JS methods are written under this class which
are used by the end user in application script.
Use the App Statistics object for creating, saving, and exporting statistics related to SDK framework usage.
Methods
addExportListener(successCallback, errorCallback, exportListenerCallback)
The exportStatusEvent delegate method reports on the status of the export sequence. If the export is still in progress, the method also reports the percent complete. Otherwise, it reports either export complete or export failed.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success Call back function name, called when the event is registered successfully |
errorCallback |
function | Default Error Call back function name |
exportListenerCallback |
function | function variable to hold the return value once the event is triggered |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - KMC_SUCCESS success call back
errorCallback - error message would contain the appropriate error description. Possible error objects are KmcRuntimeException, Exception.
Example
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
function exportListenerSuccessCallback(){
alert('exportListenerSuccessCallback');
}
appStats.addExportListener(function(exportSuccess){alert(JSON.stringify(exportSuccess));},function(exportError){alert(JSON.stringify(exportError));},exportListenerSuccessCallback);
addThresholdListener(successCallback, errorCallback, thresholdListenerCallback)
The sizeThreshold delegate method indicates that either the memory buffer or the file size has reached a threshold
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success Call back function name, called when the event is registered successfully |
errorCallback |
function | Default Error Call back function name |
thresholdListenerCallback |
function | function variable to hold the return value once the event is triggered |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - KMC_SUCCESS success call back
errorCallback - error message would contain the appropriate error description. Possible error objects are KmcRuntimeException, Exception.
Example
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
function thresholdListenerSuccessCallback(){
alert('thresholdListenerSuccessCallback');
}
appStats.addThresholdListener(function(thresholdSuccess){alert(JSON.stringify(thresholdSuccess));},function(thresholdError){alert(JSON.stringify(thresholdError));},thresholdListenerSuccessCallback);
addWriteToFileListener(successCallback, errorCallback, writeToFIleListenerCallback)
The writeFileStatusEvent delegate method reports on the status of writeToFile. If writeToFile is still in progress, it also reports the percent complete. Otherwise, it reports either write complete or write failed. In the case of failure, errorCode and errorMsg will contain a description of the specific failure.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success Call back function name, called when the event is registered successfully |
errorCallback |
function | Default Error Call back function name |
writeToFIleListenerCallback |
function | function variable to hold the return value once the event is triggered |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - KMC_SUCCESS success call back
errorCallback - error message would contain the appropriate error description. Possible error objects are KmcRuntimeException, Exception.
Example
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
function writeToFileListenerSuccessCallback(){
alert('writeToFileListenerSuccessCallback');
}
appStats.addWriteToFileListener(function(writeToFileSuccess){alert(JSON.stringify(writeToFileSuccess));},function(writeToFileError){alert(JSON.stringify(writeToFileError));},writeToFileListenerSuccessCallback);
beginSession(successCallback, errorCallback, parameters)
This method allows the application a means of recording an application-defined Session.
Each session is a grouping in which all subsequent appStats operations will be logged with the same "sessionKey", until the next endSession call.
This "sessionKey" is automatically generated while recording session.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
successCallback |
function | Default Success call back function name | ||||||
errorCallback |
function | Default Error call back function name | ||||||
parameters |
Object | parameters are the options that need to be set on the AppStatsObject.
Properties
|
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - KMC_SUCCESS if options are set successfully
errorCallback - error message would contain the appropriate error description. Possible error objects are Wrong Parameters, KmcRuntimeException & Exception.
Example
function successCallback(success){
alert(JSON.stringify(success));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
appStats.beginSession(successCallback,errorCallback,{category:"BillPay"});
endSession(successCallback, errorCallback, parameters)
This method tells appStats to stop the session.
Subsequent logging calls will not include a sessionKey in the database, until the next time beginSession is called again.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
successCallback |
function | Default Success call back function name | |||||||||
errorCallback |
function | Default Error call back function name | |||||||||
parameters |
Object | parameters are the options that need to be set on the AppStatsObject.
Properties
|
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - KMC_SUCCESS if options are set successfully
errorCallback - error message would contain the appropriate error description. Possible error objects are Wrong Parameters, KmcRuntimeException & Exception.
Example
function successCallback(success){
alert(JSON.stringify(success));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
appStats.endSession(successCallback,errorCallback,{success:false, description:" submission failed due to network issues"});
export(successCallback, errorCallback, parameters)
Use this asynchronous method to create a file containing the different statistics tables created by AppStats.\n\n
The library creates a file according to the export format specified (e.g. MSSQL, etc.). This will create a series of SQL insert statements, intended to populate a destination database with the AppStats data. The destination database must already exist with the schema provided; no "Create" statements are included in this export SQL dump. Note that exportFilePath is a full file path. The export data file is expected to be a .sql file name.\n\n
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success call back function name |
errorCallback |
function | Default Error call back function name |
parameters |
Object | file path and format as JSON Object. Valid format values are JSON, SQL. Ex : {filePath :"file path value", format : "JSON"} |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - success call back with JSON Object representing export status.
errorCallback - error message would contain the appropriate error description. Possible error objects are Wrong Parameters, KmcRuntimeException & Exception.
Example
function successCallback(success){
alert(JSON.stringify(success));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
appStats.export(successCallback,errorCallback,{filePath :"file path value", format : "JSON"});
getAppStatsOptions()
Method to get the properties of the AppStatsObject .
Returns:
'appStatsOptions' JSON Object containing the properties to be set to the AppStatsObject
Example
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
var appStatsOptions = appStats.getAppStatsOptions();
appStatsOptions should be like below {
deviceId:"",
fileSizeThreshold:2097152,
ramSizeThreshold:109000,
filePath:""
};
getOptions(successCallback, errorCallback)
Method to get the properties of the App Stats class.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success call back function name |
errorCallback |
function | Default Error call back function name. |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - JSONObject representing AppStatsObject Options. JSONObject structure can also be known from getAppStatsOptions() method.
errorCallback - error message would contain the appropriate error description. Possible error objects are JSONException, Exception.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
appStats.getAppStatsOptions(successCallback,errorCallback);
isRecording(successCallback, errorCallback)
Use the isRecording to determine whether or not AppStats recording is active. It is set true after you call the startRecord method, and off after you call stopRecord. Certain methods calls are illegal while recording is on.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success Call back function name, called when the event is registered successfully |
errorCallback |
function | Default Error Call back function name |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - success call back with TRUE or FALSE boolean
errorCallback - error message would contain the appropriate error description. Possible error object is Exception.
Example
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
appStats.isRecording(function(isRecordingSuccess){
alert(JSON.stringify(isRecordingSuccess));
},function(isRecordingError){
alert(JSON.stringify(isRecordingError));
});
logSessionEvent(successCallback, errorCallback, parameters)
Each Session event may represent a "sub-Session", or single operation which defines one step in a sequence of steps which collectively define a complete session.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
successCallback |
function | Default Success call back function name | |||||||||
errorCallback |
function | Default Error call back function name | |||||||||
parameters |
Object | parameters are the options that need to be set on the AppStatsObject.
Properties
|
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - KMC_SUCCESS if options are set successfully
errorCallback - error message would contain the appropriate error description. Possible error objects are Wrong Parameters, KmcRuntimeException & Exception.
Example
function successCallback(success){
alert(JSON.stringify(success));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
appStats.logSessionEvent(successCallback,errorCallback,{type:"Retake", response:"success"});
purge(successCallback, errorCallback)
Recording must be disabled before calling this method. The purge method does not delete the SQL file that was created by the export method. Your app is responsible for consuming and controlling the export data file.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success call back function name |
errorCallback |
function | Default Error call back function name |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - KMC_SUCCESS if purge done successfully.
errorCallback - error message would contain the appropriate error description. Possible error objects are JSONException, Exception.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
appStats.purge(successCallback,errorCallback);
removeExportListener(successCallback, errorCallback)
The export listener would be removed and no further events are received
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success Call back function name, called when the event is removed successfully |
errorCallback |
function | Default Error Call back function name |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - KMC_SUCCESS success call back
errorCallback - error message would contain the appropriate error description. Possible error objects are KmcRuntimeException, Exception.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
appStats.removeExportListener(successCallback,errorCallback);
removeThresholdListener(successCallback, errorCallback)
The threshold listener would be removed and no further events are received
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success Call back function name, called when the event is removed successfully |
errorCallback |
function | Default Error Call back function name |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - KMC_SUCCESS success call back
errorCallback - error message would contain the appropriate error description. Possible error objects are KmcRuntimeException, Exception.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
appStats.removeThresholdListener(successCallback,errorCallback);
removeWriteToFileListener(successCallback, errorCallback)
The write to file listener would be removed and no further events are received
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success Call back function name, called when the event is removed successfully |
errorCallback |
function | Default Error Call back function name |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - KMC_SUCCESS success call back
errorCallback - error message would contain the appropriate error description. Possible error objects are KmcRuntimeException, Exception.
Example
function successCallback(response){
alert(JSON.stringify(response));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
appStats.removeWriteToFileListener(successCallback,errorCallback);
setOptions(successCallback, errorCallback, parameters)
Method to set the properties of the App Stats class.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success call back function name |
errorCallback |
function | Default Error call back function name |
parameters |
Object | parameters are the options that need to be set on the AppStatsObject. see AppStatsObject#getAppStatsOptions for more understanding. |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - KMC_SUCCESS if options are set successfully
errorCallback - error message would contain the appropriate error description. Possible error objects are Wrong Parameters, KmcRuntimeException & Exception.
Example
function successCallback(success){
alert(JSON.stringify(success));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
var options = appStats.getAppStatsOptions();
// need to set deviceId from cordova device Plugin
options.deviceId = device.uuid;
appStats.setOptions(successCallback,errorCallback,options);
startRecord(successCallback, errorCallback)
Use this method to start recording statistics during normal library operations. This will set the isRecording property to true, and open the SQLite database.\n
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success call back function name |
errorCallback |
function | Default Error call back function name |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - KMC_SUCCESS if recording started successfully.
errorCallback - error message would contain the error description. Possible error objects are KmcRuntimeException, Exception.
Example
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
appStats.isRecording(function(isRecordingSuccess){
if(!isRecordingSuccess){
appStats.startRecord(function(startRecordSuccess){
alert(JSON.stringify(startRecordSuccess));
},function(startRecordError){
alert(JSON.stringify(startRecordError));
});
}
},function(isRecordingError){
alert(JSON.stringify(isRecordingError));
});
stopRecord(successCallback, errorCallback)
Use this method to stop recording. This will set the isRecording property to false, and close the SQLite database to ensure anything in memory is flushed to the file system.\n
This method is only valid if you previously started recording.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success call back function name |
errorCallback |
function | Default Error call back function name |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - KMC_SUCCESS if recording stopped successfully.
errorCallback - error message would contain the appropriate error description. Possible error objects are KmcRuntimeException, Exception.
Example
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
appStats.isRecording(function(isRecordingSuccess){
if(isRecordingSuccess){
appStats.stopRecord(function(stopRecordSuccess){
alert(JSON.stringify(stopRecordSuccess));
},function(stopRecordError){
alert(JSON.stringify(stopRecordError));
});
}
},function(isRecordingError){
alert(JSON.stringify(isRecordingError));
});
upgradeSchema(successCallback, errorCallback, parameters)
If a database open fails error call back is triggered with the error "invalid schema", then it is likely due to
attempting to open a database of an older schema. Issuing this call will update the database and close it again, to allow the caller to attempt opening again.
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success call back function name |
errorCallback |
function | Default Error call back function name |
parameters |
Object | the new file path of the schema is specified in the parameters. Ex : {filePath :"file path value"} |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback - KMC_SUCCESS success call back
errorCallback - error message would contain the appropriate error description. Possible error objects are Wrong Parameters, KmcRuntimeException & Exception.
Example
function successCallback(success){
alert(JSON.stringify(success));
}
function errorCallback(error){
alert(JSON.stringify(error));
}
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
appStats.upgradeSchema(successCallback,errorCallback,{filePath :"file path value"});
writeToFile(successCallback, errorCallback)
Use this asynchronous method from your thresholdReached delegate to periodically write the buffer to the database file. You may also call this method periodically while recording or after recording is turned off. This helps conserve memory. Writing AppStats data to memory improves performance.\n\n
If the database was closed, this method opens it first for writing, then closes it when finished. Else if open, the method keeps it open.\n\n
After the write is complete, the AppStats internal buffer is erased, and the filesize property may or may not increase, but reflects the size of the database file after the write completes.\n\n
Parameters:
Name | Type | Description |
---|---|---|
successCallback |
function | Default Success call back function name |
errorCallback |
function | Default Error call back function name |
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions
successCallback : KMC_SUCCESS if the write to file was started successfully
errorCallback : error message would contain the appropriate error description. Possible error objects are KmcRuntimeException, Exception.
Example
var appStats = kfxCordova.kfxUtilities.createAppStatsObject();
appStats.isRecording(function(isRecordingSuccess){
if(isRecordingSuccess){
appStats.stopRecord(function(stopRecordSuccess){
appStats.writeToFile(function(writeToFileSuccess){
alert(JSON.stringify(writeToFileSuccess));
},function(writeToFileError){
alert(JSON.stringify(writeToFileError));
});
},function(stopRecordError){
alert(JSON.stringify(stopRecordError));
});
}
},function(isRecordingError){
alert(JSON.stringify(isRecordingError));
});