This topic describes how to develop custom event anlaysis funciton on the Android client, including:
Access Mobile Analysis Service by referring to Access Android - Quick start guide.
The section guides you how to record event logs through a code sample, and gives introduction about the parameters involved in the code sample.
// Specify the business ID
String bizType = "Pay";
// Event ID
String logId = "PayResults";
// Add attributes
Map<String, String> params = new HashMap<>(4);
// Attribute: payment time. Key corresponds to the attribute ID and Value corresponds to the attribute value.
// Attribute: user ID
// Attribute: payment mode
// Print logs
MPLogger.event(logId, bizType, params);
bizType (business ID)
bizTypespecifies the business ID (also known as business code or business type), which is the unique identifier of a business. In the code sample, bizType is set to
Pay, indicating payment business.
bizTypeaffects the log file name on the client. The log file naming format is
logId (event ID)
logIdspecifies the event ID, which is the unique identifier of an event. For more information, see the description of tutorial scenario in About this tutorial.
params (event attribute)
paramsstores attributes associated with events. In
param-key: corresponding to the attribute ID. For more information, see the description of tutorial scenario in About this tutorial.
Param-value: corresponding to the attribute value. The attribute value is stored as a character string on the client. In actual analysis, the server supports converting the attribute value into a character, integer, or float value.
By default, when logs cached on the client reach a certain number or the program runs in the backend for a certain period of time, local logs are automatically reported to the Mobile Analysis server. During development testing, you can call the following APIs to forcibly report local logs to the server immediately: