Atalasoft MobileImage API Reference
Classes | Public Member Functions | Static Public Member Functions | List of all members
com.kofax.kmc.kut.utilities.appstats.AppStatistics Class Reference

Use the AppStatistics class for creating, saving, and exporting statistics related to SDK framework usage. More...

Classes

enum  AppStatsExportFormat
 Indicates the export format desired when calling the export method. More...
 
enum  ExportStatusEvent
 
enum  ThresholdType
 

Public Member Functions

int getRamSizeThreshold ()
 
void setRamSizeThreshold (int ramSizeThreshold)
 
int getFileSizeThreshold ()
 
void setFileSizeThreshold (int fileSizeThreshold)
 
long getRamSize ()
 Current size of available RAM. More...
 
long getFileSize () throws FileNotFoundException
 
String getFileName ()
 Returns the filename of the datastore where AppStats events are written. More...
 
String getDeviceId ()
 Returns the current DeviceID which is recorded as a field in the Environment table. More...
 
void setDeviceId (String userDeviceID)
 Sets the current DeviceID which is recorded as a field in the Environment table. More...
 
ListenerCallbackThreadType getListenerCallbackThreadType ()
 Get the ListenerCallbackThreadType. More...
 
void setListenerCallbackThreadType (ListenerCallbackThreadType listenerCallbackThreadType)
 Set the ListenerCallbackThreadType. More...
 
synchronized void initAppStats (String name)
 Initialize AppStats with datastore name. More...
 
synchronized ErrorInfo startRecord ()
 Start recording app statistics, or continues recording. More...
 
synchronized ErrorInfo stopRecord ()
 Stop recording data while retaining data that has been collected. More...
 
synchronized ErrorInfo writeToFile ()
 Writes the in-memory statistics buffer to the AppStats database. More...
 
void registerExportHandler (AppStatsDsExportHandler handler)
 The export method creates a SQL dump or other file format of the internal data store. More...
 
synchronized ErrorInfo export (String exportFilePath, AppStatsExportFormat format)
 The export method creates a SQL dump or other file of the internal data store. More...
 
synchronized ErrorInfo purge ()
 The purge method erases the AppStats memory buffer and the AppStats recording database file. More...
 
boolean isRecording ()
 Returns the status, isRecording is set to true when startRecording is. More...
 
synchronized void beginSession (String sessionKey, String category)
 This method tells appStats to start a "session". More...
 
synchronized void logSessionEvent (AppStatsSessionEvent sessionEvent)
 This method allows the application a means of recording an application-defined Session event. More...
 
synchronized void endSession (boolean success, String description)
 This method tells appStats to end a "session". More...
 
synchronized void upgradeSchema (String datastoreName)
 Upgrade existing datastore from earlier AppStats release to current schema. More...
 
void addAppStatsWriteFileListener (AppStatsWriteFileListener listener)
 Registers an event listener for the writeToFile method. More...
 
void addAppStatsExportListener (AppStatsExportListener listener)
 Registers an event listener for the export method. More...
 
void addAppThresholdListener (AppstatsThresholdReachedListener listener)
 Registers a threshold listener. More...
 
void removeAppStatsExportListener (AppStatsExportListener listener)
 Removes an event listener for the export method. More...
 
void removeAppStatsThresholdListener (AppstatsThresholdReachedListener listener)
 Removes an event listener for the threshold detection. More...
 
void removeAppStatsWriteFileListener (AppStatsWriteFileListener listener)
 Removes an event listener for the writeToFile method. More...
 

Static Public Member Functions

static AppStatistics getInstance ()
 

Detailed Description

Use the AppStatistics class for creating, saving, and exporting statistics related to SDK framework usage.

Member Function Documentation

void com.kofax.kmc.kut.utilities.appstats.AppStatistics.addAppStatsExportListener ( AppStatsExportListener  listener)
inline

Registers an event listener for the export method.

This method registers an event listener for the export method, so the application can be notified of progress and completion of the export operation.

void com.kofax.kmc.kut.utilities.appstats.AppStatistics.addAppStatsWriteFileListener ( AppStatsWriteFileListener  listener)
inline

Registers an event listener for the writeToFile method.

This method registers an event listener for the writeToFile method, so the application can be notified of progress and completion of the writeToFile operation.

void com.kofax.kmc.kut.utilities.appstats.AppStatistics.addAppThresholdListener ( AppstatsThresholdReachedListener  listener)
inline

Registers a threshold listener.

