This topic describes how to develop custom event analysis function on the Android client, including:
Integrate MAS component
Integrate MAS component by referring to Access Android - Quick start guide.
Record event logs
The section guides you how to record event logs through a code sample, and gives introduces the parameters involved in the code sample.
Code sample
In the following code example, the client will record the business ID, event ID, payment time, user ID, and payment method corresponding to the event.
import com.mpaas.mas.adapter.api.MPLogger;
import java.util.HashMap;
import java.util.Map;
// 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.
params.put("pay_time", String.valueOf(System.currentTimeMillis()));
// Attribute: user ID
params.put("user_id", "the-userId");
// Attribute: payment mode
params.put("payment_method", "alipay");
// Print logs
MPLogger.event(logId, bizType, params);Parameters description
Parameter | Description |
bizType |
|
logId |
|
params |
|
Report logs
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 MAS server. During development testing, you can call the following APIs to forcibly report local logs to the server immediately:
import com.mpaas.mas.adapter.api.MPLogger;
MPLogger.uploadAll();