WLAnalytics
WLAnalytics means of persistently capturing analytics data and provides a method call to send captured data to the IBM MobileFirst Platform server, to be forwarded to the Operational Analytics engine.
Capture is on by default.
When this WLAnalytics class's capture flag is turned on via enable method call, all messages passed through this class's log method will be persisted to file in the following JSON object format:
{ "timestamp" : "17-02-2013 13:54:27:123", // "dd-MM-yyyy hh:mm:ss:S" "level" : "ERROR", // ERROR || WARN || INFO || LOG || DEBUG "package" : "your_tag", // typically a class name, app name, or JavaScript object name "msg" : "the message", // a helpful log message "metadata" : {"hi": "world"}, // (optional) additional JSON metadata, appended via doLog API call "threadid" : long // (optional) id of the current thread }
Method Summary
Public Methods | ||
public |
addDeviceEventListener(deviceEvent: string) Enable analytics to capture the specified DeviceEvent |
|
public |
disable() Disable persistent capture of analytics data. |
|
public |
enable() Enable persistent capture of analytics data. |
|
public |
Log data you want to be captured in the context of "analytics". |
|
public |
removeDeviceEventListener(deviceEvent: string) Disable analytics from capturing the specified DeviceEvent |
|
public |
send() Send the accumulated log data when the persistent log buffer exists and is not empty. |
|
public |
async sendWithCallback(): Promise Send the accumulated log data when the persistent log buffer exists and is not empty. |
|
public |
setUserContext(user: string) Specify current application user. |
|
public |
Unset any user context previously set. |
Public Methods
public addDeviceEventListener(deviceEvent: string) source
Enable analytics to capture the specified DeviceEvent
Params:
Name | Type | Attribute | Description |
deviceEvent | string | A string representation of the device event to capture. Valid values are "LIFECYCLE" and "NETWORK" |
public enable() source
Enable persistent capture of analytics data. Enable, and thus capture, is the default.
public log(message: string, metadata: Object) source
Log data you want to be captured in the context of "analytics". Some data is already captured by the framework. To avoid collisions, the following keys will be excluded if logged: appStoreID appStoreLabel appStoreVersion appStoreVersionDisplay mfpAppName mfpAppVersion deviceBrand deviceOSversion deviceOS deviceModel deviceID timezone timestamp
public removeDeviceEventListener(deviceEvent: string) source
Disable analytics from capturing the specified DeviceEvent
Params:
Name | Type | Attribute | Description |
deviceEvent | string | A string representation of the device event to capture. Valid values are "LIFECYCLE" and "NETWORK" |
public send() source
Send the accumulated log data when the persistent log buffer exists and is not empty.
public async sendWithCallback(): Promise source
Send the accumulated log data when the persistent log buffer exists and is not empty.
public setUserContext(user: string) source
Specify current application user. If you want user-based analytics, you must use this method call. For example, use it when the user logs in, and call the unsetUserContext method when the user logs out. Or if your application supports user profiles, call this method when the user profile changes.
Params:
Name | Type | Attribute | Description |
user | string | User ID for the current app user. |