This method registers an event listener for appStats reaching threshold levels, so that each time memory or storage crosses the next threshold level in terms of storage space, this listener will be called.

synchronized void com.kofax.kmc.kut.utilities.appstats.AppStatistics.beginSession ( String  sessionKey,
String  category 
)
inline

This method tells appStats to start a "session".

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.

Parameters
sessionKeyis an application-defined string, which will be a meaningful identifier for this session. This same sessionKey should also be passed to any server-side calls, such as RTTI, so stats collected on the server can reflect the same sessionKey.
categoryis an application-defined string, representing the type of session this represents. Examples of typical categories include CheckDeposit, BillPay, etc.
synchronized void com.kofax.kmc.kut.utilities.appstats.AppStatistics.endSession ( boolean  success,
String  description 
)
inline

This method tells appStats to end a "session".

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
successshould be set to true if the overall operation for this session, such as a check deposit, succeeded. Only the application can know overall success or not of a session.
descriptionmay be used to include helpful logging information, in case the session did not succeed.
synchronized ErrorInfo com.kofax.kmc.kut.utilities.appstats.AppStatistics.export ( String  exportFilePath,
AppStatsExportFormat  format 
)
inline

The export method creates a SQL dump or other file of the internal data store.

The contents of the database will be written to a sql dump file

String com.kofax.kmc.kut.utilities.appstats.AppStatistics.getDeviceId ( )
inline

Returns the current DeviceID which is recorded as a field in the Environment table.

String com.kofax.kmc.kut.utilities.appstats.AppStatistics.getFileName ( )
inline

Returns the filename of the datastore where AppStats events are written.

The writeToFile method will store data in a file with this name in the directory: /data/data/application_package_name/databases.

Returns
AppStats database filename
long com.kofax.kmc.kut.utilities.appstats.AppStatistics.getFileSize ( ) throws FileNotFoundException
inline

The readonly fileSize variable is the current amount of flash memory used in the database. The database file was specified by the initAppStats method. After you call the purge method, this value is set to 0. The size of the file does not grow linearly, even after a few write to file calls, but this value gives you a relative size as statistical data is written to the data base.

Returns
Current flash storage usage
int com.kofax.kmc.kut.utilities.appstats.AppStatistics.getFileSizeThreshold ( )
inline

fileSizeThreshold is the size in bytes at which a warning will be issued to the application. The warning indicates the file size has reached the limit established by the application.

Returns
fileSizeThreshold
static AppStatistics com.kofax.kmc.kut.utilities.appstats.AppStatistics.getInstance ( )
inlinestatic

This method returns a singleton object of AppStatistics.

ListenerCallbackThreadType com.kofax.kmc.kut.utilities.appstats.AppStatistics.getListenerCallbackThreadType ( )
inline

Get the ListenerCallbackThreadType.

Returns
the thread type for asynchronous callbacks
long com.kofax.kmc.kut.utilities.appstats.AppStatistics.getRamSize ( )
inline

Current size of available RAM.

This readonly property keeps the current recording memory usage.

Returns
Current memory usage
int com.kofax.kmc.kut.utilities.appstats.AppStatistics.getRamSizeThreshold ( )
inline

Get the current ram threshold size

Returns
ramSizeThreshold
synchronized void com.kofax.kmc.kut.utilities.appstats.AppStatistics.initAppStats ( String  name)
inline

Initialize AppStats with datastore name.

This method is used to initialize and open the AppStats datastore.

Parameters
name- name of the datastore
boolean com.kofax.kmc.kut.utilities.appstats.AppStatistics.isRecording ( )
inline

Returns the status, isRecording is set to true when startRecording is.

Returns the recording status

Returns
- recording status
synchronized void com.kofax.kmc.kut.utilities.appstats.AppStatistics.logSessionEvent ( AppStatsSessionEvent  sessionEvent)
inline

This method allows the application a means of recording an application-defined Session event.

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. The logSessionEvent accepts as a parameter an AppStatsSessionEvent object.

See also
beginSession and endSession.
Parameters
sessionEventincludes all the properties necessary to define a specific AppStats Session event.
synchronized ErrorInfo com.kofax.kmc.kut.utilities.appstats.AppStatistics.purge ( )
inline

The purge method erases the AppStats memory buffer and the AppStats recording database file.

The database file was specified by the initAppstats method. Recording must be disabled before calling this method. After this call, the library AppStats is set to an uninitialized state. You must call initAppStats again to begin another session. 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.

Exceptions
KmcException(ErrorInfo.KMC_UT_STATS_NOTHING_TO_PURGE)
KmcRuntimeException(ErrorInfo.KMC_UT_STATS_RECORDING_NOT_OFF)
void com.kofax.kmc.kut.utilities.appstats.AppStatistics.registerExportHandler ( AppStatsDsExportHandler  handler)
inline

The export method creates a SQL dump or other file format of the internal data store.

The export method allows the user to either use the built-in handler for exporting data from the datastore, or the user can write a custom handler to write their own export functionality.

In order to write a custom handler write a class that implements AppStatsDsExportHandler, register the handler, while adding the listener make sure to choose the right export format type.

Parameters
handler- Custom handler
void com.kofax.kmc.kut.utilities.appstats.AppStatistics.removeAppStatsExportListener ( AppStatsExportListener  listener)
inline

Removes an event listener for the export method.

This method removes an event listener for the export method.

void com.kofax.kmc.kut.utilities.appstats.AppStatistics.removeAppStatsThresholdListener ( AppstatsThresholdReachedListener  listener)
inline

Removes an event listener for the threshold detection.

This method removes an event listener for theshold detection.

void com.kofax.kmc.kut.utilities.appstats.AppStatistics.removeAppStatsWriteFileListener ( AppStatsWriteFileListener  listener)
inline

Removes an event listener for the writeToFile method.

This method removes an event listener for the writeToFile method.

void com.kofax.kmc.kut.utilities.appstats.AppStatistics.setDeviceId ( String  userDeviceID)
inline

Sets the current DeviceID which is recorded as a field in the Environment table.

The application is free to set any device-specific identifier. If no DeviceID is specified, a null or empty string value will be recorded and exported as the 'DeviceID' field in the Environment table.

void com.kofax.kmc.kut.utilities.appstats.AppStatistics.setFileSizeThreshold ( int  fileSizeThreshold)
inline

When the file reaches the threshold specified SizeThresholdReached event will be fired

Parameters
fileSizeThreshold
void com.kofax.kmc.kut.utilities.appstats.AppStatistics.setListenerCallbackThreadType ( ListenerCallbackThreadType  listenerCallbackThreadType)
inline

Set the ListenerCallbackThreadType.

Set the thread type for asynchronous callbacks. The application can choose whether to receive event callbacks on the worker thread used to record, write and export AppStats events, or on the main UI thread. The default value is ListenerCallbackThreadType.UI_THREAD.

void com.kofax.kmc.kut.utilities.appstats.AppStatistics.setRamSizeThreshold ( int  ramSizeThreshold)
inline

Each time a multiple of this threshold is met a SizeThresholdReached event will fire (0 turns off event triggering for file usage).

Parameters
ramSizeThreshold
synchronized ErrorInfo com.kofax.kmc.kut.utilities.appstats.AppStatistics.startRecord ( )
inline

Start recording app statistics, or continues recording.

Use this method to start recording statistics during normal library operations. This will set the isRecording property to true, and open the SQLite database.
This method is only valid if you have initialized AppStats by calling initAppStats to create the database file.

synchronized ErrorInfo com.kofax.kmc.kut.utilities.appstats.AppStatistics.stopRecord ( )
inline

Stop recording data while retaining data that has been collected.

Use this method to stop recording. This will set the isRecording property to false, and close the data repository to ensure anything in memory is flushed to the file system.
This method is only valid if you previously started recording.

synchronized void com.kofax.kmc.kut.utilities.appstats.AppStatistics.upgradeSchema ( String  datastoreName)
inline

Upgrade existing datastore from earlier AppStats release to current schema.

This method is used when a new version of the Mobile SDK needs to initialize, write to, and export from an earlier version of an AppStats datastore. The datastore schema can change between releases of the Mobile SDK, and an earlier version of the AppStats datastore may need to be upgraded to the current datastore schema. If you attempt to initialize an older AppStats datastore that is incompatible with the current schema, a KmcRuntimeException with an ErrorInfo of KMC_UT_STATS_DATASTORE_OUT_OF_DATE will be thrown.

Parameters
datastoreName- name of the datastore to upgrade.
synchronized ErrorInfo com.kofax.kmc.kut.utilities.appstats.AppStatistics.writeToFile ( )
inline

Writes the in-memory statistics buffer to the AppStats database.

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.

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.

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.


The documentation for this class was generated from the following file:
Untitled Document © 2016 Atalasoft, Inc., 116 Pleasant St, Suite 321, Easthampton, MA 01027, U.S.A. All rights reserved. Use is subject to license terms.